[Numpy-discussion] random permutation
Sebastian Haase
seb.haase at gmx.net
Sat Jan 13 14:28:14 CST 2007
On 1/13/07, Keith Goodman <kwgoodman at gmail.com> wrote:
> On 1/13/07, Sebastian Haase <seb.haase at gmx.net> wrote:
> > On 1/13/07, Keith Goodman <kwgoodman at gmail.com> wrote:
> > > On 1/13/07, Sebastian Haase <seb.haase at gmx.net> wrote:
> > > > On 1/13/07, Keith Goodman <kwgoodman at gmail.com> wrote:
> > > > > On 1/11/07, Robert Kern <robert.kern at gmail.com> wrote:
> > > > > > Keith Goodman wrote:
> > > > > > > Why is the first element of the permutation always the same? Am I
> > > > > > > using random.permutation in the right way?
> > > > > >
> > > > > > >>> M.__version__
> > > > > > > '1.0rc1'
> > > > > >
> > > > > > This has been fixed in more recent versions.
> > > > > >
> > > > > > http://projects.scipy.org/scipy/numpy/ticket/374
> > > > >
> > > > > I don't see any unit tests for numpy.random. I guess randomness is hard to test.
> > > > >
> > > > > Would it help to seed the random number generator and at least check
> > > > > that you get the same result you got before? No existing problems
> > > > > would be found. But new ones might be caught.
> > > > >
> > > > Hi,
> > > > Is it guaranteed that a given seed produces the same sequence of
> > > > rand-number between different platforms ?
> > > > I thought this might only be guaranteed for "any given computer" to
> > > > reproduce the same numbers.
> > >
> > > I hope, and expect, that it is system independent.
> > >
> > > Here's what I get:
> > >
> > > >> rs = numpy.random.RandomState([123, 901, 789])
> > > >> rs.randn(4,1)
> > >
> > > array([[ 0.76072026],
> > > [ 1.27712191],
> > > [ 0.03497453],
> > > [ 0.09056668]])
> > > >> rs.rand(4,1)
> > >
> > > array([[ 0.184306 ],
> > > [ 0.58967936],
> > > [ 0.52425903],
> > > [ 0.33389408]])
> > > >> numpy.__version__
> > > '1.0.1'
> > >
> > > Linux kel 2.6.18-3-686 #1 SMP Mon Dec 4 16:41:14 UTC 2006 i686 GNU/Linux
> > import numpy
> > rs = numpy.random.RandomState([123, 901, 789])
> > rs.randn(4,1)
> > [[ 0.76072026]
> > [ 1.27712191]
> > [ 0.03497453]
> > [ 0.09056668]]
> > rs.rand(4,1)
> > [[ 0.184306 ]
> > [ 0.58967936]
> > [ 0.52425903]
> > [ 0.33389408]]
> > numpy.__version__
> > '1.0rc1'
> >
> > Windows XP- pentium4 - (non current numpy) -
> >
> > Looks promising - but how about PowerPC macs ...
>
> The random numbers are generated by a fixed algorithm. So they are not
> random at all. As long as everyone is using float64 I would think we'd
> all get the same (pseudo) random numbers.
I understand this - but I thought the algorithm might involve some
rounding(-error) cases that would produce different results especially
when changing the CPU (intel vs. PowerPC). I found this to be true
even for non pseudo-random code that between CPU-types results were
different within a given epsilon.
-Sebastian
More information about the Numpy-discussion
mailing list