matlab - Cumulative Normal Distribution Function in C/C++ with parameters -
i want implement equivalent of matlab normcdf function in c++, have found useful post: cumulative normal distribution function in c/c++ pointing implementation http://www.johndcook.com/cpp_phi.html. want optional mu , sigma parameters in matlab.
is ok, when change this:
x = fabs(x)/sqrt(2.0);
to:
x = fabs(x - mu)/sqrt(2.0 * sigma * sigma);
or supposed else?
watch out - want save sign of x-mu
, not of x
:
int sign = 1; if (x < mu) sign = -1; x = fabs(x-mu)/sqrt(2.0*sigma*sigma);
otherwise scaling correct.
Comments
Post a Comment