bug in randperm?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

bug in randperm?

Juan Pablo Carbajal-2
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?

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: bug in randperm?

Juan Pablo Carbajal-2
> Am I misunderstanding something here or is this a bug?
A misunderstanding, of course.
A simple exercise shows the case

v = [1,2,3,4];
nchoosek (v, 2)

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: bug in randperm?

Doug Stewart-4


On Sat, Dec 30, 2017 at 12:46 PM, Juan Pablo Carbajal <[hidden email]> wrote:
> Am I misunderstanding something here or is this a bug?
A misunderstanding, of course.
A simple exercise shows the case

v = [1,2,3,4];
nchoosek (v, 2)

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave

I thought that you ran into 

Benford's law 




--
DASCertificate for 206392


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: bug in randperm?

nrjank


On Dec 30, 2017 12:59 PM, "Doug Stewart" <[hidden email]> wrote:

I thought that you ran into 

Benford's law 



Well, I guess I just learned something today. That will be quite enough of that now, thankyouverymuch.

NickJ

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave