/// <summary> /// Converts a given test statistic to a p-value. /// </summary> /// /// <param name="x">The value of the test statistic.</param> /// /// <returns>The p-value for the given statistic.</returns> /// public override double StatisticToPValue(double x) { if (Double.IsNaN(this.Statistic)) { Trace.TraceWarning("The test statistic is NaN, probably because its standard error is zero. This test is not applicable in this case as the samples do " + "not come from a normal distribution. One way to overcome this problem may be to increase the number of samples in your experiment."); return(Double.NaN); } double p; switch (Tail) { case DistributionTail.TwoTail: p = 2.0 * StatisticDistribution.DistributionFunction(Math.Abs(x)); break; case DistributionTail.OneUpper: p = StatisticDistribution.ComplementaryDistributionFunction(x); break; case DistributionTail.OneLower: p = StatisticDistribution.DistributionFunction(x); break; default: throw new InvalidOperationException(); } return(p); }
/// <summary> /// Converts a given test statistic to a p-value. /// </summary> /// /// <param name="x">The value of the test statistic.</param> /// /// <returns>The p-value for the given statistic.</returns> /// public override double StatisticToPValue(double x) { if (StatisticDistribution == null) { return(Double.NaN); // return NaN to match R's behavior } double p; switch (Tail) { case DistributionTail.TwoTail: double a = StatisticDistribution.DistributionFunction(x); double b = StatisticDistribution.ComplementaryDistributionFunction(x); double c = Math.Min(a, b); p = Math.Min(2 * c, 1); break; case DistributionTail.OneLower: p = StatisticDistribution.DistributionFunction(x); break; case DistributionTail.OneUpper: p = StatisticDistribution.ComplementaryDistributionFunction(x); break; default: throw new InvalidOperationException(); } return(p); }
/// <summary> /// Converts a given test statistic to a p-value. /// </summary> /// /// <param name="x">The value of the test statistic.</param> /// /// <returns>The p-value for the given statistic.</returns> /// public override double StatisticToPValue(double x) { // TODO: Maybe unify with WilcoxonTest? double p; switch (Tail) { case DistributionTail.TwoTail: double a = StatisticDistribution.DistributionFunction(x); double b = StatisticDistribution.ComplementaryDistributionFunction(x); double c = Math.Min(a, b); p = Math.Min(2 * c, 1); break; case DistributionTail.OneLower: p = StatisticDistribution.DistributionFunction(x); break; case DistributionTail.OneUpper: p = StatisticDistribution.ComplementaryDistributionFunction(x); break; default: throw new InvalidOperationException(); } return(p); }
/// <summary> /// Converts a given test statistic to a p-value. /// </summary> /// /// <param name="x">The value of the test statistic.</param> /// /// <returns>The p-value for the given statistic.</returns> /// public override double StatisticToPValue(double x) { double p; switch (Tail) { case DistributionTail.TwoTail: double a = StatisticDistribution.DistributionFunction(x); double b = StatisticDistribution.ComplementaryDistributionFunction(x); p = 2 * Math.Min(a, b); break; case DistributionTail.OneUpper: p = StatisticDistribution.DistributionFunction(x); break; case DistributionTail.OneLower: p = StatisticDistribution.ComplementaryDistributionFunction(x); break; default: throw new InvalidOperationException(); } return(p); }
/// <summary> /// Converts a given test statistic to a p-value. /// </summary> /// /// <param name="x">The value of the test statistic.</param> /// /// <returns>The p-value for the given statistic.</returns> /// public override double StatisticToPValue(double x) { double p; switch (Tail) { case DistributionTail.TwoTail: p = wilsonSterne(x); break; case DistributionTail.OneUpper: p = StatisticDistribution.ComplementaryDistributionFunction((int)x, inclusive: true); break; case DistributionTail.OneLower: p = StatisticDistribution.DistributionFunction((int)x); break; default: throw new InvalidOperationException(); } return p; }
/// <summary> /// Converts a given test statistic to a p-value. /// </summary> /// /// <param name="x">The value of the test statistic.</param> /// /// <returns>The p-value for the given statistic.</returns> /// public override double StatisticToPValue(double x) { return(StatisticDistribution.DistributionFunction(x)); }