http://qs321.pair.com?node_id=1131257


in reply to Random shuffling

Prima facie, the code looks right. Not sure you need to shuffle 10 times over, but why not? But you haven't really said what you aim is. The shuffle function of the List::Util module is supposed to return the input values in a random order. If your random order is not the same as the one in published sources, this is good news, isn't it? If you obtained the same result, then this would be a strong indication that the random function is not right.

Or, said in other words, if your random output is not the same as the random output of someone else, then it tends to confirm that this is really random (or, at least, that there is no proof that it is misbehaving). But the fact that your random output is different from someone else random output does not mean that your result is any better or worse than someone else's result.

I think you need to explain more what you are trying to do.

Or did I entirely miss your point? I am not a biologist and my knowledge of genetics essentially dates back from the mid-1970s, so a very long time ago both in terms of what I remember about it and in terms of the progresses made in between.

Then, there is the question of whether the (pseudo-)random order provided by shuffle is good enough to suit your purposes. This is a very difficult question and, besides the fact that I do not know your purposes, I just don't know how good shuffle is. Donald Knuth's The Art of of Computer Programming, Vol. 2, has almost 200 pages on random numbers generation, I think that this shows that this is a rather difficult problem.

Replies are listed 'Best First'.
Re^2: Random shuffling
by onlyIDleft (Scribe) on Jun 20, 2015 at 18:23 UTC

    Thank you, that was an insightful reply

    First time I tried to shuffle, I used a different Perl module, but exact same syntax otherwise. That module is

    use Array::Shuffle qw(shuffle_array shuffle_huge_array); # from https://metacpan.org/source/SALVA/Array-Shuffle-0.03/samples/benchmark.pl

    I got inexplicable results using that module to randomly shuffle the sequences. That one is supposed to use the Fisher Yates Knuth algorithm. I contacted the author of the Perl module, and he suggested I cross verify using another Perl module. So using List::Util now.

      And can you say what is inexplicable in the results you obtained?