[cctbxbb] order bias in flex.random_permutation

Keitaro Yamashita k.yamashita at spring8.or.jp
Thu Sep 11 03:59:36 PDT 2014


Dear cctbx developers,

I happened to notice that the implementation of
flex.random_permutation (scitbx/random.h) results in biased order
because each element is always swapped with the element randomly
selected from entire range of array.

For details, please see the second paragraph and the right figure of
http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#Implementation_errors
I reproduced the plot using flex.random_permutation.

Actually this seems to have less impact because
flex.random_permutation is rarely used in cctbx or phenix as far as I
know.

If needed, I would commit the corrected version (using the algorithm
in the wikipedia article above).


Best regards,
Keitaro


More information about the cctbxbb mailing list