  We consider the problem of testing the dimension of uncharacterised classical
and quantum systems in a prepare-and-measure setup. Here we assume the
preparation and measurement devices to be independent, thereby making the
problem non-convex. We present a simple method for generating nonlinear
dimension witnesses for systems of arbitrary dimension. The simplest of our
witnesses is highly robust to technical imperfections, and can certify the use
of qubits in the presence of arbitrary noise and arbitrarily low detection
efficiency. Finally, we show that this witness can be used to certify the
presence of randomness, suggesting applications in quantum information
processing.
