How to calculate probit in C++
c++, sas, statistics
Solution
Using the boost math library and the definition of probit you found on the wikipedia article I came up with the following. No warranties here :-)
#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);
}
Problem
I'm converting some SAS code into C++ but currently stuck on how to calculate the probit function. I believe I've found the probit formula (http://en.wikipedia.org/wiki/Probit) but my statistics knowledge is a little rusty. So basically I need someone to convert this to C++, or tell me if there is the same method under another name.