public void Interpolate_CDF_Test() { Exceedance exceed = new Exceedance(); Add_Exceedance addExceed = new Add_Exceedance(); Exceedance.ExceedanceCurve exceedCurve = new Exceedance.ExceedanceCurve(); exceedCurve.distSize = 1000; exceedCurve.xVals = new double[exceedCurve.distSize]; exceedCurve.cumulDist = new double[exceedCurve.distSize]; string filename = testingFolder + "\\Interpolate_CDF\\Imported_CDF.csv"; double[,] importedCDF = addExceed.Read_CDF_file(filename); exceed.Interpolate_CDF(ref exceedCurve, importedCDF); Assert.AreEqual(exceedCurve.xVals[0], 0.853452, 0.001, "Wrong XVal Index 0"); Assert.AreEqual(exceedCurve.cumulDist[0], 0, 0.001, "Wrong CDF Index 0"); Assert.AreEqual(exceedCurve.xVals[224], 0.9246206, 0.001, "Wrong XVal Index 224"); Assert.AreEqual(exceedCurve.cumulDist[224], 0.067422, 0.001, "Wrong CDF Index 224"); Assert.AreEqual(exceedCurve.xVals[368], 0.9703719, 0.001, "Wrong XVal Index 368"); Assert.AreEqual(exceedCurve.cumulDist[368], 0.307178, 0.001, "Wrong CDF Index 368"); Assert.AreEqual(exceedCurve.xVals[479], 1.005639, 0.001, "Wrong XVal Index 479"); Assert.AreEqual(exceedCurve.cumulDist[479], 0.565243, 0.001, "Wrong CDF Index 479"); Assert.AreEqual(exceedCurve.xVals[602], 1.044718, 0.001, "Wrong XVal Index 602"); Assert.AreEqual(exceedCurve.cumulDist[602], 0.796571, 0.001, "Wrong CDF Index 602"); Assert.AreEqual(exceedCurve.xVals[788], 1.103813, 0.001, "Wrong XVal Index 788"); Assert.AreEqual(exceedCurve.cumulDist[788], 0.909619, 0.001, "Wrong CDF Index 788"); Assert.AreEqual(exceedCurve.xVals[899], 1.13908, 0.001, "Wrong XVal Index 899"); Assert.AreEqual(exceedCurve.cumulDist[899], 0.970939, 0.001, "Wrong CDF Index 899"); Assert.AreEqual(exceedCurve.xVals[903], 1.140351, 0.001, "Wrong XVal Index 903"); Assert.AreEqual(exceedCurve.cumulDist[903], 0.972101, 0.001, "Wrong CDF Index 903"); }
public void Calc_PDF_from_CDF_Test() { Exceedance exceed = new Exceedance(); Add_Exceedance addExceed = new Add_Exceedance(); Exceedance.ExceedanceCurve exceedCurve = new Exceedance.ExceedanceCurve(); exceedCurve.distSize = 1000; exceedCurve.xVals = new double[exceedCurve.distSize]; exceedCurve.cumulDist = new double[exceedCurve.distSize]; exceedCurve.probDist = new double[exceedCurve.distSize]; string filename = testingFolder + "\\Interpolate_CDF\\Imported_CDF.csv"; double[,] importedCDF = addExceed.Read_CDF_file(filename); exceed.Interpolate_CDF(ref exceedCurve, importedCDF); exceed.Calc_PDF_from_CDF(ref exceedCurve); Assert.AreEqual(exceedCurve.probDist[145], 1.8294, 0.0001, "Wrong PDF at Index 145"); Assert.AreEqual(exceedCurve.probDist[369], 7.3175, 0.0001, "Wrong PDF at Index 369"); Assert.AreEqual(exceedCurve.probDist[599], 3.6588, 0.0001, "Wrong PDF at Index 599"); Assert.AreEqual(exceedCurve.probDist[703], 0.9147, 0.0001, "Wrong PDF at Index 703"); Assert.AreEqual(exceedCurve.probDist[850], 1.8294, 0.0001, "Wrong PDF at Index 850"); }