|
|
@ -79,66 +79,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete |
|
|
Assert.AreEqual("DiscreteUniform(Lower = 0, Upper = 10)", b.ToString()); |
|
|
Assert.AreEqual("DiscreteUniform(Lower = 0, Upper = 10)", b.ToString()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Can set lower bound.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="p">Lower bound.</param>
|
|
|
|
|
|
[TestCase(0)] |
|
|
|
|
|
[TestCase(3)] |
|
|
|
|
|
[TestCase(10)] |
|
|
|
|
|
public void CanSetLowerBound(int p) |
|
|
|
|
|
{ |
|
|
|
|
|
GC.KeepAlive(new DiscreteUniform(0, 10) |
|
|
|
|
|
{ |
|
|
|
|
|
LowerBound = p |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Can set upper bound.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="p">Upper bound.</param>
|
|
|
|
|
|
[TestCase(0)] |
|
|
|
|
|
[TestCase(3)] |
|
|
|
|
|
[TestCase(10)] |
|
|
|
|
|
public void CanSetUpperBound(int p) |
|
|
|
|
|
{ |
|
|
|
|
|
GC.KeepAlive(new DiscreteUniform(0, 10) |
|
|
|
|
|
{ |
|
|
|
|
|
UpperBound = p |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Set lower bound with bad values fails.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="p">Lower bound.</param>
|
|
|
|
|
|
[TestCase(11)] |
|
|
|
|
|
[TestCase(20)] |
|
|
|
|
|
public void SetLowerBoundFails(int p) |
|
|
|
|
|
{ |
|
|
|
|
|
var b = new DiscreteUniform(0, 10); |
|
|
|
|
|
Assert.That(() => b.LowerBound = p, Throws.ArgumentException); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Set upper bound with bad values fails
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="p">Upper bound.</param>
|
|
|
|
|
|
[TestCase(-11)] |
|
|
|
|
|
[TestCase(-20)] |
|
|
|
|
|
public void SetUpperBoundFails(int p) |
|
|
|
|
|
{ |
|
|
|
|
|
var b = new DiscreteUniform(0, 10); |
|
|
|
|
|
Assert.That(() => b.UpperBound = p, Throws.ArgumentException); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Validate entropy.
|
|
|
/// Validate entropy.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="l">Lower bound.</param>
|
|
|
/// <param name="l">Lower bound.</param>
|
|
|
/// <param name="u">Upper bound.</param>
|
|
|
/// <param name="u">Upper bound.</param>
|
|
|
/// <param name="e">Expceted value.</param>
|
|
|
/// <param name="e">Expected value.</param>
|
|
|
[TestCase(-10, 10, 3.0445224377234229965005979803657054342845752874046093)] |
|
|
[TestCase(-10, 10, 3.0445224377234229965005979803657054342845752874046093)] |
|
|
[TestCase(0, 4, 1.6094379124341003746007593332261876395256013542685181)] |
|
|
[TestCase(0, 4, 1.6094379124341003746007593332261876395256013542685181)] |
|
|
[TestCase(10, 20, 2.3978952727983705440619435779651292998217068539374197)] |
|
|
[TestCase(10, 20, 2.3978952727983705440619435779651292998217068539374197)] |
|
|
@ -169,7 +115,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="l">Lower bound.</param>
|
|
|
/// <param name="l">Lower bound.</param>
|
|
|
/// <param name="u">Upper bound.</param>
|
|
|
/// <param name="u">Upper bound.</param>
|
|
|
/// <param name="m">Expceted value.</param>
|
|
|
/// <param name="m">Expected value.</param>
|
|
|
[TestCase(-10, 10, 0)] |
|
|
[TestCase(-10, 10, 0)] |
|
|
[TestCase(0, 4, 2)] |
|
|
[TestCase(0, 4, 2)] |
|
|
[TestCase(10, 20, 15)] |
|
|
[TestCase(10, 20, 15)] |
|
|
@ -185,7 +131,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="l">Lower bound.</param>
|
|
|
/// <param name="l">Lower bound.</param>
|
|
|
/// <param name="u">Upper bound.</param>
|
|
|
/// <param name="u">Upper bound.</param>
|
|
|
/// <param name="m">Expceted value.</param>
|
|
|
/// <param name="m">Expected value.</param>
|
|
|
[TestCase(-10, 10, 0)] |
|
|
[TestCase(-10, 10, 0)] |
|
|
[TestCase(0, 4, 2)] |
|
|
[TestCase(0, 4, 2)] |
|
|
[TestCase(10, 20, 15)] |
|
|
[TestCase(10, 20, 15)] |
|
|
@ -201,7 +147,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="l">Lower bound.</param>
|
|
|
/// <param name="l">Lower bound.</param>
|
|
|
/// <param name="u">Upper bound.</param>
|
|
|
/// <param name="u">Upper bound.</param>
|
|
|
/// <param name="m">Expceted value.</param>
|
|
|
/// <param name="m">Expected value.</param>
|
|
|
[TestCase(-10, 10, 0)] |
|
|
[TestCase(-10, 10, 0)] |
|
|
[TestCase(0, 4, 2)] |
|
|
[TestCase(0, 4, 2)] |
|
|
[TestCase(10, 20, 15)] |
|
|
[TestCase(10, 20, 15)] |
|
|
@ -238,7 +184,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete |
|
|
/// <param name="l">Lower bound.</param>
|
|
|
/// <param name="l">Lower bound.</param>
|
|
|
/// <param name="u">Upper bound.</param>
|
|
|
/// <param name="u">Upper bound.</param>
|
|
|
/// <param name="x">Input X value.</param>
|
|
|
/// <param name="x">Input X value.</param>
|
|
|
/// <param name="p">Expceted value.</param>
|
|
|
/// <param name="p">Expected value.</param>
|
|
|
[TestCase(-10, 10, -5, 1 / 21.0)] |
|
|
[TestCase(-10, 10, -5, 1 / 21.0)] |
|
|
[TestCase(-10, 10, 1, 1 / 21.0)] |
|
|
[TestCase(-10, 10, 1, 1 / 21.0)] |
|
|
[TestCase(-10, 10, 10, 1 / 21.0)] |
|
|
[TestCase(-10, 10, 10, 1 / 21.0)] |
|
|
@ -256,7 +202,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete |
|
|
/// <param name="l">Lower bound.</param>
|
|
|
/// <param name="l">Lower bound.</param>
|
|
|
/// <param name="u">Upper bound.</param>
|
|
|
/// <param name="u">Upper bound.</param>
|
|
|
/// <param name="x">Input X value.</param>
|
|
|
/// <param name="x">Input X value.</param>
|
|
|
/// <param name="dln">Expceted value.</param>
|
|
|
/// <param name="dln">Expected value.</param>
|
|
|
[TestCase(-10, 10, -5, -3.0445224377234229965005979803657054342845752874046093)] |
|
|
[TestCase(-10, 10, -5, -3.0445224377234229965005979803657054342845752874046093)] |
|
|
[TestCase(-10, 10, 1, -3.0445224377234229965005979803657054342845752874046093)] |
|
|
[TestCase(-10, 10, 1, -3.0445224377234229965005979803657054342845752874046093)] |
|
|
[TestCase(-10, 10, 10, -3.0445224377234229965005979803657054342845752874046093)] |
|
|
[TestCase(-10, 10, 10, -3.0445224377234229965005979803657054342845752874046093)] |
|
|
@ -332,7 +278,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete |
|
|
/// <param name="l">Lower bound.</param>
|
|
|
/// <param name="l">Lower bound.</param>
|
|
|
/// <param name="u">Upper bound.</param>
|
|
|
/// <param name="u">Upper bound.</param>
|
|
|
/// <param name="x">Input X value.</param>
|
|
|
/// <param name="x">Input X value.</param>
|
|
|
/// <param name="cdf">Expceted value.</param>
|
|
|
/// <param name="cdf">Expected value.</param>
|
|
|
[TestCase(-10, 10, -5, 6.0 / 21.0)] |
|
|
[TestCase(-10, 10, -5, 6.0 / 21.0)] |
|
|
[TestCase(-10, 10, 1, 12.0 / 21.0)] |
|
|
[TestCase(-10, 10, 1, 12.0 / 21.0)] |
|
|
[TestCase(-10, 10, 10, 1.0)] |
|
|
[TestCase(-10, 10, 10, 1.0)] |
|
|
|