First time here? Check out the FAQ!

Ask Your Question
0

log-normal and gaussian distribution - array generation

asked 11 years ago

mresimulator gravatar image

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?

Waitign for your answers.

Thanks a lot!

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
1

answered 11 years ago

calc314 gravatar image

updated 11 years ago

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)
Preview: (hide)
link

Comments

Thanks a lot!!

mresimulator gravatar imagemresimulator ( 11 years ago )
0

answered 11 years ago

Shashank gravatar image

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
Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 11 years ago

Seen: 952 times

Last updated: Nov 01 '13