How to get Gaussian distribution quantile in c++

67 Views Asked by At

What is the C++ equivalent of python's stats.norm.ppf(probability)? Are there built-in c++ functions for it, or can you call python functions from C++?

Is boost the only way to do it? but I am trouble installing boost.

1

There are 1 best solutions below

0
user17732522 On

The error function is implemented in the C++ standard library as std::erf in <cmath>. However, the inverse error function, which is essentially what you want here, is not implemented in the standard library.

You need to use some third-party library that implements it. Whether that is boost or any other one of course doesn't matter.

There are also going to be general statistics libraries that implement the distribution functions directly for different distributions.

That is no different than in Python. scipy.stats.norm.ppf is also not part of the Python standard library that comes with a Python installation. It is part of the SciPy library.

However, generally the C++ standard library is much narrower in scope than the Python one.

(Alternatively you can of course implement the function yourself.)

Recommendations for specific libraries are off-topic here.