# log-normal and gaussian distribution - array generation

Hi experts!

I wanna generate a random number array of size=N using a log normal distribution. From http://en.wikipedia.org/wiki/Log-normal_distribution i wanna use the parameters mu and sigma.

I know that I must do:

form scipy.stats import lognorm
new_array = lognorm.rvs(......, size=N)


What must I set like parameters (loc, s, scale, etc.) for use mu and sigma distribution parameters.

In the same way: what must I do in

new_array = norm.rvs(......, size=N)


for generate a array of random numbers using a gaussian distribution with parameters mu and sigma?

Thanks a lot!

edit retag close merge delete

Sort by ยป oldest newest most voted

You might also prefer to use numpy.random. You can get help at:

http://docs.scipy.org/doc/numpy/refer...

For example, try:

import numpy.random as rdm
rdm.normal(4,1,10)
rdm.lognormal(4,2,20)

more

Thanks a lot!!

( 2013-11-05 13:12:01 +0100 )edit

You can convert a normal or log distribution with mu=0 and sigma=1, which is the default to whatever you want. For eg. for normal distribution you can use the following to get a normal distribution with sigma=10 and mu=1

from scipy.stats import norm
R = norm.rvs(size=10)
sigma=10
mu=1
print sigma*R+mu

more