[SciPy-User] log normal distribution random number array generation

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[SciPy-User] log normal distribution random number array generation

Josè Luis Mietta
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!


_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: log normal distribution random number array generation

Paul Hobson-2
Jose,

For lognorm.rvs, mu and sigma translate to loc and scale, respectively. The same is true for norm.rvs

-paul


On Fri, Nov 1, 2013 at 8:17 AM, Josè Luis Mietta <[hidden email]> wrote:
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!


_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user



_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: log normal distribution random number array generation

josef.pktd
On Tue, Dec 3, 2013 at 5:46 PM, Paul Hobson <[hidden email]> wrote:
> Jose,
>
> For lognorm.rvs, mu and sigma translate to loc and scale, respectively. The
> same is true for norm.rvs

For the lognorm, mu and sigma are often used as parameters of the
underlying normal distribution, not directly of the lognormal mean and
scale

"If log(x) is normally distributed with mean mu and variance sigma**2,
then x is log-normally distributed with shape parameter sigma and
scale parameter exp(mu)."
http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.lognorm.html

Josef




>
> -paul
>
>
> On Fri, Nov 1, 2013 at 8:17 AM, Josè Luis Mietta
> <[hidden email]> wrote:
>>
>> 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!
>>
>>
>> _______________________________________________
>> SciPy-User mailing list
>> [hidden email]
>> http://mail.scipy.org/mailman/listinfo/scipy-user
>>
>
>
> _______________________________________________
> SciPy-User mailing list
> [hidden email]
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: log normal distribution random number array generation

Robert Kern-2
On Tue, Dec 3, 2013 at 11:08 PM, <[hidden email]> wrote:
>
> On Tue, Dec 3, 2013 at 5:46 PM, Paul Hobson <[hidden email]> wrote:
> > Jose,
> >
> > For lognorm.rvs, mu and sigma translate to loc and scale, respectively. The
> > same is true for norm.rvs
>
> For the lognorm, mu and sigma are often used as parameters of the
> underlying normal distribution, not directly of the lognormal mean and
> scale
>
> "If log(x) is normally distributed with mean mu and variance sigma**2,
> then x is log-normally distributed with shape parameter sigma and
> scale parameter exp(mu)."
> http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.lognorm.html

Specifically, in order to translate any standard convention to lognorm, you must keep the default loc=0. Most standard conventions for the log-normal distribution do not shift the location at all, just the scale and a shape as explained above.

--
Robert Kern

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user