eFinancialPlanner  V1.0 (proof of concept)
Personal Financial Planning based on Maslowian Portfolio Theory
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
normdist.h File Reference

Go to the source code of this file.

Macros

#define LOW   0.02425
 
#define HIGH   0.97575
 

Functions

template<class type >
type norminv (type p)
 
template<class type >
type phi (type x)
 
float fast_erfinv (float x)
 
double erfinv (double x)
 

Variables

static const double a []
 
static const double b []
 
static const double c []
 
static const double d []
 

Macro Definition Documentation

#define HIGH   0.97575

Definition at line 72 of file normdist.h.

#define LOW   0.02425

norminv(x)

Lower tail quantile for standard normal distribution function.

This function returns an approximation of the inverse cumulative standard normal distribution function. I.e., given P, it returns an approximation to the X satisfying P = Pr{Z <= X} where Z is a random variable from the standard normal distribution.

The algorithm uses a minimax approximation by rational functions and the result has a relative error whose absolute value is less than 1.15e-9.

Author: Peter John Acklam Time-stamp: 2002-06-09 18:45:44 +0200 E-mail: jackl.nosp@m.am@m.nosp@m.ath.u.nosp@m.io.n.nosp@m.o WWW URL: https://www.math.uio.no/~jacklam

C implementation adapted from Peter's Perl version by Philippe De Brouwer and re-written as a function template (in stead over function overloading as this results in more compact code)

note:

  • requires
    • include <math.h>
    • include <errno.h>

Definition at line 71 of file normdist.h.

Function Documentation

double erfinv ( double  x)

erfinv

calculates the inverse error function. Uses fast_erfinv and performs a two steps of Newton-Raphson correction to achieve full accuracy.

Definition at line 182 of file normdist.h.

float fast_erfinv ( float  x)
inline

fast_erfinv

calculates the inverse error function (correct up to 6 digits)

Definition at line 154 of file normdist.h.

template<class type >
type norminv ( type  p)

Definition at line 73 of file normdist.h.

template<class type >
type phi ( type  x)

Phi(x)

calculates the inverse comulative normal distribution note: - requires <cmath>

  • in stead of function overloading we use a template (shorter code and only one version)

Definition at line 123 of file normdist.h.

Variable Documentation

const double a[]
static
Initial value:
=
{
-3.969683028665376e+01,
2.209460984245205e+02,
-2.759285104469687e+02,
1.383577518672690e+02,
-3.066479806614716e+01,
2.506628277459239e+00
}

Coefficients in rational approximations. needed for norminv()

Definition at line 5 of file normdist.h.

const double b[]
static
Initial value:
=
{
-5.447609879822406e+01,
1.615858368580409e+02,
-1.556989798598866e+02,
6.680131188771972e+01,
-1.328068155288572e+01
}

Definition at line 15 of file normdist.h.

const double c[]
static
Initial value:
=
{
-7.784894002430293e-03,
-3.223964580411365e-01,
-2.400758277161838e+00,
-2.549732539343734e+00,
4.374664141464968e+00,
2.938163982698783e+00
}

Definition at line 24 of file normdist.h.

const double d[]
static
Initial value:
=
{
7.784695709041462e-03,
3.224671290700398e-01,
2.445134137142996e+00,
3.754408661907416e+00
}

Definition at line 34 of file normdist.h.