From a08c76b7ac9d506fb8e8e6c05d6713dab14bf5ae Mon Sep 17 00:00:00 2001 From: Evangelink Date: Tue, 30 Jun 2020 18:37:11 +0200 Subject: [PATCH] Fix GeometricTests.ValidateProbabilityLn to use expected value parameter --- .../Discrete/GeometricTests.cs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/Numerics.Tests/DistributionTests/Discrete/GeometricTests.cs b/src/Numerics.Tests/DistributionTests/Discrete/GeometricTests.cs index 3acfac0c..dd07d7fd 100644 --- a/src/Numerics.Tests/DistributionTests/Discrete/GeometricTests.cs +++ b/src/Numerics.Tests/DistributionTests/Discrete/GeometricTests.cs @@ -175,28 +175,21 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete /// Input X value. /// Expected value. [TestCase(0.0, -1, Double.NegativeInfinity)] - [TestCase(0.0, 0, 0.0)] + [TestCase(0.0, 0, Double.NegativeInfinity)] [TestCase(0.0, 1, Double.NegativeInfinity)] [TestCase(0.0, 2, Double.NegativeInfinity)] [TestCase(0.3, -1, Double.NegativeInfinity)] - [TestCase(0.3, 0, -0.35667494393873244235395440410727451457180907089949815)] + [TestCase(0.3, 0, Double.NegativeInfinity)] [TestCase(0.3, 1, -1.2039728043259360296301803719337238685164245381839102)] - [TestCase(0.3, 2, Double.NegativeInfinity)] + [TestCase(0.3, 2, -1.5606477482646686)] [TestCase(1.0, -1, Double.NegativeInfinity)] [TestCase(1.0, 0, Double.NegativeInfinity)] - [TestCase(1.0, 1, 0.0)] + [TestCase(1.0, 1, Double.NaN)] [TestCase(1.0, 2, Double.NegativeInfinity)] public void ValidateProbabilityLn(double p, int x, double pln) { var d = new Geometric(p); - if (x > 0) - { - Assert.AreEqual(((x - 1) * Math.Log(1.0 - p)) + Math.Log(p), d.ProbabilityLn(x)); - } - else - { - Assert.AreEqual(Double.NegativeInfinity, d.ProbabilityLn(x)); - } + Assert.AreEqual(pln, d.ProbabilityLn(x)); } ///