public void Normalize_Dists_Test() { Exceedance exceedance = new Exceedance(); Exceedance.ExceedanceCurve exceedanceCurve = new Exceedance.ExceedanceCurve(); exceedanceCurve.lowerBound = 90; exceedanceCurve.upperBound = 100; exceedanceCurve.distSize = 100; exceedanceCurve.modes = new Exceedance.Mode_Def[1]; exceedanceCurve.modes[0].mean = 97; exceedanceCurve.modes[0].SD = 2.1f; exceedanceCurve.modes[0].weight = 1.0f; exceedanceCurve.probDist = new double[100]; exceedanceCurve.cumulDist = new double[100]; exceedanceCurve.xVals = new double[100]; exceedance.CalculateProbDist(ref exceedanceCurve); exceedance.Normalize_Dists(ref exceedanceCurve); Assert.AreEqual(exceedanceCurve.probDist[0], 0.000793, 0.00001, "Wrong normalized PDF index 0"); Assert.AreEqual(exceedanceCurve.probDist[28], 0.028506, 0.00001, "Wrong normalized PDF index 28"); Assert.AreEqual(exceedanceCurve.probDist[49], 0.127301, 0.00001, "Wrong normalized PDF index 49"); Assert.AreEqual(exceedanceCurve.probDist[61], 0.189345, 0.00001, "Wrong normalized PDF index 61"); Assert.AreEqual(exceedanceCurve.probDist[79], 0.183905, 0.00001, "Wrong normalized PDF index 79"); Assert.AreEqual(exceedanceCurve.probDist[88], 0.13683, 0.00001, "Wrong normalized PDF index 88"); Assert.AreEqual(exceedanceCurve.probDist[99], 0.07391, 0.00001, "Wrong normalized PDF index 99"); Assert.AreEqual(exceedanceCurve.cumulDist[0], 0.000080, 0.00001, "Wrong normalized CDF index 0"); Assert.AreEqual(exceedanceCurve.cumulDist[28], 0.0263899, 0.00001, "Wrong normalized CDF index 28"); Assert.AreEqual(exceedanceCurve.cumulDist[49], 0.18353226, 0.00001, "Wrong normalized CDF index 49"); Assert.AreEqual(exceedanceCurve.cumulDist[61], 0.38140445, 0.00001, "Wrong normalized CDF index 61"); Assert.AreEqual(exceedanceCurve.cumulDist[79], 0.74236859, 0.00001, "Wrong normalized CDF index 79"); Assert.AreEqual(exceedanceCurve.cumulDist[88], 0.88698974, 0.00001, "Wrong normalized CDF index 88"); Assert.AreEqual(exceedanceCurve.cumulDist[99], 1, 0.00001, "Wrong normalized CDF index 99"); }
public void CalculateProbDist_Test() { Exceedance exceedance = new Exceedance(); Exceedance.ExceedanceCurve exceedanceCurve = new Exceedance.ExceedanceCurve(); exceedanceCurve.lowerBound = 80; exceedanceCurve.upperBound = 120; exceedanceCurve.distSize = 100; exceedanceCurve.modes = new Exceedance.Mode_Def[1]; exceedanceCurve.modes[0].mean = 103; exceedanceCurve.modes[0].SD = 5.3f; exceedanceCurve.modes[0].weight = 1.0f; exceedanceCurve.probDist = new double[100]; exceedanceCurve.xVals = new double[100]; exceedance.CalculateProbDist(ref exceedanceCurve); Assert.AreEqual(exceedanceCurve.probDist[0], 0, 0.0001, "Wrong PDF at index 0"); Assert.AreEqual(exceedanceCurve.probDist[12], 0.0002136, 0.00001, "Wrong PDF at index 12"); Assert.AreEqual(exceedanceCurve.probDist[49], 0.062715488, 0.00001, "Wrong PDF at index 49"); Assert.AreEqual(exceedanceCurve.probDist[73], 0.035524804, 0.00001, "Wrong PDF at index 73"); Assert.AreEqual(exceedanceCurve.probDist[99], 0.0004390, 0.00001, "Wrong PDF at index 99"); }