[Numpy-discussion] Random Numbers

Karthikesh Raju karthik at james.hut.fi
Wed Jun 2 08:29:03 EDT 2004


Hi Bruce and All,

Probably i jumped the wagon and thought the problem was with randn.
Think i have isolated the problem:

say:

a = rand(10000) > 0.5
b = rand(10000) > 0.5

now to compare and find the number of differences or errors:

sum(a!=b) or sum(not_equal(a,b))

How can this value be negative at times?

With warm regards
karthik




-----------------------------------------------------------------------
Karthikesh Raju,		    email: karthik at james.hut.fi
Researcher,			    http://www.cis.hut.fi/karthik
Helsinki University of Technology,  Tel: +358-9-451 5389
Laboratory of Comp. & Info. Sc.,    Fax: +358-9-451 3277
Department of Computer Sc.,
P.O Box 5400, FIN 02015 HUT,
Espoo, FINLAND
-----------------------------------------------------------------------

On Wed, 2 Jun 2004, Bruce Southey wrote:

> Hi,
> All three use different but well-known algorithms
>
> For Matlab 5 onwards, this references the randn (which is the standard normal):
> http://www.mathworks.com/company/newsletters/news_notes/clevescorner/spring01_cleve.html
>
> (You also note the link to Matlabs uniform generator that has excellent
> properties.)
>
> numarray.random_array.normal that uses ranlib snorm (snorm is the standard normal).
>
> numarray.linear_algebra.mlab.randn uses the Box-Muller method using random
> uniform numbers from ranlib.
>
> Your problems suggest that randn is not the cause. Without any code or what you
> want to do it hard to address your question except that you should ensure that
> your sampling does provide the normal distribution with your parameters. By that
> I mean draw many, many samples from one set of parameters and check the
> estimated mean and variance.
>
> Regards
> Bruce
>
> ---- Original message ----
> >Date: Wed, 2 Jun 2004 17:27:02 +0300
> >From: Karthikesh Raju <karthik at james.hut.fi>
> >Subject: [Numpy-discussion] Random Numbers
> >To: numpy-discussion at lists.sourceforge.net
> >
> >Hi All,
> >
> >How close is the random number generation from
> >numarray.random_array.normal(0,1,x) or
> >numarray.linear_algebra.mlab.randn(x) to matlab's randn?
> >
> >i am having problems with an identical program written in matlab and
> >python, with the results entirely different in both cases :(
> >
> >Warm regards
> >
> >karthik
> >
> >
> >-----------------------------------------------------------------------
> >Karthikesh Raju,		    email: karthik at james.hut.fi
> >Researcher,			    http://www.cis.hut.fi/karthik
> >Helsinki University of Technology,  Tel: +358-9-451 5389
> >Laboratory of Comp. & Info. Sc.,    Fax: +358-9-451 3277
> >Department of Computer Sc.,
> >P.O Box 5400, FIN 02015 HUT,
> >Espoo, FINLAND
> >-----------------------------------------------------------------------
> >
> >
> >-------------------------------------------------------
> >This SF.Net email is sponsored by the new InstallShield X.
> >From Windows to Linux, servers to mobile, InstallShield X is the one
> >installation-authoring solution that does it all. Learn more and
> >evaluate today! http://www.installshield.com/Dev2Dev/0504
> >_______________________________________________
> >Numpy-discussion mailing list
> >Numpy-discussion at lists.sourceforge.net
> >https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>
>




More information about the NumPy-Discussion mailing list