/// <summary> /// This function return the value of probability density /// function(PDF) for normal standard distribution with Z=z /// and Z ~ N(0,1) /// </summary> /// <param name="z">double. z is standard value</param> /// <returns> /// The value of probability density function (PDF) for x /// where Z ~ N(0, 1) /// </returns> public static double PDF(double z) { NormalFunction function = new NormalFunction(); return function.Value(z); }
/// <summary> /// Return the cumulative distribution function (CDF) /// for normal standard distribution with mean 0, standard /// deviation 1 and Z has a value less than z /// </summary> /// <param name="z"> /// double. z is standard value where Z ~ N(0, 1) /// </param> /// <returns> /// The cumulative distribution function for normal /// standard distribution has a value less then z /// </returns> public static double CDF(double z) { // The CDF value for z < -10 --> 0 if (z < -10.0) return double.Epsilon; // The CDF value for z > 10 --> 1 if (z > 10.0) return (1.0 - double.Epsilon); NormalFunction function = new NormalFunction(0.0, 1.0); // accuracy of the integration method is 1.0e-6 if (z < 0) return 0.5 - Integrator.GaussLegendre(function, z, 0, 1.0e-6); else return 0.5 + Integrator.GaussLegendre(function, 0, z, 1.0e-6); }
/// <summary> /// This function return the value of probability density /// function(PDF) for normal distribution with X=x, mean mu, /// and standard deviation sig. /// </summary> /// <param name="x">double. x is observing data</param> /// <param name="mu">double. mu is mean of data</param> /// <param name="sig">double. sig is standard deviation data</param> /// <returns> /// The value of probability density function (PDF) for x /// where X ~ N(mu, sig) /// </returns> public static double PDF(double x, double mu, double sig) { NormalFunction function = new NormalFunction(mu, sig); return function.Value(x); }