Feature #10225 » _ math.c New method Math.normcdf.PATCH
math.c | ||
---|---|---|
/*
|
||
* call-seq:
|
||
* Math.normcdf(x) -> Float
|
||
*
|
||
* Calculates cumulative distribution function (CDF) of the standard normal distribution for +x+.
|
||
*
|
||
* Domain: (-INFINITY, INFINITY)
|
||
*
|
||
* Codomain: (0.0, 1.0)
|
||
*
|
||
* Math.normcdf(0) #=> 0.5
|
||
*
|
||
*/
|
||
static VALUE
|
||
math_normcdf(VALUE obj, VALUE x)
|
||
{
|
||
double d0, d;
|
||
Need_Float(x);
|
||
d0 = RFLOAT_VALUE(x);
|
||
d = 0.5 * (1.0 + erf(d0 / sqrt(2)));
|
||
return DBL2NUM(d);
|
||
}
|
||
/*
|
||
* call-seq:
|
||
* Math.gamma(x) -> Float
|
||
*
|
||
* Calculates the gamma function of x.
|
||
... | ... | |
rb_define_module_function(rb_mMath, "erf", math_erf, 1);
|
||
rb_define_module_function(rb_mMath, "erfc", math_erfc, 1);
|
||
rb_define_module_function(rb_mMath, "normcdf", math_normcdf, 1);
|
||
rb_define_module_function(rb_mMath, "gamma", math_gamma, 1);
|
||
rb_define_module_function(rb_mMath, "lgamma", math_lgamma, 1);
|
||
}
|