using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Science.Statistics.BasicStatistics { public class TwoSampleZTest { private double opdiff, sep; public TwoSampleZTest(StandardErrorAndExpectedValue input1, StandardErrorAndExpectedValue input2) { opdiff = input1.ExpectedValueForPercentage - input2.ExpectedValueForPercentage; sep = Math.Sqrt(input1.StandardErrorForPercentage * input1.StandardErrorForPercentage + input2.StandardErrorForPercentage * input2.StandardErrorForPercentage); zv = opdiff / sep; FindpValue(); } private void FindpValue() { NormalCurve nc = new NormalCurve(); pv = (100.0 - nc.AreaBetween(-Math.Abs(zv), Math.Abs(zv))) / 2.0; if (pv < 0.01) c = "Reject null."; else if (pv >= 0.01 && pv < 1.0) c = " Reject null at 1% level."; else if (pv >= 1.0 && pv < 5.0) c = " Reject null at 5% level."; else c = "Accept null."; } private double zv; public double zValue { get { return zv; } set { zv = value; } } private double pv; public double PValue { get { return pv; } set { pv = value; } } private string c; public string Conclusion { get { return c; } } } }