开发者

Trying to use Cumulative Distribution Function in GSL

Hey guys, I'm trying to compute the cumulative distribution function of the standard normal distribution for a formula in C using the GSL (Gnu Statistics Library)

I've installed and included gsl but am having trouble understanding how to use it.

I think the function I need is:

double gsl_ran_lognormal (const gsl_rng * r, double zeta, double sigma)

The formula I have only has one number that I would pass into a cdf function so I'm not quite sure what to do here. (This is probably because of my crappy understanding of statistics)

I would appreciate it anyone could lend me a hand on how to get the cdf using gsl with one input variable.

Documentation only says:

Thi开发者_如何转开发s function returns a random variate from the lognormal distribution. The distribution function is,

p(x) dx = {1 \over x \sqrt{2 \pi \sigma^2} } \exp(-(\ln(x) - \zeta)^2/2 \sigma^2) dx

for x > 0.

Basically, could someone explain what gsl_rng, zeta, and sigma should be?

EDIT: Ok, I think that zeta should be 0 (mu) and sigma should be 1 (std dev) to make it normal? Is that right? What is gsl_rng?


gsl_rng is a pointer to an initialized (and possible custom seeded) random number generator.

See for example http://www.csse.uwa.edu.au/programming/gsl-1.0/gsl-ref_16.html


Tyler,

I hope your problem is solved already. I am not a programming guru myself but I try to help. I think there are several points.

What you need is gsl_cdf_gaussian_P. The other thing (gsl_ran_lognormal) is inappropriate for two reasons.

1)It is a random number generator and not a cumulative distribution. That means it gives you numbers following a particular distribution, rather than a probability, as you need it.

2)It refers to the lognormal distribution, while you want the normal one.

Once you have a normal, cumulative distribution you can put the mean to 0 and the variance to unity to make it standard normal.

I hope this clarifies the situation. If not, I am here again in the morning.


Your function is for generating a random number with a lognormal distribution. If you are looking for the cumulative distribution you need to look in the "Special Functions" section of the GSL manual, section 7.15.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜