尝试在 GSL 中使用累积分布函数

发布于 2024-09-07 20:12:10 字数 637 浏览 5 评论 0原文

大家好,我正在尝试使用 GSL(Gnu 统计库)计算 C 中公式的标准正态分布的累积分布函数,

我已经安装并包含了 gsl,但我无法理解如何使用它。

我认为我需要的函数是:

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

我的公式只有一个数字,我将其传递给 cdf 函数,所以我不太确定在这里要做什么。 (这可能是因为我对统计数据的理解很差)

我将不胜感激,任何人都可以帮助我了解如何使用带有一个输入变量的 gsl 获取 cdf。

文档仅说明:

此函数返回对数正态分布的随机变量。分布函数为

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

对于 x > 0.

基本上,有人可以解释一下 gsl_rng、zeta 和 sigma 应该是什么吗?

编辑:好的,我认为 zeta 应该为 0 (mu),sigma 应该为 1 (std dev) 才能正常?是这样吗? gsl_rng 是什么?

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:

This 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不必在意 2024-09-14 20:12:10

gsl_rng 是指向已初始化(以及可能的自定义种子)随机数生成器的指针。

例如,请参见 http://www.csse.uwa .edu.au/programming/gsl-1.0/gsl-ref_16.html

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

掀纱窥君容 2024-09-14 20:12:10

泰勒,

我希望你的问题已经解决了。我自己不是编程大师,但我会尽力提供帮助。我认为有几点。

您需要的是gsl_cdf_gaussian_P。另一件事(gsl_ran_lognormal)不合适有两个原因。

1)它是一个随机数生成器,而不是累积分布。这意味着它会根据您的需要为您提供遵循特定分布的数字,而不是概率。

2)它指的是对数正态分布,而你想要的是正态分布。

一旦获得正态累积分布,您可以将平均值设为 0,将方差设为 1,使其成为标准正态分布。

我希望这能澄清情况。如果没有的话,我早上会再来这里。

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.

为你鎻心 2024-09-14 20:12:10

您的函数用于生成具有对数正态分布的随机数。如果您正在寻找累积分布,您需要查看 GSL 手册第 7.15 节的“特殊函数”部分。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文