public void TestDistributionEmpirical() { double[] binBounds = new double[] { 4.0, 7.0, 8.0, 10.0, 13.0, 14.0 }; double[] heights = new double[] { 2.0, 4.0, 3.0, 6.0, 4.0 }; // Note - one less than in intervals. IDoubleDistribution dist = new EmpiricalDistribution(m_model, "EmpiricalDistributionFromHistogram", Guid.NewGuid(), binBounds, heights); Assert.IsTrue(dist.GetValueWithCumulativeProbability(0.50) == 10.5); dist.SetCDFInterval(0.5, 0.5); Assert.IsTrue(dist.GetNext() == 10.5); dist.SetCDFInterval(0.0, 1.0); System.IO.StreamWriter tw = new System.IO.StreamWriter(Environment.GetEnvironmentVariable("TEMP") + "\\DistributionEmpiricalFromHistogram.csv"); Debug.WriteLine("Generating raw data."); int DATASETSIZE = 1500000; double[] rawData = new double[DATASETSIZE]; for (int x = 0; x < DATASETSIZE; x++) { rawData[x] = dist.GetNext(); //tw.WriteLine(rawData[x]); } Debug.WriteLine("Performing histogram analysis."); Histogram1D_Double hist = new Histogram1D_Double(rawData, 4, 14, 100, "distribution"); hist.LabelProvider = new LabelProvider(((Histogram1D_Double)hist).DefaultLabelProvider); hist.Recalculate(); Debug.WriteLine("Writing data dump file."); int[] bins = (int[])hist.Bins; for (int i = 0; i < bins.Length; i++) { //Debug.WriteLine(hist.GetLabel(new int[]{i}) + ", " + bins[i]); tw.WriteLine(hist.GetLabel(new int[] { i }) + ", " + bins[i]); } tw.Flush(); tw.Close(); if (m_visuallyVerify) { System.Diagnostics.Process.Start("excel.exe", Environment.GetEnvironmentVariable("TEMP") + "\\DistributionEmpiricalFromHistogram.csv"); } }