haskell - Is the Random Monad independent between replicateM iterations? -
I'm testing some hypotheses in card games.
To do this, I have brought games and AI in play that play games. For the examination, I have to do a sample in place of all the possibilities of arranging cards in my deck (24 for deck cards, so there are 24! Different initial state of deck) However, this sample should be independent in the sense that (A) After the shuffle of deck, there should be a possibility in each preliminary arrangement (1/24!) And (b) if I and I have two shifts of two decks that the arrangement i and then arrange May include 'at initial system (1/24!) X (1/24!) Should be. [Note 1]
So, if d is my deck and Shuffle deck is my job to manipulate the deck. I believe in The probability that random mood was created in a way ((suffleDeck d) == i) = 1/24!
But my question is: Is it free when interacting with function function replicateM? In other words, is the following true?
P ((Repeat M2 (Shuffle Ditch D)) == [i, i ']) = P ((suffleDeck d) == i) * P (suffleDeck D) = = I ')
Where P (x = x) is the probability of x x
The code that I have been using for shuffle is given below:
import system. Random Shuffle Deck D = Beed Seed & lt; - newStdGen $ resize seed de-shuffle return :: StdGen - & gt; [Card] - & gt; [Card] Shuffle G [] = [] Shuffle GD = C: Shuffle G 'D' where (C, G ') = ARENDMACKARD GD D' = D \\ [C] ARENDAMCARD :: STGN - & gt; [Card] - & gt; (Card, stedegen) arendactcard gd = (take the last dollar, Nd), g1) where (n, g1) = initial r (1, length d) g
i see I know that this question seems trivial before, but the way Hackel has remembered that treats randomness, I thought it was worth a question.
[1] Note: Distribution is not needed as I said. It is just a known distribution, so I can assess the test power but in this case it should be the same.
[2] Note: As mentioned in a comment, the function controls. Uses Random.
Since your example is only for replicateM
in the IO The question is actually made a bit sick
Replication M2 (Shuffel Deck D)
type IO [[Card]]
. It will never be equal to any type of [[Card]]
. But when this technical problem is really important when using Haskell, then I am going to ignore it to answer that which I think is your underlying question.
As far as I can tell, your basic question is whether the difference between two of the following snippets of code:
Deck D = Boplika M2 ( Sheffel Deck D)
and
deck D = DE1 and Lt; - Shuffle Deck DD2 & Lt; - Shuffle deck D [D1, D2]
If there is a difference between the two, then the example for the type of question has been broken. Monaad
With the definition of replicateM
, mond laws require those expressions to have the same results.
Comments
Post a Comment