public string GetValue(double index) { if (Cdf == null) { ComputeProbabilities(); } return(Cdf.FirstOrDefault(x => x.Item2 >= index).Item1); }
public void GenerteFromHistogram() { var graph = Cdf.GenerateFromHistogram(SimpleDistribution); foreach (var tuple in SimpleDistributionTestValues) { int actual = graph.F(tuple.Item1); Assert.AreEqual(tuple.Item2, actual, $"F({(double)tuple.Item1})={actual} ... != {tuple.Item2}"); } }
public void When_ConstPdf_Expect_Reference() { // arrange var curve = new Curve(); curve.Add(new Point(-1, 0.5)); curve.Add(new Point(1, 0.5)); var pdf = new Pdf(curve); // act var cdf = new Cdf(pdf, 100); // assert Assert.Equal(100, cdf.PointsCount); }
public void NoOneValueFailsTest() { Assert.Throws <ArgumentOutOfRangeException>(() => Cdf.GenerateFromHistogram(NoOneValue)); }
public void EmptyInputFailsTest() { Assert.Throws <ArgumentException>(() => Cdf.GenerateFromHistogram(EmptyTupleArray)); }