[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug in randperm?
From: |
Juan Pablo Carbajal |
Subject: |
bug in randperm? |
Date: |
Sat, 30 Dec 2017 18:29:56 +0100 |
Hi all,
According to the docstring of randperm "all permutations are equally
likely". Therefore I was expecting that the resulting histogram from
the script below was more or less 1 until N-n and then went to zero
N = 100;
n = 10;
x=zeros(1e4,1);
for i=1:length(x);
x(i) = min (randperm (N, n));
end
hist (x,1:100)
set (gca, 'xtick', 1:9:100)
axis tight
Even with n=2 it seems that small indexes are more likely than larger
ones (seems exponential). Am I misunderstanding something here or is
this a bug?
- bug in randperm?,
Juan Pablo Carbajal <=