c++ - 如何在 C++ 中计算概率

标签 c++ statistics sas

我正在转换一些 SAS code进入 C++,但目前停留在如何计算 probit 上功能。

我相信我已经找到了 probit 公式 ( http://en.wikipedia.org/wiki/Probit ),但我的统计知识有点生疏。所以基本上我需要有人将其转换为 C++,或者告诉我是否有其他名称下的相同方法。

最佳答案

使用 boost 数学库和您在维基百科文章中找到的 probit 的定义,我得出了以下结论。这里没有保证:-)

#include <boost/math/special_functions/erf.hpp>

namespace bm = boost::math;

template<typename T>
T probit(T p)
{
    T root_2 = sqrt(2);

    return root_2 * bm::erf_inv(2*p-1);
}

int main()
{
    double val = 0.9;
    double res = probit(val);
}

关于c++ - 如何在 C++ 中计算概率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16312900/

相关文章:

python - 在 python 中计算下一个表的 T Student Test

sas - Yrdif 返回特定日期跨度的意外值?

c++ - 在游戏中添加计时器

c++ - 模板类的友元函数中的链接错误

hibernate - 是否有一个很好的 GUI 可用于显示 Hibernate 统计信息?

python - 使用 Python 进行具有固定效应的面板数据回归

format - SAS 中的 Bestw.d 格式语法

regex - 使用正则表达式提取 SAS 中的子字符串

C++ C2440 '<function-style-cast>' : cannot convert from 'Node<T> *const ' to 'Iterator<const T>'

c++ - 如何为 Windows 安装 libjpeg?