Beispiel #1
0
float normcdfi(float p, float mu, float sigma2)
{
    //Inverse CDF of normal distribution
    //default: mu=0.0, sigma2=1.0
    if (mu == 0.0 && sigma2 == 1.0)
        //return sqrt(2) * erfi(2 * p - 1);
        return 1.4142135623730951 * erfi(2 * p - 1);
    else
        return mu + sqrt(sigma2) * normcdfi(p, mu, sigma2);      //default: mu=0.0, sigma2=1.0
}
Beispiel #2
0
double lerfi_diff(double x1, double x0)
{
    /* 
       same comment apply as for lerf_diff
     */
    double limit = 25.0, xmin, dx, value;

    if (x1 == x0)
    {
	return -DBL_MAX;
    }
    else
    {
	if (ABS(x1) < limit || ABS(x0) < limit)
	    return log(erfi(x1)-erfi(x0));
	else
	{
	    xmin  = MIN(x0, x1);
	    dx    = MAX(x0, x1) -xmin;
	    value = SQR(xmin) + log((exp(2.*dx*xmin)-1.0)/(2.*xmin)) + log(TWODIVSQRTPI);
	}
    }
    return value;
}
 Real invertCDF(const Real input) const {
   return std::sqrt(2.*variance_)*erfi(2.*input-1.) + mean_;
 }