I was thinking of how to obtain a random shuffle of the Rubik's cube with uniform probability.
Simply trying a randomly generated sequence of turns will not necessarily produce a uniform distribution on the final states!
Alternatively, one could break the cube and reassemble it piece by piece with uniform probability for which piece to put next and in which orientation. Then the cube has a probability of 1/12 of being solvable, so we'd need to reject an expected 11 configurations before we obtain one that's solveable. (This can be checked with known parity checks on the edges and on the corners.)
Is there anything more efficient than this?
- One idea I had could use Metropolis Hastings - if we treat the shuffles of the cube as a graph, then each vertex has degree 12 (single turn metric) or 18 (HTM). But I think that in this case, we would never reject any samples - and so all we are left with is the statement that if we keep randomly applying moves to the cube, the probability distribution we obtain converges to the uniform distribution. A back of the envelope calculation suggests (please correct me if I'm wrong?) that if $N = 4.3*10^{19}$ is the number of valid Rubik's cube shuffles, then we should aim for more than $\frac{\ln{N}}{\ln{12}} \approx 19$ (STM) or $\frac{\ln{N}}{\ln{18}} \approx 16 (HTM)$ turns.
Is there a way to precisely sample a shuffle of a Rubik's Cube with a finite number of steps?
Represent the group of rotations as a permutation group. From a stabilizer chain you can generate uniformly distributed random elements.
Stabilizer chains are the standard data structure for algorithms with permutation groups, you can find a description for example in my lecture notes https://www.math.colostate.edu/~hulpke/CGT/cgtnotes.pdf