[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
problem with rand ?
From: |
Dmitri A. Sergatskov |
Subject: |
problem with rand ? |
Date: |
Tue, 27 Jul 2004 21:46:18 -0600 |
User-agent: |
Mozilla Thunderbird 0.7.1 (X11/20040626) |
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
-------------------------------------------------------------
- problem with rand ?,
Dmitri A. Sergatskov <=