[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: problem with rand ?
From: |
Paul Kienzle |
Subject: |
Re: problem with rand ? |
Date: |
Wed, 28 Jul 2004 02:08:50 -0400 |
Dimitri,
Running the simple birthday test on randn, I got 47 out of 100
trials with no duplicates instead of the expected 50, so it also
suffers the same problem.
Extending randn to 53 bits will take some thought. No guarantees
I will get to it any time soon, so if anyone is inspired, please fix it.
- Paul
On Jul 27, 2004, at 11:46 PM, Dmitri A. Sergatskov wrote:
I found that random series returned by rand (from octave-forge) returns
a higher number of _identical_ values than I would expect:
octave:1> s1=rand(1,128*1024); ss1=sort(s1); dss1=diff(ss1);
any(dss1==0)
ans = 1
octave:2> s1=rand(1,128*1024); ss1=sort(s1); dss1=diff(ss1);
find(dss1==0)
ans = [](1x0)
octave:3> s1=rand(1,128*1024); ss1=sort(s1); dss1=diff(ss1);
find(dss1==0)
ans = 60641
octave:4> s1=rand(1,128*1024); ss1=sort(s1); dss1=diff(ss1);
find(dss1==0)
ans = [](1x0)
octave:5> s1=rand(1,128*1024); ss1=sort(s1); dss1=diff(ss1);
find(dss1==0)
ans =
26998 27604
octave:6> s1=rand(1,128*1024); ss1=sort(s1); dss1=diff(ss1);
find(dss1==0)
ans = 16034
octave:7> s1=rand(1,128*1024); ss1=sort(s1); dss1=diff(ss1);
find(dss1==0)
ans = 23032
octave:8> s1=rand(1,128*1024); ss1=sort(s1); dss1=diff(ss1);
find(dss1==0)
ans = 121716
etc...
I would think that for random 2^17 numbers probability of two identical
numbers would be something like 2^17 / 2^54 (assuming ieee 64 bit
double
representation)
Matlab does not show this behavior even for larger series:
>> s1=rand(1,256*1024); ss1=sort(s1); dss1=diff(ss1); any(dss1==0)
ans =
0
>> s1=rand(1,1024*1024); ss1=sort(s1); dss1=diff(ss1); any(dss1==0)
ans =
0
>> s1=rand(1,1024*1024); ss1=sort(s1); dss1=diff(ss1); any(dss1==0)
ans =
0
Am I missing something here?
Sincerely,
Dmitri.
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------