我试图实现一个函数来计算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);
不确定如何计算它,即使创建了这个实例(在我得到它之前只会命中和错过),所以帮助使用它来计算函数将是非常感谢的,谢谢。
发布于 2022-01-05 15:38:29
好的,你想要的是x-平方分布的逆分布(即它的分位数),还是想要“逆齐平方分布”,它本身就是一个分布,也是一个逆/分位数分布!
如果前者,然后假设v自由度,以及概率p,那么这就做到了:
#include <boost/math/distributions/chi_squared.hpp>
double chi_squared_quantile(double v, double p)
{
return quantile(boost::math::chi_squared(v), p);
}如果是后者,则示例用法可能是:
#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。
https://stackoverflow.com/questions/70594837
复制相似问题