Browse Source

Merge pull request #713 from Evangelink/use-test-parameters-geometric

Fix GeometricTests.ValidateProbabilityLn to use expected value parameter
v4
Christoph Ruegg 6 years ago
committed by GitHub
parent
commit
b2ffaa089b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      src/Numerics.Tests/DistributionTests/Discrete/GeometricTests.cs

17
src/Numerics.Tests/DistributionTests/Discrete/GeometricTests.cs

@ -176,28 +176,21 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
/// <param name="x">Input X value.</param>
/// <param name="pln">Expected value.</param>
[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));
}
/// <summary>

Loading…
Cancel
Save