[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] Lognormal normal distribution within prescribed range lim
John D Lamb
Re: [Help-gsl] Lognormal normal distribution within prescribed range limits
Wed, 04 Jul 2012 15:36:22 +0100
Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1
On 04/07/12 14:21, Ghani, Irfan wrote:
> Hello, I am wondering, how can I get Lognormal distribution within a
> certain prescribed range limit. Following two functions gives
> lognormal variant and density distribution respectively in a range of
> [0, infinity].
> Function: double gsl_ran_lognormal (const gsl_rng * r, double zeta,
> double sigma);
> and Function: double gsl_ran_lognormal_pdf (double x, double zeta,
> double sigma)
> However, I could not figure out how to use these functions
> particularly the gsl_ran_lognormal() , to get a variant in a
> predefined range limit say [10, 200]. I will highly appreciate any
> sort of help and hint.
It depends on what you really want to do.
If you know the mean and standard deviation and want a truncated
lognormal distribution then you can resample from the lognormal
distribution until you get a value in the required range. This is not
particularly efficient, but it is effective.
If you want a distribution that has lognormal shape but starts at 10
then all you need do is subtract 10 from the mean value you want and add
a shift of 10 to the variate returned by gsl_ran_lognormal. I think you
have to compute zeta and sigma from the mean and standard deviation you
have, but the formulas for the mean and standard deviation (see, for
example, mathworld.wolfram.com) are invertible.
If you don’t know mean and standard deviation but want a roughly
lognormal-shaped distribution starting at 10 and having values over 200
with low probability, then you’ll have to do some calculation with the
distribution function of the lognormal to identify values of zeta and
sigma that give an upper tail area with the specified probability. But
note that you’ll need one more equation involving zeta and sigma to get
a unique solution.
John D Lamb