help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Difference between normal_rnd (m,v, n,n) and randn (n)


From: Henry F. Mollet
Subject: Difference between normal_rnd (m,v, n,n) and randn (n)
Date: Thu, 04 Mar 2004 11:45:30 -0800
User-agent: Microsoft-Entourage/10.1.1.2418

What's the difference between between using normal_rnd (m,v, n,n) and randn
(n) to generate random numbers from a normal distribution. The former takes
much longer? I'll probably only need 10+4 random numbers rather than 10+6,
so speed may not present an actual problem but for other distributions only
the slower random number generator is available? But it is great to have all
these distributions available (from beta to uniform). The only one I haven't
found yet is a triangular distribution.
Henry

octave:42> tic, X=normal_rnd(10,0.2603,1000,1000); toc
ans = 20.504
% creation of 10+6 random numbers with mean 10.0 and variance 0.2603 (std
0.5102) takes about 20 sec
(less cpu-time but I'm doing nothing else).
Check on normal distribution generated after reshaping into vector, gave
mean = 9.9993, std = 0.5109, skewness = 0.0050, kurtosis = 0.0015.

octave:53> tic, Y = 10 + 0.5102*randn(1000); toc
ans = 1.5279
% creation of 10+6 random numbers with mean 10.0 and variance 0.2603 using
randn only takes about 1.5 sec. Check on normal distribution generated after
reshaping into a vector gave mean = 9.9999, std = 0.5103, skewness =
-0.0020, kurtosis = -0.0049.







-------------------------------------------------------------
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
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]