public double[] EstimateInterval(Estimate e) { double z = NormalConfidenceEstimator.Quantile((1.0 - this._confidence) / 2.0); double len = Math.Abs(z * Math.Sqrt(e.Variance)); return(new double[] { e.Expectation - len, e.Expectation + len }); }
protected static double Quantile(double p) { // From http://www.johndcook.com/csharp_phi_inverse.html if (p <= 0.0 || p >= 1.0) { string msg = String.Format("Invalid input argument: {0}.", p); throw new ArgumentOutOfRangeException(msg); } // See article above for explanation of this section. if (p < 0.5) { // F^-1(p) = - G^-1(p) return(-NormalConfidenceEstimator.RationalApproximation(Math.Sqrt(-2.0 * Math.Log(p)))); } else { // F^-1(p) = G^-1(1-p) return(NormalConfidenceEstimator.RationalApproximation(Math.Sqrt(-2.0 * Math.Log(1.0 - p)))); } }
public double EstimateAbsoluteConfidence(Estimate e) { return(1.0 - 2 * NormalConfidenceEstimator.CDF(-this._sizeAbs / Math.Sqrt(e.Variance))); }
public double EstimateRelativeConfidence(Estimate e) { return(NormalConfidenceEstimator.CDF((e.Expectation - this._sizeRel) / Math.Sqrt(e.Variance))); }