Let's say I implement an algorithm that shuffles a deck by simply swapping any 2 cards. How many times do I need to swap in order to have an even number of chances for any order.
Assume the following pseudocode:
for n=0: n<num_iterations:
r1 = random(52)
r2 = random(52)
swap(card[r1],card[r2])
Assume that the random() function returns a value between 0 and 51 inclusively, with perfectly normal distribution. What value should num_iterations be in order to have the deck with even probabilities across all permutations?
Does it make a difference if r1 and r2 are possibly identical any number of times?
To be clear, the question is not about the algorithm in particular or how to improve it. It is about how to calculate the value num_iterations, such that any bias is statistically insignificant. I understand this is not a good algorithm but if num_iterations
where n² say, I'm sure any bias would statistically vanish, but there is likely a lower value than n². What is it? How can it be calculated?