7#include "GaussianDistribution.h" 
   50    if(value == DBL_MIN) {
 
   53    else if(value == DBL_MAX) {
 
   66    for(
int n = 0; pre != sum; n++) {
 
   69      sum += std::pow(x, 2 * n + 1) / (fact * (2 * n + 1) * std::pow(-2.0, n));
 
   74    return 50.0 + 100.0 / std::sqrt(2.0 * 
PI) * sum;
 
 
   92    static double lowCutoff = 2.425;
 
   93    static double highCutoff = 97.575;
 
   95    if((percent < 0.0) || (percent > 100.0)) {
 
   96      string m = 
"Argument percent outside of the range 0 to 100 in";
 
   97      m += 
" [GaussianDistribution::InverseCumulativeDistribution]";
 
  109    else if(percent == 100.0) {
 
  113    if(percent < lowCutoff) {
 
  114      double q = std::sqrt(-2.0 * std::log(percent / 100.0));
 
  117    else if(percent < highCutoff) {
 
  118      double q = percent / 100.0 - 0.5,
 
  123      double q = std::sqrt(-2.0 * std::log(1.0 - percent / 100.0));
 
  124      x = -1.0 * C(q) / D(q);
 
  130    double u = e * std::sqrt(2.0 * 
PI) * std::exp(-0.5 * x * x);
 
  131    x = x - u / (1 + 0.5 * x * u);
 
 
  140  double GaussianDistribution::A(
const double x) {
 
  141    static const double a[6] = { -39.69683028665376,
 
  149    return((((a[0] * x + a[1]) * x + a[2]) * x + a[3]) * x + a[4]) * x + a[5];
 
  152  double GaussianDistribution::B(
const double x) {
 
  153    static const double b[6] = { -54.47609879822406,
 
  161    return((((b[0] * x + b[1]) * x + b[2]) * x + b[3]) * x + b[4]) * x + b[5];
 
  164  double GaussianDistribution::C(
const double x) {
 
  165    static const double c[6] = { -0.007784894002430293,
 
  173    return((((c[0] * x + c[1]) * x + c[2]) * x + c[3]) * x + c[4]) * x + c[5];
 
  176  double GaussianDistribution::D(
const double x) {
 
  177    static const double d[5] = { 0.007784695709041462,
 
  184    return(((d[0] * x + d[1]) * x + d[2]) * x + d[3]) * x + d[4];
 
GaussianDistribution(const double mean=0.0, const double standardDeviation=1.0)
Constructs a gaussian distribution object.
 
double CumulativeDistribution(const double value)
Computes and returns the cumulative distribution up to the specified value on the gaussian distributi...
 
double Probability(const double value)
Computes and returns the probability of the specified value on the gaussian distribution.
 
double p_stdev
Value of the standard deviation.
 
double InverseCumulativeDistribution(const double percent)
Computes and returns the inverse cumulative distribution evaluated at the specified percentage value ...
 
double p_mean
Value of the mean.
 
@ Programmer
This error is for when a programmer made an API call that was illegal.
 
This is free and unencumbered software released into the public domain.
 
const double PI
The mathematical constant PI.
 
Namespace for the standard library.