首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >利用boost计算Inverse_chi_squared_distribution

利用boost计算Inverse_chi_squared_distribution
EN

Stack Overflow用户
提问于 2022-01-05 14:46:19
回答 1查看 153关注 0票数 1

我试图实现一个函数来计算inverse_chi_squared_distribution,boost有一个名为inverse_chi_squared_distribution的容器,但是当我试图创建类的一个实例时,我得到了这个错误too few template arguments for class template 'inverse_chi_squared_distribution'。我正在使用wsl:ubuntu-18.04和其他boost函数/容器可以正常工作。

下面是生成错误的代码:boost::math::inverse_chi_squared_distribution<double> invChi(degValue);

不确定如何计算它,即使创建了这个实例(在我得到它之前只会命中和错过),所以帮助使用它来计算函数将是非常感谢的,谢谢。

EN

回答 1

Stack Overflow用户

发布于 2022-01-05 15:38:29

好的,你想要的是x-平方分布的逆分布(即它的分位数),还是想要“逆齐平方分布”,它本身就是一个分布,也是一个逆/分位数分布!

如果前者,然后假设v自由度,以及概率p,那么这就做到了:

代码语言:javascript
复制
#include <boost/math/distributions/chi_squared.hpp>

double chi_squared_quantile(double v, double p)
{
   return quantile(boost::math::chi_squared(v), p);
}

如果是后者,则示例用法可能是:

代码语言:javascript
复制
#include <boost/math/distributions/inverse_chi_squared.hpp>

double inverse_chi_squared_quantile(double v, double p)
{
   return quantile(boost::math::inverse_chi_squared(v), p);
}
double inverse_chi_squared_pdf(double v, double x)
{
   return pdf(boost::math::inverse_chi_squared(v), x);
}
double inverse_chi_squared_cdf(double v, double x)
{
   return cdf(boost::math::inverse_chi_squared(v), x);
}

还有其他选项--您可以使用double以外的类型进行计算,然后使用boost::math::inverse_chi_squared_distribution<MyType>来代替方便的typedef inverse_chi_squared

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70594837

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档