首页 > 解决方案 > 逆高斯分布c ++

问题描述

我想用 C++ 做一个程序,可以得到一个数字的逆高斯分布,就像NORM.S.INV在 Excel 中一样:

=NORM.S.INV(0.95) -> 1.644853627

我尝试使用 Boost,https://www.boost.org/doc/libs/1_53_0/libs/math/doc/sf_and_dist/html/math_toolkit/dist/dist_ref/dists/inverse_gaussian_dist.html

问题是我不知道如何使用 boost 包来做到这一点。我厌倦了下面的程序:

#include <boost/math/distributions/inverse_gaussian.hpp>
#include <iostream>

int main() {
    std::cout << "Hello world" << std::endl;
    using boost::math::inverse_gaussian;
    double Inverse = inverse_gaussian my_ig(2, 3);
    std::cout << Inverse;
    return 0;
}

但它给了我error: expected primary-expression before 'my_ig'。有谁知道我做错了什么?

标签: c++statistics

解决方案


我认为 inverse_gaussian costructor 不能返回双精度...例如此代码有效。 inverse_gaussian my_ig(2, 3); std::cout << my_ig.mean();


推荐阅读