I do some hypothesis tests in a card game.
To do this, I implemented the game and the AI that play the game. For the test, I have to make a selection on the space of all the possibilities of arranging cards in my deck (the deck has 24 for the cards, so there are 24 different initial states of the deck). However, the selection should be independent in the sense that (a) after shuffling the deck, each initial layout should have a probability of (1/24!) And (b) if I and I are two initial arrangements after two shuffling of the deck, the probability that location i, and then location i 'was the initial location, should be (1/24!) x (1/24!). [Note1]
So if d is my deck and shuffleDeck is my function to shuffle the deck. I believe that the random monad was constructed in such a way that the Probability ((suffleDeck d) == i) = 1/24!
But my question is: is this function independent when interacting with the replicateM function? In other words, the following is true:
P ((replicateM 2 (shuffleDeck d)) == [i, i ']]) = P ((suffleDeck d) == i) * P ((suffleDeck d) == i')
where P (x = X) is the probability of x being X.
The code I'm using for shuffling is below:
import System.Random
shuffleDeck d = do
seed <- newStdGen
return $ shuffle seed d
shuffle :: StdGen -> [Card] -> [Card]
shuffle g [] = []
shuffle g d = c : shuffle g' d'
where (c, g') = oneRandomCard g d
d' = d\\[c]
oneRandomCard :: StdGen -> [Card] -> (Card, StdGen)
oneRandomCard g d =((last $ take n d), g1 )
where (n,g1) = randomR (1, length d) g
I see that at first glance this question seems trivial, but given the way heckell relates to chance, I thought it was worth the question.
[1] : , . , . .
[2] . , , System.Random Control.Monad.Random.