diff --git a/src/Examples/ContinuousDistributions/ChiSquareDistribution.cs b/src/Examples/ContinuousDistributions/ChiSquareDistribution.cs
index b5dda2c6..1191e2a5 100644
--- a/src/Examples/ContinuousDistributions/ChiSquareDistribution.cs
+++ b/src/Examples/ContinuousDistributions/ChiSquareDistribution.cs
@@ -64,7 +64,7 @@ namespace Examples.ContinuousDistributionsExamples
public void Run()
{
// 1. Initialize the new instance of the ChiSquare distribution class with parameter dof = 1.
- var chiSquare = new ChiSquare(1);
+ var chiSquare = new ChiSquared(1);
Console.WriteLine(@"1. Initialize the new instance of the ChiSquare distribution class with parameter DegreesOfFreedom = {0}", chiSquare.DegreesOfFreedom);
Console.WriteLine();
diff --git a/src/Examples/ContinuousDistributions/FisherSnedecorDistribution.cs b/src/Examples/ContinuousDistributions/FisherSnedecorDistribution.cs
index d4dc99c2..b600f864 100644
--- a/src/Examples/ContinuousDistributions/FisherSnedecorDistribution.cs
+++ b/src/Examples/ContinuousDistributions/FisherSnedecorDistribution.cs
@@ -63,9 +63,9 @@ namespace Examples.ContinuousDistributionsExamples
/// FisherSnedecor distribution
public void Run()
{
- // 1. Initialize the new instance of the FisherSnedecor distribution class with parameter DegreeOfFreedom1 = 50, DegreeOfFreedom2 = 20.
+ // 1. Initialize the new instance of the FisherSnedecor distribution class with parameter DegreesOfFreedom1 = 50, DegreesOfFreedom2 = 20.
var fisherSnedecor = new FisherSnedecor(50, 20);
- Console.WriteLine(@"1. Initialize the new instance of the FisherSnedecor distribution class with parameters DegreeOfFreedom1 = {0}, DegreeOfFreedom2 = {1}", fisherSnedecor.DegreeOfFreedom1, fisherSnedecor.DegreeOfFreedom2);
+ Console.WriteLine(@"1. Initialize the new instance of the FisherSnedecor distribution class with parameters DegreesOfFreedom1 = {0}, DegreesOfFreedom2 = {1}", fisherSnedecor.DegreesOfFreedom1, fisherSnedecor.DegreesOfFreedom2);
Console.WriteLine();
// 2. Distributuion properties:
@@ -125,8 +125,8 @@ namespace Examples.ContinuousDistributionsExamples
// 5. Generate 100000 samples of the FisherSnedecor(20, 10) distribution and display histogram
Console.WriteLine(@"5. Generate 100000 samples of the FisherSnedecor(20, 10) distribution and display histogram");
- fisherSnedecor.DegreeOfFreedom1 = 20;
- fisherSnedecor.DegreeOfFreedom2 = 10;
+ fisherSnedecor.DegreesOfFreedom1 = 20;
+ fisherSnedecor.DegreesOfFreedom2 = 10;
for (var i = 0; i < data.Length; i++)
{
data[i] = fisherSnedecor.Sample();
@@ -137,8 +137,8 @@ namespace Examples.ContinuousDistributionsExamples
// 6. Generate 100000 samples of the FisherSnedecor(100, 100) distribution and display histogram
Console.WriteLine(@"6. Generate 100000 samples of the FisherSnedecor(100, 100) distribution and display histogram");
- fisherSnedecor.DegreeOfFreedom1 = 100;
- fisherSnedecor.DegreeOfFreedom2 = 100;
+ fisherSnedecor.DegreesOfFreedom1 = 100;
+ fisherSnedecor.DegreesOfFreedom2 = 100;
for (var i = 0; i < data.Length; i++)
{
data[i] = fisherSnedecor.Sample();
diff --git a/src/Examples/Signals/Random.cs b/src/Examples/Signals/Random.cs
index adda4d88..257f73da 100644
--- a/src/Examples/Signals/Random.cs
+++ b/src/Examples/Signals/Random.cs
@@ -96,7 +96,7 @@ namespace Examples.SignalsExamples
Console.WriteLine();
// 3. Get 10 random samples of f(x, y) = (x * y) / 2 using ChiSquare(10) distribution
- var chiSquare = new ChiSquare(10);
+ var chiSquare = new ChiSquared(10);
result = SignalGenerator.Random(TwoDomainFunction, chiSquare, 10);
Console.WriteLine(@" 3. Get 10 random samples of f(x, y) = (x * y) / 2 using ChiSquare(10) distribution");
for (var i = 0; i < result.Length; i++)
diff --git a/src/Examples/Statistics.cs b/src/Examples/Statistics.cs
index 77fdcd15..cd5597d4 100644
--- a/src/Examples/Statistics.cs
+++ b/src/Examples/Statistics.cs
@@ -65,7 +65,7 @@ namespace Examples
public void Run()
{
// 1. Initialize the new instance of the ChiSquare distribution class with parameter dof = 5.
- var chiSquare = new ChiSquare(5);
+ var chiSquare = new ChiSquared(5);
Console.WriteLine(@"1. Initialize the new instance of the ChiSquare distribution class with parameter DegreesOfFreedom = {0}", chiSquare.DegreesOfFreedom);
Console.WriteLine(@"{0} distributuion properties:", chiSquare);
Console.WriteLine(@"{0} - Largest element", chiSquare.Maximum.ToString(" #0.00000;-#0.00000"));
@@ -111,7 +111,7 @@ namespace Examples
Console.WriteLine();
// Generate 1000 samples of the ChiSquare(2.5) distribution
- var chiSquareB = new ChiSquare(2);
+ var chiSquareB = new ChiSquared(2);
var dataB = new double[1000];
for (var i = 0; i < data.Length; i++)
{
diff --git a/src/Numerics/Distributions/Bernoulli.cs b/src/Numerics/Distributions/Bernoulli.cs
index 77a8a4ce..952a649d 100644
--- a/src/Numerics/Distributions/Bernoulli.cs
+++ b/src/Numerics/Distributions/Bernoulli.cs
@@ -199,7 +199,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the probability mass (PMF), i.e. P(X = x).
+ /// Computes the probability mass (PMF) at k, i.e. P(X = k).
///
/// The location in the domain where we want to evaluate the probability mass function.
/// the probability mass at location .
@@ -219,7 +219,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log probability mass (lnPMF), i.e. ln(P(X = x)).
+ /// Computes the log probability mass (lnPMF) at k, i.e. ln(P(X = k)).
///
/// The location in the domain where we want to evaluate the log probability mass function.
/// the log probability mass at location .
@@ -234,7 +234,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
@@ -259,7 +259,7 @@ namespace MathNet.Numerics.Distributions
/// The random source to use.
/// The probability of generating a one.
/// A random sample from the Bernoulli distribution.
- internal static int SampleUnchecked(System.Random rnd, double p)
+ static int SampleUnchecked(System.Random rnd, double p)
{
if (rnd.NextDouble() < p)
{
@@ -275,7 +275,7 @@ namespace MathNet.Numerics.Distributions
/// A sample from the Bernoulli distribution.
public int Sample()
{
- return SampleUnchecked(RandomSource, _p);
+ return SampleUnchecked(_random, _p);
}
///
@@ -286,7 +286,7 @@ namespace MathNet.Numerics.Distributions
{
while (true)
{
- yield return SampleUnchecked(RandomSource, _p);
+ yield return SampleUnchecked(_random, _p);
}
}
diff --git a/src/Numerics/Distributions/Beta.cs b/src/Numerics/Distributions/Beta.cs
index 0945af2f..87e06dd8 100644
--- a/src/Numerics/Distributions/Beta.cs
+++ b/src/Numerics/Distributions/Beta.cs
@@ -346,7 +346,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the density of the distribution (PDF), i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
///
/// The location at which to compute the density.
/// the density at .
@@ -402,7 +402,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log density of the distribution (lnPDF), i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
///
/// The location at which to compute the log density.
/// the log density at .
@@ -461,7 +461,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
@@ -527,7 +527,7 @@ namespace MathNet.Numerics.Distributions
/// The α shape parameter of the Beta distribution.
/// The β shape parameter of the Beta distribution.
/// a random number from the Beta distribution.
- internal static double SampleUnchecked(System.Random rnd, double a, double b)
+ static double SampleUnchecked(System.Random rnd, double a, double b)
{
var x = Gamma.SampleUnchecked(rnd, a, 1.0);
var y = Gamma.SampleUnchecked(rnd, b, 1.0);
@@ -540,7 +540,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public double Sample()
{
- return SampleUnchecked(RandomSource, _shapeA, _shapeB);
+ return SampleUnchecked(_random, _shapeA, _shapeB);
}
///
@@ -551,7 +551,7 @@ namespace MathNet.Numerics.Distributions
{
while (true)
{
- yield return SampleUnchecked(RandomSource, _shapeA, _shapeB);
+ yield return SampleUnchecked(_random, _shapeA, _shapeB);
}
}
diff --git a/src/Numerics/Distributions/Binomial.cs b/src/Numerics/Distributions/Binomial.cs
index 9eec7bef..a69f5cbc 100644
--- a/src/Numerics/Distributions/Binomial.cs
+++ b/src/Numerics/Distributions/Binomial.cs
@@ -245,7 +245,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the probability mass (PMF), i.e. P(X = x).
+ /// Computes the probability mass (PMF) at k, i.e. P(X = k).
///
/// The location in the domain where we want to evaluate the probability mass function.
/// the probability mass at location .
@@ -285,7 +285,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log probability mass (lnPMF), i.e. ln(P(X = x)).
+ /// Computes the log probability mass (lnPMF) at k, i.e. ln(P(X = k)).
///
/// The location in the domain where we want to evaluate the log probability mass function.
/// the log probability mass at location .
@@ -325,7 +325,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
@@ -357,7 +357,7 @@ namespace MathNet.Numerics.Distributions
/// The success probability of a trial; must be in the interval [0.0, 1.0].
/// The number of trials; must be positive.
/// The number of successful trials.
- internal static int SampleUnchecked(System.Random rnd, double p, int n)
+ static int SampleUnchecked(System.Random rnd, double p, int n)
{
var k = 0;
for (var i = 0; i < n; i++)
@@ -374,7 +374,7 @@ namespace MathNet.Numerics.Distributions
/// The number of successes in N trials.
public int Sample()
{
- return SampleUnchecked(RandomSource, _p, _trials);
+ return SampleUnchecked(_random, _p, _trials);
}
///
@@ -385,7 +385,7 @@ namespace MathNet.Numerics.Distributions
{
while (true)
{
- yield return SampleUnchecked(RandomSource, _p, _trials);
+ yield return SampleUnchecked(_random, _p, _trials);
}
}
diff --git a/src/Numerics/Distributions/Categorical.cs b/src/Numerics/Distributions/Categorical.cs
index e5da163b..0e27f8d7 100644
--- a/src/Numerics/Distributions/Categorical.cs
+++ b/src/Numerics/Distributions/Categorical.cs
@@ -285,7 +285,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the probability mass (PMF), i.e. P(X = x).
+ /// Computes the probability mass (PMF) at k, i.e. P(X = k).
///
/// The location in the domain where we want to evaluate the probability mass function.
/// the probability mass at location .
@@ -305,7 +305,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log probability mass (lnPMF), i.e. ln(P(X = x)).
+ /// Computes the log probability mass (lnPMF) at k, i.e. ln(P(X = k)).
///
/// The location in the domain where we want to evaluate the log probability mass function.
/// the log probability mass at location .
@@ -325,7 +325,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
@@ -344,6 +344,58 @@ namespace MathNet.Numerics.Distributions
return _cdfUnnormalized[(int) Math.Floor(x)]/_cdfUnnormalized[_cdfUnnormalized.Length - 1];
}
+ ///
+ /// Computes the inverse of the cumulative distribution function (InvCDF) for the distribution
+ /// at the given probability.
+ ///
+ /// A real number between 0 and 1.
+ /// An integer between 0 and the size of the categorical (exclusive), that corresponds to the inverse CDF for the given probability.
+ public int InverseCumulativeDistribution(double probability)
+ {
+ if (probability < 0.0 || probability > 1.0 || Double.IsNaN(probability))
+ {
+ throw new ArgumentOutOfRangeException("probability");
+ }
+
+ var denormalizedProbability = probability * _cdfUnnormalized[_cdfUnnormalized.Length - 1];
+ int idx = Array.BinarySearch(_cdfUnnormalized, denormalizedProbability);
+ if (idx < 0)
+ {
+ idx = ~idx;
+ }
+
+ return idx;
+ }
+
+ ///
+ /// Computes the inverse of the cumulative distribution function (InvCDF) for the distribution
+ /// at the given probability.
+ ///
+ /// An array corresponding to a CDF for a categorical distribution. Not assumed to be normalized.
+ /// A real number between 0 and 1.
+ /// An integer between 0 and the size of the categorical (exclusive), that corresponds to the inverse CDF for the given probability.
+ public static int InverseCumulativeDistribution(double[] cdfUnnormalized, double probability)
+ {
+ if (Control.CheckDistributionParameters && !IsValidCumulativeDistribution(cdfUnnormalized))
+ {
+ throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ }
+
+ if (probability < 0.0 || probability > 1.0 || Double.IsNaN(probability))
+ {
+ throw new ArgumentOutOfRangeException("probability");
+ }
+
+ var denormalizedProbability = probability * cdfUnnormalized[cdfUnnormalized.Length - 1];
+ int idx = Array.BinarySearch(cdfUnnormalized, denormalizedProbability);
+ if (idx < 0)
+ {
+ idx = ~idx;
+ }
+
+ return idx;
+ }
+
///
/// Computes the cumulative distribution function. This method performs no parameter checking.
/// If the probability mass was normalized, the resulting cumulative distribution is normalized as well (up to numerical errors).
@@ -389,7 +441,7 @@ namespace MathNet.Numerics.Distributions
/// The number of successful trials.
public int Sample()
{
- return SampleUnchecked(RandomSource, _cdfUnnormalized);
+ return SampleUnchecked(_random, _cdfUnnormalized);
}
///
@@ -400,7 +452,7 @@ namespace MathNet.Numerics.Distributions
{
while (true)
{
- yield return SampleUnchecked(RandomSource, _cdfUnnormalized);
+ yield return SampleUnchecked(_random, _cdfUnnormalized);
}
}
@@ -475,35 +527,5 @@ namespace MathNet.Numerics.Distributions
yield return SampleUnchecked(rnd, cdf);
}
}
-
- ///
- /// Returns the inverse of the distribution function for the categorical distribution
- /// specified by the given normalized CDF, for the given probability.
- ///
- /// An array corresponding to a CDF for a categorical distribution. Not assumed to be normalized.
- /// A real number between 0 and 1.
- /// An integer between 0 and the size of the categorical (exclusive),
- /// that corresponds to the inverse CDF for the given probability.
- public static int InverseCumulativeDistribution(double[] cdfUnnormalized, double probability)
- {
- if (Control.CheckDistributionParameters && !IsValidCumulativeDistribution(cdfUnnormalized))
- {
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
- }
-
- if (probability < 0.0 || probability > 1.0 || Double.IsNaN(probability))
- {
- throw new ArgumentOutOfRangeException("probability");
- }
-
- var denormalizedProbability = probability*cdfUnnormalized[cdfUnnormalized.Length - 1];
- int idx = Array.BinarySearch(cdfUnnormalized, denormalizedProbability);
- if (idx < 0)
- {
- idx = ~idx;
- }
-
- return idx;
- }
}
}
diff --git a/src/Numerics/Distributions/Cauchy.cs b/src/Numerics/Distributions/Cauchy.cs
index 512a852c..4d5a095c 100644
--- a/src/Numerics/Distributions/Cauchy.cs
+++ b/src/Numerics/Distributions/Cauchy.cs
@@ -216,7 +216,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the density of the distribution (PDF), i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
///
/// The location at which to compute the density.
/// the density at .
@@ -226,7 +226,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log density of the distribution (lnPDF), i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
///
/// The location at which to compute the log density.
/// the log density at .
@@ -236,7 +236,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
@@ -252,7 +252,7 @@ namespace MathNet.Numerics.Distributions
/// The location (x0) of the distribution.
/// The scale (γ) of the distribution.
/// a random number from the distribution.
- internal static double SampleUnchecked(System.Random rnd, double location, double scale)
+ static double SampleUnchecked(System.Random rnd, double location, double scale)
{
var u = rnd.NextDouble();
return location + (scale*Math.Tan(Constants.Pi*(u - 0.5)));
@@ -264,7 +264,7 @@ namespace MathNet.Numerics.Distributions
/// A random number from this distribution.
public double Sample()
{
- return SampleUnchecked(RandomSource, _location, _scale);
+ return SampleUnchecked(_random, _location, _scale);
}
///
@@ -275,7 +275,7 @@ namespace MathNet.Numerics.Distributions
{
while (true)
{
- yield return SampleUnchecked(RandomSource, _location, _scale);
+ yield return SampleUnchecked(_random, _location, _scale);
}
}
diff --git a/src/Numerics/Distributions/Chi.cs b/src/Numerics/Distributions/Chi.cs
index 0dee8af3..8ffc6f4e 100644
--- a/src/Numerics/Distributions/Chi.cs
+++ b/src/Numerics/Distributions/Chi.cs
@@ -55,22 +55,22 @@ namespace MathNet.Numerics.Distributions
///
/// Initializes a new instance of the class.
///
- /// The degrees of freedom for the Chi distribution.
- public Chi(double dof)
+ /// The degrees of freedom (k) of the distribution.
+ public Chi(double freedom)
{
_random = new System.Random();
- SetParameters(dof);
+ SetParameters(freedom);
}
///
/// Initializes a new instance of the class.
///
- /// The degrees of freedom for the Chi distribution.
+ /// The degrees of freedom (k) of the distribution.
/// The random number generator which is used to draw random samples.
- public Chi(double dof, System.Random randomSource)
+ public Chi(double freedom, System.Random randomSource)
{
_random = randomSource ?? new System.Random();
- SetParameters(dof);
+ SetParameters(freedom);
}
///
@@ -79,36 +79,36 @@ namespace MathNet.Numerics.Distributions
/// a string representation of the distribution.
public override string ToString()
{
- return "Chi(DoF = " + _freedom + ")";
+ return "Chi(k = " + _freedom + ")";
}
///
/// Checks whether the parameters of the distribution are valid.
///
- /// The degrees of freedom for the Chi distribution.
+ /// The degrees of freedom for the Chi distribution.
/// true when the parameters are valid, false otherwise.
- static bool IsValidParameterSet(double dof)
+ static bool IsValidParameterSet(double freedom)
{
- return dof > 0.0;
+ return freedom > 0.0;
}
///
/// Sets the parameters of the distribution after checking their validity.
///
- /// The degrees of freedom for the Chi distribution.
+ /// The degrees of freedom for the Chi distribution.
/// When the parameters don't pass the function.
- void SetParameters(double dof)
+ void SetParameters(double freedom)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(dof))
+ if (Control.CheckDistributionParameters && !IsValidParameterSet(freedom))
{
throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
}
- _freedom = dof;
+ _freedom = freedom;
}
///
- /// Gets or sets the degrees of freedom of the Chi distribution.
+ /// Gets or sets the degrees of freedom (k) of the Chi distribution.
///
public double DegreesOfFreedom
{
@@ -210,7 +210,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the density of the distribution (PDF), i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
///
/// The location at which to compute the density.
/// the density at .
@@ -220,7 +220,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log density of the distribution (lnPDF), i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
///
/// The location at which to compute the log density.
/// the log density at .
@@ -230,7 +230,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
@@ -243,12 +243,12 @@ namespace MathNet.Numerics.Distributions
/// Samples the distribution.
///
/// The random number generator to use.
- /// Degrees of Freedom
+ /// The degrees of freedom (k) of the distribution.
/// a random number from the distribution.
- internal static double SampleUnchecked(System.Random rnd, int dof)
+ static double SampleUnchecked(System.Random rnd, int freedom)
{
double sum = 0;
- for (var i = 0; i < dof; i++)
+ for (var i = 0; i < freedom; i++)
{
sum += Math.Pow(Normal.Sample(rnd, 0.0, 1.0), 2);
}
@@ -262,7 +262,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public double Sample()
{
- return SampleUnchecked(RandomSource, (int) _freedom);
+ return SampleUnchecked(_random, (int) _freedom);
}
///
@@ -271,10 +271,10 @@ namespace MathNet.Numerics.Distributions
/// a sequence of samples from the distribution.
public IEnumerable Samples()
{
- var dof = (int) _freedom;
+ var freedom = (int)_freedom;
while (true)
{
- yield return SampleUnchecked(RandomSource, dof);
+ yield return SampleUnchecked(_random, freedom);
}
}
@@ -282,34 +282,34 @@ namespace MathNet.Numerics.Distributions
/// Generates a sample from the distribution.
///
/// The random number generator to use.
- /// Degrees of Freedom
+ /// The degrees of freedom (k) of the distribution.
/// a sample from the distribution.
- public static double Sample(System.Random rnd, int dof)
+ public static double Sample(System.Random rnd, int freedom)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(dof))
+ if (Control.CheckDistributionParameters && !IsValidParameterSet(freedom))
{
throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
}
- return SampleUnchecked(rnd, dof);
+ return SampleUnchecked(rnd, freedom);
}
///
/// Generates a sequence of samples from the distribution.
///
/// The random number generator to use.
- /// Degrees of Freedom
+ /// The degrees of freedom (k) of the distribution.
/// a sequence of samples from the distribution.
- public static IEnumerable Samples(System.Random rnd, int dof)
+ public static IEnumerable Samples(System.Random rnd, int freedom)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(dof))
+ if (Control.CheckDistributionParameters && !IsValidParameterSet(freedom))
{
throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
}
while (true)
{
- yield return SampleUnchecked(rnd, dof);
+ yield return SampleUnchecked(rnd, freedom);
}
}
}
diff --git a/src/Numerics/Distributions/ChiSquare.cs b/src/Numerics/Distributions/ChiSquared.cs
similarity index 81%
rename from src/Numerics/Distributions/ChiSquare.cs
rename to src/Numerics/Distributions/ChiSquared.cs
index 9b15e809..37e7c53b 100644
--- a/src/Numerics/Distributions/ChiSquare.cs
+++ b/src/Numerics/Distributions/ChiSquared.cs
@@ -35,7 +35,7 @@ using MathNet.Numerics.Properties;
namespace MathNet.Numerics.Distributions
{
///
- /// Continuous Univariate ChiSquare distribution.
+ /// Continuous Univariate Chi-Squared distribution.
/// This distribution is a sum of the squares of k independent standard normal random variables.
/// Wikipedia - ChiSquare distribution.
///
@@ -44,31 +44,31 @@ namespace MathNet.Numerics.Distributions
/// The statistics classes will check all the incoming parameters whether they are in the allowed
/// range. This might involve heavy computation. Optionally, by setting Control.CheckDistributionParameters
/// to false, all parameter checks can be turned off.
- public class ChiSquare : IContinuousDistribution
+ public class ChiSquared : IContinuousDistribution
{
System.Random _random;
double _freedom;
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
- /// The degrees of freedom for the ChiSquare distribution.
- public ChiSquare(double dof)
+ /// The degrees of freedom (k) of the distribution.
+ public ChiSquared(double freedom)
{
_random = new System.Random();
- SetParameters(dof);
+ SetParameters(freedom);
}
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
- /// The degrees of freedom for the ChiSquare distribution.
+ /// The degrees of freedom (k) of the distribution.
/// The random number generator which is used to draw random samples.
- public ChiSquare(double dof, System.Random randomSource)
+ public ChiSquared(double freedom, System.Random randomSource)
{
_random = randomSource ?? new System.Random();
- SetParameters(dof);
+ SetParameters(freedom);
}
///
@@ -77,36 +77,36 @@ namespace MathNet.Numerics.Distributions
/// a string representation of the distribution.
public override string ToString()
{
- return "ChiSquare(DoF = " + _freedom + ")";
+ return "ChiSquared(k = " + _freedom + ")";
}
///
/// Checks whether the parameters of the distribution are valid.
///
- /// The degrees of freedom for the ChiSquare distribution.
+ /// The degrees of freedom (k) of the distribution.
/// true when the parameters are valid, false otherwise.
- static bool IsValidParameterSet(double dof)
+ static bool IsValidParameterSet(double freedom)
{
- return dof > 0 && !Double.IsNaN(dof);
+ return freedom > 0 && !Double.IsNaN(freedom);
}
///
/// Sets the parameters of the distribution after checking their validity.
///
- /// The degrees of freedom for the ChiSquare distribution.
+ /// The degrees of freedom (k) of the distribution.
/// When the parameters don't pass the function.
- void SetParameters(double dof)
+ void SetParameters(double freedom)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(dof))
+ if (Control.CheckDistributionParameters && !IsValidParameterSet(freedom))
{
throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
}
- _freedom = dof;
+ _freedom = freedom;
}
///
- /// Gets or sets the degrees of freedom of the ChiSquare distribution.
+ /// Gets or sets the degrees of freedom (k) of the Chi-Squared distribution.
///
public double DegreesOfFreedom
{
@@ -196,7 +196,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the density of the distribution (PDF), i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
///
/// The location at which to compute the density.
/// the density at .
@@ -206,7 +206,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log density of the distribution (lnPDF), i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
///
/// The location at which to compute the log density.
/// the log density at .
@@ -216,7 +216,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
@@ -229,24 +229,25 @@ namespace MathNet.Numerics.Distributions
/// Samples the distribution.
///
/// The random number generator to use.
- /// The degrees of freedom.
+ /// The degrees of freedom (k) of the distribution.
/// a random number from the distribution.
- internal static double SampleUnchecked(System.Random rnd, double dof)
+ static double SampleUnchecked(System.Random rnd, double freedom)
{
- //Use the simple method if the dof is an integer anyway
- if (Math.Floor(dof) == dof && dof < Int32.MaxValue)
+ // Use the simple method if the degrees if freedom is an integer anyway
+ if (Math.Floor(freedom) == freedom && freedom < Int32.MaxValue)
{
double sum = 0;
- var n = (int) dof;
+ var n = (int) freedom;
for (var i = 0; i < n; i++)
{
sum += Math.Pow(Normal.Sample(rnd, 0.0, 1.0), 2);
}
return sum;
}
+
//Call the gamma function (see http://en.wikipedia.org/wiki/Gamma_distribution#Specializations
//for a justification)
- return Gamma.SampleUnchecked(rnd, dof/2.0, .5);
+ return Gamma.SampleUnchecked(rnd, freedom/2.0, .5);
}
///
@@ -255,7 +256,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public double Sample()
{
- return SampleUnchecked(RandomSource, _freedom);
+ return SampleUnchecked(_random, _freedom);
}
///
@@ -266,7 +267,7 @@ namespace MathNet.Numerics.Distributions
{
while (true)
{
- yield return SampleUnchecked(RandomSource, _freedom);
+ yield return SampleUnchecked(_random, _freedom);
}
}
@@ -274,34 +275,34 @@ namespace MathNet.Numerics.Distributions
/// Generates a sample from the ChiSquare distribution.
///
/// The random number generator to use.
- /// The degrees of freedom.
+ /// The degrees of freedom (k) of the distribution.
/// a sample from the distribution.
- public static double Sample(System.Random rnd, double dof)
+ public static double Sample(System.Random rnd, double freedom)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(dof))
+ if (Control.CheckDistributionParameters && !IsValidParameterSet(freedom))
{
throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
}
- return SampleUnchecked(rnd, dof);
+ return SampleUnchecked(rnd, freedom);
}
///
/// Generates a sequence of samples from the distribution.
///
/// The random number generator to use.
- /// The degrees of freedom.
+ /// The degrees of freedom (k) of the distribution.
/// a sample from the distribution.
- public static IEnumerable Samples(System.Random rnd, double dof)
+ public static IEnumerable Samples(System.Random rnd, double freedom)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(dof))
+ if (Control.CheckDistributionParameters && !IsValidParameterSet(freedom))
{
throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
}
while (true)
{
- yield return SampleUnchecked(rnd, dof);
+ yield return SampleUnchecked(rnd, freedom);
}
}
}
diff --git a/src/Numerics/Distributions/ContinuousUniform.cs b/src/Numerics/Distributions/ContinuousUniform.cs
index ef0bf0d2..88f08ee1 100644
--- a/src/Numerics/Distributions/ContinuousUniform.cs
+++ b/src/Numerics/Distributions/ContinuousUniform.cs
@@ -223,7 +223,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the density of the distribution (PDF), i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
///
/// The location at which to compute the density.
/// the density at .
@@ -238,7 +238,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log density of the distribution (lnPDF), i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
///
/// The location at which to compute the log density.
/// the log density at .
@@ -253,7 +253,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
@@ -279,7 +279,7 @@ namespace MathNet.Numerics.Distributions
/// The lower bound of the uniform random variable.
/// The upper bound of the uniform random variable.
/// a uniformly distributed random number.
- internal static double SampleUnchecked(System.Random rnd, double lower, double upper)
+ static double SampleUnchecked(System.Random rnd, double lower, double upper)
{
return lower + (rnd.NextDouble()*(upper - lower));
}
@@ -290,7 +290,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public double Sample()
{
- return SampleUnchecked(RandomSource, _lower, _upper);
+ return SampleUnchecked(_random, _lower, _upper);
}
///
@@ -301,7 +301,7 @@ namespace MathNet.Numerics.Distributions
{
while (true)
{
- yield return SampleUnchecked(RandomSource, _lower, _upper);
+ yield return SampleUnchecked(_random, _lower, _upper);
}
}
diff --git a/src/Numerics/Distributions/ConwayMaxwellPoisson.cs b/src/Numerics/Distributions/ConwayMaxwellPoisson.cs
index 20958af2..18175ce3 100644
--- a/src/Numerics/Distributions/ConwayMaxwellPoisson.cs
+++ b/src/Numerics/Distributions/ConwayMaxwellPoisson.cs
@@ -83,7 +83,7 @@ namespace MathNet.Numerics.Distributions
/// Initializes a new instance of the class.
///
/// The lambda (λ) parameter.
- /// The nu (ν) parameter.
+ /// The rate of decay (ν) parameter.
public ConwayMaxwellPoisson(double lambda, double nu)
{
_random = new System.Random();
@@ -94,7 +94,7 @@ namespace MathNet.Numerics.Distributions
/// Initializes a new instance of the class.
///
/// The lambda (λ) parameter.
- /// The nu (ν) parameter.
+ /// The rate of decay (ν) parameter.
/// The random number generator which is used to draw random samples.
public ConwayMaxwellPoisson(double lambda, double nu, System.Random randomSource)
{
@@ -115,7 +115,7 @@ namespace MathNet.Numerics.Distributions
/// Checks whether the parameters of the distribution are valid.
///
/// The lambda (λ) parameter.
- /// The nu (ν) parameter.
+ /// The rate of decay (ν) parameter.
/// true when the parameters are valid, false otherwise.
static bool IsValidParameterSet(double lambda, double nu)
{
@@ -126,7 +126,7 @@ namespace MathNet.Numerics.Distributions
/// Sets the parameters of the distribution after checking their validity.
///
/// The lambda (λ) parameter.
- /// The nu (ν) parameter.
+ /// The rate of decay (ν) parameter.
/// When the parameters don't pass the function.
void SetParameters(double lambda, double nu)
{
@@ -142,7 +142,6 @@ namespace MathNet.Numerics.Distributions
///
/// Gets or sets the lambda (λ) parameter.
///
- /// The value of the lambda parameter.
public double Lambda
{
get { return _lambda; }
@@ -150,9 +149,8 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Gets or sets the DegreeOfFreedom (ν) parameter.
+ /// Gets or sets the rate of decay (ν) parameter.
///
- /// The value of the DegreeOfFreedom parameter.
public double Nu
{
get { return _nu; }
@@ -348,7 +346,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the probability mass (PMF), i.e. P(X = x).
+ /// Computes the probability mass (PMF) at k, i.e. P(X = k).
///
/// The location in the domain where we want to evaluate the probability mass function.
/// the probability mass at location .
@@ -358,7 +356,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log probability mass (lnPMF), i.e. ln(P(X = x)).
+ /// Computes the log probability mass (lnPMF) at k, i.e. ln(P(X = k)).
///
/// The location in the domain where we want to evaluate the log probability mass function.
/// the log probability mass at location .
@@ -368,7 +366,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
@@ -403,8 +401,8 @@ namespace MathNet.Numerics.Distributions
///
/// Computes an approximate normalization constant for the CMP distribution.
///
- /// The lambda parameter for the CMP distribution.
- /// The nu parameter for the CMP distribution.
+ /// The lambda (λ) parameter for the CMP distribution.
+ /// The rate of decay (ν) parameter for the CMP distribution.
///
/// an approximate normalization constant for the CMP distribution.
///
@@ -446,12 +444,12 @@ namespace MathNet.Numerics.Distributions
///
/// The random number generator to use.
/// The lambda (λ) parameter.
- /// The nu (ν) parameter.
+ /// The rate of decay (ν) parameter.
/// The z parameter.
///
/// One sample from the distribution implied by , , and .
///
- internal static int SampleUnchecked(System.Random rnd, double lambda, double nu, double z)
+ static int SampleUnchecked(System.Random rnd, double lambda, double nu, double z)
{
var u = rnd.NextDouble();
var p = 1.0/z;
@@ -474,7 +472,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public int Sample()
{
- return SampleUnchecked(RandomSource, _lambda, _nu, Z);
+ return SampleUnchecked(_random, _lambda, _nu, Z);
}
///
@@ -487,7 +485,7 @@ namespace MathNet.Numerics.Distributions
{
while (true)
{
- yield return SampleUnchecked(RandomSource, _lambda, _nu, Z);
+ yield return SampleUnchecked(_random, _lambda, _nu, Z);
}
}
@@ -496,7 +494,7 @@ namespace MathNet.Numerics.Distributions
///
/// The random number generator to use.
/// The lambda (λ) parameter.
- /// The nu (ν) parameter.
+ /// The rate of decay (ν) parameter.
public static int Sample(System.Random rnd, double lambda, double nu)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(lambda, nu))
@@ -513,7 +511,7 @@ namespace MathNet.Numerics.Distributions
///
/// The random number generator to use.
/// The lambda (λ) parameter.
- /// The nu (ν) parameter.
+ /// The rate of decay (ν) parameter.
public static IEnumerable Samples(System.Random rnd, double lambda, double nu)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(lambda, nu))
diff --git a/src/Numerics/Distributions/Dirichlet.cs b/src/Numerics/Distributions/Dirichlet.cs
index 200b5ba3..bf7fe599 100644
--- a/src/Numerics/Distributions/Dirichlet.cs
+++ b/src/Numerics/Distributions/Dirichlet.cs
@@ -129,7 +129,7 @@ namespace MathNet.Numerics.Distributions
///
/// true when the parameters are valid, false
/// otherwise.
- public static bool IsValidParameterSet(double[] alpha)
+ static bool IsValidParameterSet(double[] alpha)
{
var allzero = true;
@@ -317,7 +317,7 @@ namespace MathNet.Numerics.Distributions
/// A sample from this distribution.
public double[] Sample()
{
- return Sample(RandomSource, _alpha);
+ return Sample(_random, _alpha);
}
///
diff --git a/src/Numerics/Distributions/DiscreteUniform.cs b/src/Numerics/Distributions/DiscreteUniform.cs
index 6a34eba9..e5e1a491 100644
--- a/src/Numerics/Distributions/DiscreteUniform.cs
+++ b/src/Numerics/Distributions/DiscreteUniform.cs
@@ -214,7 +214,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the probability mass (PMF), i.e. P(X = x).
+ /// Computes the probability mass (PMF) at k, i.e. P(X = k).
///
/// The location in the domain where we want to evaluate the probability mass function.
/// the probability mass at location .
@@ -229,7 +229,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log probability mass (lnPMF), i.e. ln(P(X = x)).
+ /// Computes the log probability mass (lnPMF) at k, i.e. ln(P(X = k)).
///
/// The location in the domain where we want to evaluate the log probability mass function.
/// the log probability mass at location .
@@ -244,7 +244,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
@@ -270,7 +270,7 @@ namespace MathNet.Numerics.Distributions
/// The lower bound of the uniform random variable.
/// The upper bound of the uniform random variable.
/// A random sample from the discrete uniform distribution.
- internal static int SampleUnchecked(System.Random rnd, int lower, int upper)
+ static int SampleUnchecked(System.Random rnd, int lower, int upper)
{
return (rnd.Next()%(upper - lower + 1)) + lower;
}
@@ -281,7 +281,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public int Sample()
{
- return SampleUnchecked(RandomSource, _lower, _upper);
+ return SampleUnchecked(_random, _lower, _upper);
}
///
@@ -292,7 +292,7 @@ namespace MathNet.Numerics.Distributions
{
while (true)
{
- yield return SampleUnchecked(RandomSource, _lower, _upper);
+ yield return SampleUnchecked(_random, _lower, _upper);
}
}
diff --git a/src/Numerics/Distributions/Erlang.cs b/src/Numerics/Distributions/Erlang.cs
index 8d4ace24..a13a9cb9 100644
--- a/src/Numerics/Distributions/Erlang.cs
+++ b/src/Numerics/Distributions/Erlang.cs
@@ -105,7 +105,7 @@ namespace MathNet.Numerics.Distributions
/// a string representation of the distribution.
public override string ToString()
{
- return "Erlang(Shape = " + _shape + ", λ = " + _rate + ")";
+ return "Erlang(k = " + _shape + ", λ = " + _rate + ")";
}
///
@@ -335,7 +335,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the density of the distribution (PDF), i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
///
/// The location at which to compute the density.
/// the density at .
@@ -360,7 +360,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log density of the distribution (lnPDF), i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
///
/// The location at which to compute the log density.
/// the log density at .
@@ -385,7 +385,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
@@ -414,7 +414,7 @@ namespace MathNet.Numerics.Distributions
/// The shape of the Gamma distribution.
/// The inverse scale of the Gamma distribution.
/// A sample from a Erlang distributed random variable.
- internal static double SampleUnchecked(System.Random rnd, double shape, double invScale)
+ static double SampleUnchecked(System.Random rnd, double shape, double invScale)
{
if (Double.IsPositiveInfinity(invScale))
{
@@ -464,7 +464,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public double Sample()
{
- return SampleUnchecked(RandomSource, _shape, _rate);
+ return SampleUnchecked(_random, _shape, _rate);
}
///
@@ -475,7 +475,7 @@ namespace MathNet.Numerics.Distributions
{
while (true)
{
- yield return SampleUnchecked(RandomSource, _shape, _rate);
+ yield return SampleUnchecked(_random, _shape, _rate);
}
}
diff --git a/src/Numerics/Distributions/Exponential.cs b/src/Numerics/Distributions/Exponential.cs
index 257de61c..a05f1d53 100644
--- a/src/Numerics/Distributions/Exponential.cs
+++ b/src/Numerics/Distributions/Exponential.cs
@@ -196,7 +196,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the density of the distribution (PDF), i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
///
/// The location at which to compute the density.
/// the density at .
@@ -211,7 +211,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log density of the distribution (lnPDF), i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
///
/// The location at which to compute the log density.
/// the log density at .
@@ -221,7 +221,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
@@ -241,7 +241,7 @@ namespace MathNet.Numerics.Distributions
/// The random number generator to use.
/// The rate (λ) parameter of the Exponential distribution.
/// a random number from the distribution.
- internal static double SampleUnchecked(System.Random rnd, double rate)
+ static double SampleUnchecked(System.Random rnd, double rate)
{
var r = rnd.NextDouble();
while (r == 0.0)
@@ -258,7 +258,7 @@ namespace MathNet.Numerics.Distributions
/// A random number from this distribution.
public double Sample()
{
- return SampleUnchecked(RandomSource, _rate);
+ return SampleUnchecked(_random, _rate);
}
///
@@ -269,7 +269,7 @@ namespace MathNet.Numerics.Distributions
{
while (true)
{
- yield return SampleUnchecked(RandomSource, _rate);
+ yield return SampleUnchecked(_random, _rate);
}
}
diff --git a/src/Numerics/Distributions/FisherSnedecor.cs b/src/Numerics/Distributions/FisherSnedecor.cs
index 5a0b9e36..7e9b3abd 100644
--- a/src/Numerics/Distributions/FisherSnedecor.cs
+++ b/src/Numerics/Distributions/FisherSnedecor.cs
@@ -54,8 +54,8 @@ namespace MathNet.Numerics.Distributions
///
/// Initializes a new instance of the class.
///
- /// The first parameter - degree of freedom.
- /// The second parameter - degree of freedom.
+ /// The first degree of freedom (d1) of the distribution.
+ /// The second degree of freedom (d2) of the distribution.
public FisherSnedecor(double d1, double d2)
{
_random = new System.Random();
@@ -65,8 +65,8 @@ namespace MathNet.Numerics.Distributions
///
/// Initializes a new instance of the class.
///
- /// The first parameter - degree of freedom.
- /// The second parameter - degree of freedom.
+ /// The first degree of freedom (d1) of the distribution.
+ /// The second degree of freedom (d2) of the distribution.
/// The random number generator which is used to draw random samples.
public FisherSnedecor(double d1, double d2, System.Random randomSource)
{
@@ -80,14 +80,14 @@ namespace MathNet.Numerics.Distributions
/// a string representation of the distribution.
public override string ToString()
{
- return "FisherSnedecor(DegreeOfFreedom1 = " + _freedom1 + ", DegreeOfFreedom2 = " + _freedom2 + ")";
+ return "FisherSnedecor(d1 = " + _freedom1 + ", d2 = " + _freedom2 + ")";
}
///
/// Checks whether the parameters of the distribution are valid.
///
- /// The first parameter - degree of freedom.
- /// The second parameter - degree of freedom.
+ /// The first degree of freedom (d1) of the distribution.
+ /// The second degree of freedom (d2) of the distribution.
/// true when the parameters are valid, false otherwise.
static bool IsValidParameterSet(double d1, double d2)
{
@@ -97,8 +97,8 @@ namespace MathNet.Numerics.Distributions
///
/// Sets the parameters of the distribution after checking their validity.
///
- /// The first parameter - degree of freedom.
- /// The second parameter - degree of freedom.
+ /// The first degree of freedom (d1) of the distribution.
+ /// The second degree of freedom (d2) of the distribution.
void SetParameters(double d1, double d2)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(d1, d2))
@@ -113,7 +113,7 @@ namespace MathNet.Numerics.Distributions
///
/// Gets or sets the first parameter - degree of freedom.
///
- public double DegreeOfFreedom1
+ public double DegreesOfFreedom1
{
get { return _freedom1; }
set { SetParameters(value, _freedom2); }
@@ -122,7 +122,7 @@ namespace MathNet.Numerics.Distributions
///
/// Gets or sets the second parameter - degree of freedom.
///
- public double DegreeOfFreedom2
+ public double DegreesOfFreedom2
{
get { return _freedom2; }
set { SetParameters(_freedom1, value); }
@@ -242,7 +242,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the density of the distribution (PDF), i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
///
/// The location at which to compute the density.
/// the density at .
@@ -252,7 +252,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log density of the distribution (lnPDF), i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
///
/// The location at which to compute the log density.
/// the log density at .
@@ -262,7 +262,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
@@ -275,12 +275,12 @@ namespace MathNet.Numerics.Distributions
/// Generates one sample from the FisherSnedecor distribution without parameter checking.
///
/// The random number generator to use.
- /// The first parameter - degree of freedom.
- /// The second parameter - degree of freedom.
+ /// The first degree of freedom (d1) of the distribution.
+ /// The second degree of freedom (d2) of the distribution.
/// a FisherSnedecor distributed random number.
- internal static double SampleUnchecked(System.Random rnd, double d1, double d2)
+ static double SampleUnchecked(System.Random rnd, double d1, double d2)
{
- return (ChiSquare.Sample(rnd, d1)/d1)/(ChiSquare.Sample(rnd, d2)/d2);
+ return (ChiSquared.Sample(rnd, d1)/d1)/(ChiSquared.Sample(rnd, d2)/d2);
}
///
@@ -289,7 +289,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public double Sample()
{
- return SampleUnchecked(RandomSource, _freedom1, _freedom2);
+ return SampleUnchecked(_random, _freedom1, _freedom2);
}
///
@@ -300,7 +300,7 @@ namespace MathNet.Numerics.Distributions
{
while (true)
{
- yield return SampleUnchecked(RandomSource, _freedom1, _freedom2);
+ yield return SampleUnchecked(_random, _freedom1, _freedom2);
}
}
@@ -308,8 +308,8 @@ namespace MathNet.Numerics.Distributions
/// Generates a sample from the distribution.
///
/// The random number generator to use.
- /// The first parameter - degree of freedom.
- /// The second parameter - degree of freedom.
+ /// The first degree of freedom (d1) of the distribution.
+ /// The second degree of freedom (d2) of the distribution.
/// a sample from the distribution.
public static double Sample(System.Random rnd, double d1, double d2)
{
@@ -325,8 +325,8 @@ namespace MathNet.Numerics.Distributions
/// Generates a sequence of samples from the distribution.
///
/// The random number generator to use.
- /// The first parameter - degree of freedom.
- /// The second parameter - degree of freedom.
+ /// The first degree of freedom (d1) of the distribution.
+ /// The second degree of freedom (d2) of the distribution.
/// a sequence of samples from the distribution.
public static IEnumerable Samples(System.Random rnd, double d1, double d2)
{
diff --git a/src/Numerics/Distributions/Gamma.cs b/src/Numerics/Distributions/Gamma.cs
index 85f1c8d2..84662304 100644
--- a/src/Numerics/Distributions/Gamma.cs
+++ b/src/Numerics/Distributions/Gamma.cs
@@ -336,7 +336,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the density of the distribution (PDF), i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
///
/// The location at which to compute the density.
/// the density at .
@@ -361,7 +361,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log density of the distribution (lnPDF), i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
///
/// The location at which to compute the log density.
/// the log density at .
@@ -386,7 +386,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
@@ -465,7 +465,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public double Sample()
{
- return SampleUnchecked(RandomSource, _shape, _rate);
+ return SampleUnchecked(_random, _shape, _rate);
}
///
@@ -476,35 +476,35 @@ namespace MathNet.Numerics.Distributions
{
while (true)
{
- yield return SampleUnchecked(RandomSource, _shape, _rate);
+ yield return SampleUnchecked(_random, _shape, _rate);
}
}
///
/// Generates a sample from the Gamma distribution.
///
- /// The random number generator to use.
+ /// The random number generator to use.
/// The shape (k, α) of the Gamma distribution.
/// The rate or inverse scale (β) of the Gamma distribution.
/// a sample from the distribution.
- public static double Sample(System.Random rng, double shape, double rate)
+ public static double Sample(System.Random rnd, double shape, double rate)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(shape, rate))
{
throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
}
- return SampleUnchecked(rng, shape, rate);
+ return SampleUnchecked(rnd, shape, rate);
}
///
/// Generates a sequence of samples from the Gamma distribution.
///
- /// The random number generator to use.
+ /// The random number generator to use.
/// The shape (k, α) of the Gamma distribution.
/// The rate or inverse scale (β) of the Gamma distribution.
/// a sequence of samples from the distribution.
- public static IEnumerable Samples(System.Random rng, double shape, double rate)
+ public static IEnumerable Samples(System.Random rnd, double shape, double rate)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(shape, rate))
{
@@ -513,7 +513,7 @@ namespace MathNet.Numerics.Distributions
while (true)
{
- yield return SampleUnchecked(rng, shape, rate);
+ yield return SampleUnchecked(rnd, shape, rate);
}
}
}
diff --git a/src/Numerics/Distributions/Geometric.cs b/src/Numerics/Distributions/Geometric.cs
index 51914162..d6170c56 100644
--- a/src/Numerics/Distributions/Geometric.cs
+++ b/src/Numerics/Distributions/Geometric.cs
@@ -202,7 +202,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the probability mass (PMF), i.e. P(X = x).
+ /// Computes the probability mass (PMF) at k, i.e. P(X = k).
///
/// The location in the domain where we want to evaluate the probability mass function.
/// the probability mass at location .
@@ -217,7 +217,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log probability mass (lnPMF), i.e. ln(P(X = x)).
+ /// Computes the log probability mass (lnPMF) at k, i.e. ln(P(X = k)).
///
/// The location in the domain where we want to evaluate the log probability mass function.
/// the log probability mass at location .
@@ -232,7 +232,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
@@ -249,7 +249,7 @@ namespace MathNet.Numerics.Distributions
///
/// One sample from the distribution implied by .
///
- internal static int SampleUnchecked(System.Random rnd, double p)
+ static int SampleUnchecked(System.Random rnd, double p)
{
return p == 1.0 ? 1 : (int) Math.Ceiling(-Math.Log(1.0 - rnd.NextDouble(), 1.0 - p));
}
@@ -260,7 +260,7 @@ namespace MathNet.Numerics.Distributions
/// A sample from the Geometric distribution.
public int Sample()
{
- return SampleUnchecked(RandomSource, _p);
+ return SampleUnchecked(_random, _p);
}
///
@@ -271,7 +271,7 @@ namespace MathNet.Numerics.Distributions
{
while (true)
{
- yield return SampleUnchecked(RandomSource, _p);
+ yield return SampleUnchecked(_random, _p);
}
}
diff --git a/src/Numerics/Distributions/Hypergeometric.cs b/src/Numerics/Distributions/Hypergeometric.cs
index 52faf2c9..59c210c4 100644
--- a/src/Numerics/Distributions/Hypergeometric.cs
+++ b/src/Numerics/Distributions/Hypergeometric.cs
@@ -260,7 +260,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the probability mass (PMF), i.e. P(X = x).
+ /// Computes the probability mass (PMF) at k, i.e. P(X = k).
///
/// The location in the domain where we want to evaluate the probability mass function.
/// the probability mass at location .
@@ -270,7 +270,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log probability mass (lnPMF), i.e. ln(P(X = x)).
+ /// Computes the log probability mass (lnPMF) at k, i.e. ln(P(X = k)).
///
/// The location in the domain where we want to evaluate the log probability mass function.
/// the log probability mass at location .
@@ -280,7 +280,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
@@ -313,7 +313,7 @@ namespace MathNet.Numerics.Distributions
/// The number successes within the population (K, M).
/// The n parameter of the distribution.
/// a random number from the Hypergeometric distribution.
- internal static int SampleUnchecked(System.Random rnd, int population, int success, int draws)
+ static int SampleUnchecked(System.Random rnd, int population, int success, int draws)
{
var x = 0;
@@ -340,7 +340,7 @@ namespace MathNet.Numerics.Distributions
/// The number of successes in n trials.
public int Sample()
{
- return SampleUnchecked(RandomSource, _population, _success, _draws);
+ return SampleUnchecked(_random, _population, _success, _draws);
}
///
@@ -351,7 +351,7 @@ namespace MathNet.Numerics.Distributions
{
while (true)
{
- yield return SampleUnchecked(RandomSource, _population, _success, _draws);
+ yield return SampleUnchecked(_random, _population, _success, _draws);
}
}
diff --git a/src/Numerics/Distributions/IContinuousDistribution.cs b/src/Numerics/Distributions/IContinuousDistribution.cs
index d7c4b7d4..b72e53d7 100644
--- a/src/Numerics/Distributions/IContinuousDistribution.cs
+++ b/src/Numerics/Distributions/IContinuousDistribution.cs
@@ -33,8 +33,9 @@ namespace MathNet.Numerics.Distributions
using System.Collections.Generic;
///
- /// The interface for continuous univariate distributions.
+ /// Continuous Univariate Probability Distribution.
///
+ ///
public interface IContinuousDistribution : IUnivariateDistribution
{
///
@@ -48,24 +49,24 @@ namespace MathNet.Numerics.Distributions
double Median { get; }
///
- /// Gets the smallest element in the domain of the distributions which can be represented by a double.
+ /// Gets the smallest element in the domain of the distribution which can be represented by a double.
///
double Minimum { get; }
///
- /// Gets the largest element in the domain of the distributions which can be represented by a double.
+ /// Gets the largest element in the domain of the distribution which can be represented by a double.
///
double Maximum { get; }
///
- /// Computes the density of the distribution (PDF), i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
///
/// The location at which to compute the density.
/// the density at .
double Density(double x);
///
- /// Computes the log density of the distribution (lnPDF), i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
///
/// The location at which to compute the log density.
/// the log density at .
@@ -80,7 +81,7 @@ namespace MathNet.Numerics.Distributions
///
/// Draws a sequence of random samples from the distribution.
///
- /// a sequence of samples from the distribution.
+ /// an infinite sequence of samples from the distribution.
IEnumerable Samples();
}
}
diff --git a/src/Numerics/Distributions/IDiscreteDistribution.cs b/src/Numerics/Distributions/IDiscreteDistribution.cs
index 1e23abbd..0bc3d499 100644
--- a/src/Numerics/Distributions/IDiscreteDistribution.cs
+++ b/src/Numerics/Distributions/IDiscreteDistribution.cs
@@ -33,8 +33,9 @@ namespace MathNet.Numerics.Distributions
using System.Collections.Generic;
///
- /// The interface for discrete univariate distributions.
+ /// Discrete Univariate Probability Distribution.
///
+ ///
public interface IDiscreteDistribution : IUnivariateDistribution
{
///
@@ -48,24 +49,24 @@ namespace MathNet.Numerics.Distributions
int Median { get; }
///
- /// Gets the smallest element in the domain of the distributions which can be represented by an integer.
+ /// Gets the smallest element in the domain of the distribution which can be represented by an integer.
///
int Minimum { get; }
///
- /// Gets the largest element in the domain of the distributions which can be represented by an integer.
+ /// Gets the largest element in the domain of the distribution which can be represented by an integer.
///
int Maximum { get; }
///
- /// Computes the probability mass (PMF), i.e. P(X = x).
+ /// Computes the probability mass (PMF) at k, i.e. P(X = k).
///
/// The location in the domain where we want to evaluate the probability mass function.
/// the probability mass at location .
double Probability(int k);
///
- /// Computes the log probability mass (lnPMF), i.e. ln(P(X = x)).
+ /// Computes the log probability mass (lnPMF) at k, i.e. ln(P(X = k)).
///
/// The location in the domain where we want to evaluate the log probability mass function.
/// the log probability mass at location .
@@ -80,7 +81,7 @@ namespace MathNet.Numerics.Distributions
///
/// Draws a sequence of random samples from the distribution.
///
- /// a sequence of samples from the distribution.
+ /// an infinite sequence of samples from the distribution.
IEnumerable Samples();
}
}
diff --git a/src/Numerics/Distributions/IDistribution.cs b/src/Numerics/Distributions/IDistribution.cs
index 5a06100a..006d6588 100644
--- a/src/Numerics/Distributions/IDistribution.cs
+++ b/src/Numerics/Distributions/IDistribution.cs
@@ -31,8 +31,10 @@
namespace MathNet.Numerics.Distributions
{
///
- /// The common interface for all distributions.
+ /// Probability Distribution.
///
+ ///
+ ///
public interface IDistribution
{
///
diff --git a/src/Numerics/Distributions/IUnivariateDistribution.cs b/src/Numerics/Distributions/IUnivariateDistribution.cs
index 294b5bda..10f08ccc 100644
--- a/src/Numerics/Distributions/IUnivariateDistribution.cs
+++ b/src/Numerics/Distributions/IUnivariateDistribution.cs
@@ -31,8 +31,10 @@
namespace MathNet.Numerics.Distributions
{
///
- /// The interface for univariate distributions.
+ /// Univariate Probability Distribution.
///
+ ///
+ ///
public interface IUnivariateDistribution : IDistribution
{
///
@@ -61,7 +63,7 @@ namespace MathNet.Numerics.Distributions
double Skewness { get; }
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
diff --git a/src/Numerics/Distributions/InverseGamma.cs b/src/Numerics/Distributions/InverseGamma.cs
index e7c1a449..4430c105 100644
--- a/src/Numerics/Distributions/InverseGamma.cs
+++ b/src/Numerics/Distributions/InverseGamma.cs
@@ -237,7 +237,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the density of the distribution (PDF), i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
///
/// The location at which to compute the density.
/// the density at .
@@ -252,7 +252,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log density of the distribution (lnPDF), i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
///
/// The location at which to compute the log density.
/// the log density at .
@@ -262,7 +262,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
@@ -278,7 +278,7 @@ namespace MathNet.Numerics.Distributions
/// The shape (α) of the inverse Gamma distribution.
/// The scale (β) of the inverse Gamma distribution.
/// a random number from the distribution.
- internal static double SampleUnchecked(System.Random rnd, double shape, double scale)
+ static double SampleUnchecked(System.Random rnd, double shape, double scale)
{
return 1.0/Gamma.Sample(rnd, shape, scale);
}
@@ -289,7 +289,7 @@ namespace MathNet.Numerics.Distributions
/// A random number from this distribution.
public double Sample()
{
- return SampleUnchecked(RandomSource, _shape, _scale);
+ return SampleUnchecked(_random, _shape, _scale);
}
///
@@ -300,7 +300,7 @@ namespace MathNet.Numerics.Distributions
{
while (true)
{
- yield return SampleUnchecked(RandomSource, _shape, _scale);
+ yield return SampleUnchecked(_random, _shape, _scale);
}
}
diff --git a/src/Numerics/Distributions/InverseWishart.cs b/src/Numerics/Distributions/InverseWishart.cs
index e767a1d2..b5bbc8b0 100644
--- a/src/Numerics/Distributions/InverseWishart.cs
+++ b/src/Numerics/Distributions/InverseWishart.cs
@@ -61,24 +61,24 @@ namespace MathNet.Numerics.Distributions
///
/// Initializes a new instance of the class.
///
- /// The degree of freedom (ν) for the inverse Wishart distribution.
+ /// The degree of freedom (ν) for the inverse Wishart distribution.
/// The scale matrix (Ψ) for the inverse Wishart distribution.
- public InverseWishart(double degreeOfFreedom, Matrix scale)
+ public InverseWishart(double degreesOfFreedom, Matrix scale)
{
_random = new System.Random();
- SetParameters(degreeOfFreedom, scale);
+ SetParameters(degreesOfFreedom, scale);
}
///
/// Initializes a new instance of the class.
///
- /// The degree of freedom (ν) for the inverse Wishart distribution.
+ /// The degree of freedom (ν) for the inverse Wishart distribution.
/// The scale matrix (Ψ) for the inverse Wishart distribution.
/// The random number generator which is used to draw random samples.
- public InverseWishart(double degreeOfFreedom, Matrix scale, System.Random randomSource)
+ public InverseWishart(double degreesOfFreedom, Matrix scale, System.Random randomSource)
{
_random = randomSource ?? new System.Random();
- SetParameters(degreeOfFreedom, scale);
+ SetParameters(degreesOfFreedom, scale);
}
///
@@ -93,10 +93,10 @@ namespace MathNet.Numerics.Distributions
///
/// Checks whether the parameters of the distribution are valid.
///
- /// The degree of freedom (ν) for the inverse Wishart distribution.
+ /// The degree of freedom (ν) for the inverse Wishart distribution.
/// The scale matrix (Ψ) for the inverse Wishart distribution.
/// true when the parameters are valid, false otherwise.
- static bool IsValidParameterSet(double degreeOfFreedom, Matrix scale)
+ static bool IsValidParameterSet(double degreesOfFreedom, Matrix scale)
{
if (scale.RowCount != scale.ColumnCount)
{
@@ -111,23 +111,23 @@ namespace MathNet.Numerics.Distributions
}
}
- return degreeOfFreedom > 0.0;
+ return degreesOfFreedom > 0.0;
}
///
/// Sets the parameters of the distribution after checking their validity.
///
- /// The degree of freedom (ν) for the inverse Wishart distribution.
+ /// The degree of freedom (ν) for the inverse Wishart distribution.
/// The scale matrix (Ψ) for the inverse Wishart distribution.
/// When the parameters don't pass the function.
- void SetParameters(double degreeOfFreedom, Matrix scale)
+ void SetParameters(double degreesOfFreedom, Matrix scale)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(degreeOfFreedom, scale))
+ if (Control.CheckDistributionParameters && !IsValidParameterSet(degreesOfFreedom, scale))
{
throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
}
- _freedom = degreeOfFreedom;
+ _freedom = degreesOfFreedom;
_scale = scale;
_chol = Cholesky.Create(_scale);
}
@@ -135,7 +135,7 @@ namespace MathNet.Numerics.Distributions
///
/// Gets or sets the degree of freedom (ν) for the inverse Wishart distribution.
///
- public double DegreeOfFreedom
+ public double DegreesOfFreedom
{
get { return _freedom; }
set { SetParameters(value, _scale); }
@@ -242,7 +242,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public Matrix Sample()
{
- return Sample(RandomSource, _freedom, _scale);
+ return Sample(_random, _freedom, _scale);
}
///
@@ -250,17 +250,17 @@ namespace MathNet.Numerics.Distributions
/// a Wishart random variable and inverting the matrix.
///
/// The random number generator to use.
- /// The degree of freedom (ν) for the inverse Wishart distribution.
+ /// The degree of freedom (ν) for the inverse Wishart distribution.
/// The scale matrix (Ψ) for the inverse Wishart distribution.
/// a sample from the distribution.
- public static Matrix Sample(System.Random rnd, double degreeOfFreedom, Matrix scale)
+ public static Matrix Sample(System.Random rnd, double degreesOfFreedom, Matrix scale)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(degreeOfFreedom, scale))
+ if (Control.CheckDistributionParameters && !IsValidParameterSet(degreesOfFreedom, scale))
{
throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
}
- var r = Wishart.Sample(rnd, degreeOfFreedom, scale.Inverse());
+ var r = Wishart.Sample(rnd, degreesOfFreedom, scale.Inverse());
return r.Inverse();
}
}
diff --git a/src/Numerics/Distributions/Laplace.cs b/src/Numerics/Distributions/Laplace.cs
index 795408ad..35a78f67 100644
--- a/src/Numerics/Distributions/Laplace.cs
+++ b/src/Numerics/Distributions/Laplace.cs
@@ -223,17 +223,17 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the density of the distribution (PDF), i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
///
/// The location at which to compute the density.
- /// the density at .
+ /// the density at .
public double Density(double x)
{
return Math.Exp(-Math.Abs(x - _location)/_scale)/(2.0*_scale);
}
///
- /// Computes the log density of the distribution (lnPDF), i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
///
/// The location at which to compute the log density.
/// the log density at .
@@ -243,7 +243,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
@@ -259,7 +259,7 @@ namespace MathNet.Numerics.Distributions
/// The location (μ) of the Laplace distribution.
/// The scale (b) of the Laplace distribution.
/// a random number from the distribution.
- internal static double SampleUnchecked(System.Random rnd, double location, double scale)
+ static double SampleUnchecked(System.Random rnd, double location, double scale)
{
var u = rnd.NextDouble() - 0.5;
return location - (scale*Math.Sign(u)*Math.Log(1.0 - (2.0*Math.Abs(u))));
@@ -271,7 +271,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public double Sample()
{
- return SampleUnchecked(RandomSource, _location, _scale);
+ return SampleUnchecked(_random, _location, _scale);
}
///
@@ -282,7 +282,7 @@ namespace MathNet.Numerics.Distributions
{
while (true)
{
- yield return SampleUnchecked(RandomSource, _location, _scale);
+ yield return SampleUnchecked(_random, _location, _scale);
}
}
diff --git a/src/Numerics/Distributions/LogNormal.cs b/src/Numerics/Distributions/LogNormal.cs
index e92b4841..e8c11fd7 100644
--- a/src/Numerics/Distributions/LogNormal.cs
+++ b/src/Numerics/Distributions/LogNormal.cs
@@ -119,7 +119,7 @@ namespace MathNet.Numerics.Distributions
/// true when the parameters are valid, false otherwise.
static bool IsValidParameterSet(double mu, double sigma)
{
- return sigma >= 0.0 && !Double.IsNaN(mu) && !Double.IsNaN(mu);
+ return sigma >= 0.0 && !Double.IsNaN(mu);
}
///
@@ -251,7 +251,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the density of the distribution (PDF), i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
///
/// The location at which to compute the density.
/// the density at .
@@ -267,7 +267,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log density of the distribution (lnPDF), i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
///
/// The location at which to compute the log density.
/// the log density at .
@@ -283,7 +283,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
@@ -303,7 +303,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public double Sample()
{
- return Math.Exp(Normal.SampleUnchecked(RandomSource, _mu, _sigma));
+ return Math.Exp(Normal.SampleUnchecked(_random, _mu, _sigma));
}
///
@@ -312,51 +312,31 @@ namespace MathNet.Numerics.Distributions
/// a sequence of samples from the distribution.
public IEnumerable Samples()
{
- while (true)
- {
- var sample = Normal.SampleUncheckedBoxMuller(RandomSource);
- yield return Math.Exp(_mu + (_sigma*sample.Item1));
- yield return Math.Exp(_mu + (_sigma*sample.Item2));
- }
+ return Normal.SamplesUnchecked(_random, _mu, _sigma).Select(Math.Exp);
}
///
/// Generates a sample from the log-normal distribution using the Box-Muller algorithm.
///
- /// The random number generator to use.
+ /// The random number generator to use.
/// The log-scale (μ) of the distribution.
/// The shape (σ) of the distribution.
/// a sample from the distribution.
- public static double Sample(System.Random rng, double mu, double sigma)
+ public static double Sample(System.Random rnd, double mu, double sigma)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(mu, sigma))
- {
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
- }
-
- return Math.Exp(Normal.SampleUnchecked(rng, mu, sigma));
+ return Math.Exp(Normal.Sample(rnd, mu, sigma));
}
///
/// Generates a sequence of samples from the log-normal distribution using the Box-Muller algorithm.
///
- /// The random number generator to use.
+ /// The random number generator to use.
/// The log-scale (μ) of the distribution.
/// The shape (σ) of the distribution.
/// a sequence of samples from the distribution.
- public static IEnumerable Samples(System.Random rng, double mu, double sigma)
+ public static IEnumerable Samples(System.Random rnd, double mu, double sigma)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(mu, sigma))
- {
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
- }
-
- while (true)
- {
- var sample = Normal.SampleUncheckedBoxMuller(rng);
- yield return Math.Exp(mu + (sigma*sample.Item1));
- yield return Math.Exp(mu + (sigma*sample.Item2));
- }
+ return Normal.Samples(rnd, mu, sigma).Select(Math.Exp);
}
}
}
diff --git a/src/Numerics/Distributions/MatrixNormal.cs b/src/Numerics/Distributions/MatrixNormal.cs
index e4b2a91c..26e58c21 100644
--- a/src/Numerics/Distributions/MatrixNormal.cs
+++ b/src/Numerics/Distributions/MatrixNormal.cs
@@ -231,7 +231,7 @@ namespace MathNet.Numerics.Distributions
/// A random number from this distribution.
public Matrix Sample()
{
- return Sample(RandomSource, _m, _v, _k);
+ return Sample(_random, _m, _v, _k);
}
///
@@ -282,34 +282,12 @@ namespace MathNet.Numerics.Distributions
static Vector SampleVectorNormal(System.Random rnd, Vector mean, Matrix covariance)
{
var chol = Cholesky.Create(covariance);
- return SampleVectorNormal(rnd, mean, chol);
- }
-
- ///
- /// Samples a vector normal distributed random variable.
- ///
- /// The random number generator to use.
- /// The mean of the vector normal distribution.
- /// The Cholesky factorization of the covariance matrix.
- /// a sequence of samples from defined distribution.
- static Vector SampleVectorNormal(System.Random rnd, Vector mean, Cholesky cholesky)
- {
- var count = mean.Count;
// Sample a standard normal variable.
- var v = new DenseVector(count);
- for (var d = 0; d < count; d += 2)
- {
- var sample = Normal.SampleUncheckedBoxMuller(rnd);
- v[d] = sample.Item1;
- if (d + 1 < count)
- {
- v[d + 1] = sample.Item2;
- }
- }
+ var v = DenseVector.CreateRandom(mean.Count, new Normal(rnd));
// Return the transformed variable.
- return mean + (cholesky.Factor*v);
+ return mean + (chol.Factor*v);
}
}
}
diff --git a/src/Numerics/Distributions/Multinomial.cs b/src/Numerics/Distributions/Multinomial.cs
index b241d34a..82821a8b 100644
--- a/src/Numerics/Distributions/Multinomial.cs
+++ b/src/Numerics/Distributions/Multinomial.cs
@@ -317,7 +317,7 @@ namespace MathNet.Numerics.Distributions
/// the counts for each of the different possible values.
public int[] Sample()
{
- return Sample(RandomSource, _p, _trials);
+ return Sample(_random, _p, _trials);
}
///
@@ -328,7 +328,7 @@ namespace MathNet.Numerics.Distributions
{
while (true)
{
- yield return Sample(RandomSource, _p, _trials);
+ yield return Sample(_random, _p, _trials);
}
}
diff --git a/src/Numerics/Distributions/NegativeBinomial.cs b/src/Numerics/Distributions/NegativeBinomial.cs
index eab6cb56..12cf30fe 100644
--- a/src/Numerics/Distributions/NegativeBinomial.cs
+++ b/src/Numerics/Distributions/NegativeBinomial.cs
@@ -56,7 +56,7 @@ namespace MathNet.Numerics.Distributions
///
/// Initializes a new instance of the class.
///
- /// The number of trials.
+ /// The number of failures until the experiment stopped.
/// The probability of a trial resulting in success.
public NegativeBinomial(double r, double p)
{
@@ -67,7 +67,7 @@ namespace MathNet.Numerics.Distributions
///
/// Initializes a new instance of the class.
///
- /// The number of trials.
+ /// The number of failures until the experiment stopped.
/// The probability of a trial resulting in success.
/// The random number generator which is used to draw random samples.
public NegativeBinomial(double r, double p, System.Random randomSource)
@@ -90,7 +90,7 @@ namespace MathNet.Numerics.Distributions
///
/// Checks whether the parameters of the distribution are valid.
///
- /// The number of trials.
+ /// The number of failures until the experiment stopped.
/// The probability of a trial resulting in success.
/// true when the parameters are valid, false otherwise.
static bool IsValidParameterSet(double r, double p)
@@ -101,7 +101,7 @@ namespace MathNet.Numerics.Distributions
///
/// Sets the parameters of the distribution after checking their validity.
///
- /// The number of trials.
+ /// The number of failures until the experiment stopped.
/// The probability of a trial resulting in success.
/// When the parameters don't pass the function.
void SetParameters(double r, double p)
@@ -214,7 +214,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the probability mass (PMF), i.e. P(X = x).
+ /// Computes the probability mass (PMF) at k, i.e. P(X = k).
///
/// The location in the domain where we want to evaluate the probability mass function.
/// the probability mass at location .
@@ -229,7 +229,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log probability mass (lnPMF), i.e. ln(P(X = x)).
+ /// Computes the log probability mass (lnPMF) at k, i.e. ln(P(X = k)).
///
/// The location in the domain where we want to evaluate the log probability mass function.
/// the log probability mass at location .
@@ -244,7 +244,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
@@ -257,10 +257,10 @@ namespace MathNet.Numerics.Distributions
/// Samples a negative binomial distributed random variable.
///
/// The random number generator to use.
- /// The r parameter.
- /// The p parameter.
+ /// The number of failures until the experiment stopped.
+ /// The probability of a trial resulting in success.
/// a sample from the distribution.
- internal static int SampleUnchecked(System.Random rnd, double r, double p)
+ static int SampleUnchecked(System.Random rnd, double r, double p)
{
var lambda = Gamma.SampleUnchecked(rnd, r, p);
var c = Math.Exp(-lambda);
@@ -280,7 +280,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public int Sample()
{
- return SampleUnchecked(RandomSource, _trials, _p);
+ return SampleUnchecked(_random, _trials, _p);
}
///
@@ -291,7 +291,7 @@ namespace MathNet.Numerics.Distributions
{
while (true)
{
- yield return SampleUnchecked(RandomSource, _trials, _p);
+ yield return SampleUnchecked(_random, _trials, _p);
}
}
@@ -299,8 +299,8 @@ namespace MathNet.Numerics.Distributions
/// Samples a random variable.
///
/// The random number generator to use.
- /// The r parameter.
- /// The p parameter.
+ /// The number of failures until the experiment stopped.
+ /// The probability of a trial resulting in success.
public static int Sample(System.Random rnd, double r, double p)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(r, p))
@@ -315,8 +315,8 @@ namespace MathNet.Numerics.Distributions
/// Samples a sequence of this random variable.
///
/// The random number generator to use.
- /// The r parameter.
- /// The p parameter.
+ /// The number of failures until the experiment stopped.
+ /// The probability of a trial resulting in success.
public static IEnumerable Samples(System.Random rnd, double r, double p)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(r, p))
diff --git a/src/Numerics/Distributions/Normal.cs b/src/Numerics/Distributions/Normal.cs
index 7dbf7e3c..8f5e7d7d 100644
--- a/src/Numerics/Distributions/Normal.cs
+++ b/src/Numerics/Distributions/Normal.cs
@@ -309,7 +309,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the density of the distribution (PDF), i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
///
/// The location at which to compute the density.
/// the density at .
@@ -319,7 +319,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log density of the distribution (lnPDF), i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
///
/// The location at which to compute the log density.
/// the log density at .
@@ -341,7 +341,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
@@ -351,7 +351,8 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the inverse cumulative distribution function of the normal distribution.
+ /// Computes the inverse of the cumulative distribution function (InvCDF) for the distribution
+ /// at the given probability.
///
/// The location at which to compute the inverse cumulative density.
/// the inverse cumulative density at .
@@ -365,7 +366,7 @@ namespace MathNet.Numerics.Distributions
///
/// The random number generator to use.
/// a pair of random numbers from the standard normal distribution.
- internal static Tuple SampleUncheckedBoxMuller(System.Random rnd)
+ static Tuple SampleStandardBoxMuller(System.Random rnd)
{
var v1 = (2.0*rnd.NextDouble()) - 1.0;
var v2 = (2.0*rnd.NextDouble()) - 1.0;
@@ -390,7 +391,24 @@ namespace MathNet.Numerics.Distributions
/// a random number from the distribution.
internal static double SampleUnchecked(System.Random rnd, double mean, double stddev)
{
- return mean + (stddev*SampleUncheckedBoxMuller(rnd).Item1);
+ return mean + (stddev*SampleStandardBoxMuller(rnd).Item1);
+ }
+
+ ///
+ /// Samples the distribution.
+ ///
+ /// The random number generator to use.
+ /// The mean (μ) of the normal distribution.
+ /// The standard deviation (σ) of the normal distribution.
+ /// a random number from the distribution.
+ internal static IEnumerable SamplesUnchecked(System.Random rnd, double mean, double stddev)
+ {
+ while (true)
+ {
+ var sample = SampleStandardBoxMuller(rnd);
+ yield return mean + (stddev*sample.Item1);
+ yield return mean + (stddev*sample.Item2);
+ }
}
///
@@ -399,7 +417,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public double Sample()
{
- return SampleUnchecked(RandomSource, _mean, _stdDev);
+ return SampleUnchecked(_random, _mean, _stdDev);
}
///
@@ -408,12 +426,7 @@ namespace MathNet.Numerics.Distributions
/// a sequence of samples from the distribution.
public IEnumerable Samples()
{
- while (true)
- {
- var sample = SampleUncheckedBoxMuller(RandomSource);
- yield return _mean + (_stdDev*sample.Item1);
- yield return _mean + (_stdDev*sample.Item2);
- }
+ return SamplesUnchecked(_random, _mean, _stdDev);
}
///
@@ -447,12 +460,7 @@ namespace MathNet.Numerics.Distributions
throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
}
- while (true)
- {
- var sample = SampleUncheckedBoxMuller(rnd);
- yield return mean + (stddev*sample.Item1);
- yield return mean + (stddev*sample.Item2);
- }
+ return SamplesUnchecked(rnd, mean, stddev);
}
}
}
diff --git a/src/Numerics/Distributions/NormalGamma.cs b/src/Numerics/Distributions/NormalGamma.cs
index ca95b769..8037da03 100644
--- a/src/Numerics/Distributions/NormalGamma.cs
+++ b/src/Numerics/Distributions/NormalGamma.cs
@@ -351,7 +351,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public MeanPrecisionPair Sample()
{
- return Sample(RandomSource, _meanLocation, _meanScale, _precisionShape, _precisionInvScale);
+ return Sample(_random, _meanLocation, _meanScale, _precisionShape, _precisionInvScale);
}
///
@@ -362,7 +362,7 @@ namespace MathNet.Numerics.Distributions
{
while (true)
{
- yield return Sample(RandomSource, _meanLocation, _meanScale, _precisionShape, _precisionInvScale);
+ yield return Sample(_random, _meanLocation, _meanScale, _precisionShape, _precisionInvScale);
}
}
diff --git a/src/Numerics/Distributions/Pareto.cs b/src/Numerics/Distributions/Pareto.cs
index 8e2aafe5..ac54731a 100644
--- a/src/Numerics/Distributions/Pareto.cs
+++ b/src/Numerics/Distributions/Pareto.cs
@@ -231,7 +231,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the density of the distribution (PDF), i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
///
/// The location at which to compute the density.
/// the density at .
@@ -241,7 +241,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log density of the distribution (lnPDF), i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
///
/// The location at which to compute the log density.
/// the log density at .
@@ -251,7 +251,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
@@ -267,7 +267,7 @@ namespace MathNet.Numerics.Distributions
/// The scale (xm) of the distribution.
/// The shape (α) of the distribution.
/// a random number from the Pareto distribution.
- internal static double SampleUnchecked(System.Random rnd, double scale, double shape)
+ static double SampleUnchecked(System.Random rnd, double scale, double shape)
{
return scale*Math.Pow(rnd.NextDouble(), -1.0/shape);
}
@@ -278,7 +278,7 @@ namespace MathNet.Numerics.Distributions
/// A random number from this distribution.
public double Sample()
{
- return SampleUnchecked(RandomSource, _scale, _shape);
+ return SampleUnchecked(_random, _scale, _shape);
}
///
@@ -289,7 +289,7 @@ namespace MathNet.Numerics.Distributions
{
while (true)
{
- yield return SampleUnchecked(RandomSource, _scale, _shape);
+ yield return SampleUnchecked(_random, _scale, _shape);
}
}
diff --git a/src/Numerics/Distributions/Poisson.cs b/src/Numerics/Distributions/Poisson.cs
index 5994c353..abf5fc5b 100644
--- a/src/Numerics/Distributions/Poisson.cs
+++ b/src/Numerics/Distributions/Poisson.cs
@@ -200,7 +200,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the probability mass (PMF), i.e. P(X = x).
+ /// Computes the probability mass (PMF) at k, i.e. P(X = k).
///
/// The location in the domain where we want to evaluate the probability mass function.
/// the probability mass at location .
@@ -210,7 +210,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log probability mass (lnPMF), i.e. ln(P(X = x)).
+ /// Computes the log probability mass (lnPMF) at k, i.e. ln(P(X = k)).
///
/// The location in the domain where we want to evaluate the log probability mass function.
/// the log probability mass at location .
@@ -220,7 +220,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
@@ -235,7 +235,7 @@ namespace MathNet.Numerics.Distributions
/// The random source to use.
/// The Poisson distribution parameter λ.
/// A random sample from the Poisson distribution.
- internal static int SampleUnchecked(System.Random rnd, double lambda)
+ static int SampleUnchecked(System.Random rnd, double lambda)
{
return (lambda < 30.0) ? DoSampleShort(rnd, lambda) : DoSampleLarge(rnd, lambda);
}
@@ -302,7 +302,7 @@ namespace MathNet.Numerics.Distributions
/// A sample from the Poisson distribution.
public int Sample()
{
- return SampleUnchecked(RandomSource, _lambda);
+ return SampleUnchecked(_random, _lambda);
}
///
@@ -313,7 +313,7 @@ namespace MathNet.Numerics.Distributions
{
while (true)
{
- yield return SampleUnchecked(RandomSource, _lambda);
+ yield return SampleUnchecked(_random, _lambda);
}
}
diff --git a/src/Numerics/Distributions/Rayleigh.cs b/src/Numerics/Distributions/Rayleigh.cs
index 6e1379e2..3b34823a 100644
--- a/src/Numerics/Distributions/Rayleigh.cs
+++ b/src/Numerics/Distributions/Rayleigh.cs
@@ -201,7 +201,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the density of the distribution (PDF), i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
///
/// The location at which to compute the density.
/// the density at .
@@ -211,7 +211,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log density of the distribution (lnPDF), i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
///
/// The location at which to compute the log density.
/// the log density at .
@@ -221,7 +221,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
@@ -236,7 +236,7 @@ namespace MathNet.Numerics.Distributions
/// The random number generator to use.
/// The scale (σ) of the distribution.
/// a random number from the Rayleigh distribution.
- internal static double SampleUnchecked(System.Random rnd, double scale)
+ static double SampleUnchecked(System.Random rnd, double scale)
{
return scale*Math.Sqrt(-2.0*Math.Log(rnd.NextDouble()));
}
@@ -247,7 +247,7 @@ namespace MathNet.Numerics.Distributions
/// A random number from this distribution.
public double Sample()
{
- return SampleUnchecked(RandomSource, _scale);
+ return SampleUnchecked(_random, _scale);
}
///
@@ -258,7 +258,7 @@ namespace MathNet.Numerics.Distributions
{
while (true)
{
- yield return SampleUnchecked(RandomSource, _scale);
+ yield return SampleUnchecked(_random, _scale);
}
}
diff --git a/src/Numerics/Distributions/Stable.cs b/src/Numerics/Distributions/Stable.cs
index 736e8b1e..0d94d035 100644
--- a/src/Numerics/Distributions/Stable.cs
+++ b/src/Numerics/Distributions/Stable.cs
@@ -303,7 +303,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the density of the distribution (PDF), i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
///
/// The location at which to compute the density.
/// the density at .
@@ -346,7 +346,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log density of the distribution (lnPDF), i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
///
/// The location at which to compute the log density.
/// the log density at .
@@ -356,7 +356,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
@@ -403,7 +403,7 @@ namespace MathNet.Numerics.Distributions
/// The scale (c) of the distribution.
/// The location (μ) of the distribution.
/// a random number from the distribution.
- internal static double SampleUnchecked(System.Random rnd, double alpha, double beta, double scale, double location)
+ static double SampleUnchecked(System.Random rnd, double alpha, double beta, double scale, double location)
{
var randTheta = ContinuousUniform.Sample(rnd, -Constants.PiOver2, Constants.PiOver2);
var randW = Exponential.Sample(rnd, 1.0);
@@ -436,7 +436,7 @@ namespace MathNet.Numerics.Distributions
/// A random number from this distribution.
public double Sample()
{
- return SampleUnchecked(RandomSource, _alpha, _beta, _scale, _location);
+ return SampleUnchecked(_random, _alpha, _beta, _scale, _location);
}
///
@@ -447,7 +447,7 @@ namespace MathNet.Numerics.Distributions
{
while (true)
{
- yield return SampleUnchecked(RandomSource, _alpha, _beta, _scale, _location);
+ yield return SampleUnchecked(_random, _alpha, _beta, _scale, _location);
}
}
diff --git a/src/Numerics/Distributions/StudentT.cs b/src/Numerics/Distributions/StudentT.cs
index d4f6a38d..e7ded7e9 100644
--- a/src/Numerics/Distributions/StudentT.cs
+++ b/src/Numerics/Distributions/StudentT.cs
@@ -1,4 +1,4 @@
-//
+//
// Math.NET Numerics, part of the Math.NET Project
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
@@ -78,13 +78,13 @@ namespace MathNet.Numerics.Distributions
/// freedom. The distribution will
/// be initialized with the default random number generator.
///
- /// The location of the Student t-distribution.
- /// The scale of the Student t-distribution.
- /// The degrees of freedom for the Student t-distribution.
- public StudentT(double location, double scale, double dof)
+ /// The location (μ) of the distribution.
+ /// The scale (σ) of the distribution.
+ /// The degrees of freedom (ν) for the distribution.
+ public StudentT(double location, double scale, double freedom)
{
_random = new System.Random();
- SetParameters(location, scale, dof);
+ SetParameters(location, scale, freedom);
}
///
@@ -92,14 +92,14 @@ namespace MathNet.Numerics.Distributions
/// freedom. The distribution will
/// be initialized with the default random number generator.
///
- /// The location of the Student t-distribution.
- /// The scale of the Student t-distribution.
- /// The degrees of freedom for the Student t-distribution.
+ /// The location (μ) of the distribution.
+ /// The scale (σ) of the distribution.
+ /// The degrees of freedom (ν) for the distribution.
/// The random number generator which is used to draw random samples.
- public StudentT(double location, double scale, double dof, System.Random randomSource)
+ public StudentT(double location, double scale, double freedom, System.Random randomSource)
{
_random = randomSource ?? new System.Random();
- SetParameters(location, scale, dof);
+ SetParameters(location, scale, freedom);
}
///
@@ -108,42 +108,42 @@ namespace MathNet.Numerics.Distributions
/// a string representation of the distribution.
public override string ToString()
{
- return "StudentT(Location = " + _location + ", Scale = " + _scale + ", DoF = " + _freedom + ")";
+ return "StudentT(μ = " + _location + ", σ = " + _scale + ", ν = " + _freedom + ")";
}
///
/// Checks whether the parameters of the distribution are valid.
///
- /// The location of the Student t-distribution.
- /// The scale of the Student t-distribution.
- /// The degrees of freedom for the Student t-distribution.
+ /// The location (μ) of the distribution.
+ /// The scale (σ) of the distribution.
+ /// The degrees of freedom (ν) for the distribution.
/// true when the parameters are valid, false otherwise.
- static bool IsValidParameterSet(double location, double scale, double dof)
+ static bool IsValidParameterSet(double location, double scale, double freedom)
{
- return scale > 0.0 && dof > 0.0 && !Double.IsNaN(location);
+ return scale > 0.0 && freedom > 0.0 && !Double.IsNaN(location);
}
///
/// Sets the parameters of the distribution after checking their validity.
///
- /// The location of the Student t-distribution.
- /// The scale of the Student t-distribution.
- /// The degrees of freedom for the Student t-distribution.
+ /// The location (μ) of the distribution.
+ /// The scale (σ) of the distribution.
+ /// The degrees of freedom (ν) for the distribution.
/// When the parameters don't pass the function.
- void SetParameters(double location, double scale, double dof)
+ void SetParameters(double location, double scale, double freedom)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(location, scale, dof))
+ if (Control.CheckDistributionParameters && !IsValidParameterSet(location, scale, freedom))
{
throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
}
_location = location;
_scale = scale;
- _freedom = dof;
+ _freedom = freedom;
}
///
- /// Gets or sets the location of the Student t-distribution.
+ /// Gets or sets the location (μ) of the Student t-distribution.
///
public double Location
{
@@ -152,7 +152,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Gets or sets the scale of the Student t-distribution.
+ /// Gets or sets the scale (σ) of the Student t-distribution.
///
public double Scale
{
@@ -161,7 +161,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Gets or sets the degrees of freedom of the Student t-distribution.
+ /// Gets or sets the degrees of freedom (ν) of the Student t-distribution.
///
public double DegreesOfFreedom
{
@@ -235,12 +235,10 @@ namespace MathNet.Numerics.Distributions
{
get
{
- if (_location != 0 || _scale != 1.0)
- {
- throw new NotSupportedException();
- }
+ if (_location != 0 || _scale != 1.0) throw new NotSupportedException();
- return (((_freedom + 1.0)/2.0)*(SpecialFunctions.DiGamma((1.0 + _freedom)/2.0) - SpecialFunctions.DiGamma(_freedom/2.0))) + Math.Log(Math.Sqrt(_freedom)*SpecialFunctions.Beta(_freedom/2.0, 1.0/2.0));
+ return (((_freedom + 1.0)/2.0)*(SpecialFunctions.DiGamma((1.0 + _freedom)/2.0) - SpecialFunctions.DiGamma(_freedom/2.0)))
+ + Math.Log(Math.Sqrt(_freedom)*SpecialFunctions.Beta(_freedom/2.0, 1.0/2.0));
}
}
@@ -251,10 +249,7 @@ namespace MathNet.Numerics.Distributions
{
get
{
- if (_freedom <= 3)
- {
- throw new NotSupportedException();
- }
+ if (_freedom <= 3) throw new NotSupportedException();
return 0.0;
}
@@ -293,7 +288,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the density of the distribution (PDF), i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
///
/// The location at which to compute the density.
/// the density at .
@@ -313,7 +308,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log density of the distribution (lnPDF), i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
///
/// The location at which to compute the log density.
/// the log density at .
@@ -333,7 +328,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
@@ -357,15 +352,14 @@ namespace MathNet.Numerics.Distributions
/// The algorithm is method 2 in section 5, chapter 9
/// in L. Devroye's "Non-Uniform Random Variate Generation"
/// The random number generator to use.
- /// The location of the Student t-distribution.
- /// The scale of the Student t-distribution.
- /// The degrees of freedom for the standard student-t distribution.
+ /// The location (μ) of the distribution.
+ /// The scale (σ) of the distribution.
+ /// The degrees of freedom (ν) for the distribution.
/// a random number from the standard student-t distribution.
- internal static double SampleUnchecked(System.Random rnd, double location, double scale, double dof)
+ static double SampleUnchecked(System.Random rnd, double location, double scale, double freedom)
{
- var n = Normal.SampleUncheckedBoxMuller(rnd).Item1;
- var g = Gamma.SampleUnchecked(rnd, 0.5*dof, 0.5);
- return location + (scale*n*Math.Sqrt(dof/g));
+ var gamma = Gamma.SampleUnchecked(rnd, 0.5*freedom, 0.5);
+ return Normal.SampleUnchecked(rnd, location, scale*Math.Sqrt(freedom/gamma));
}
///
@@ -374,7 +368,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public double Sample()
{
- return SampleUnchecked(RandomSource, _location, _scale, _freedom);
+ return SampleUnchecked(_random, _location, _scale, _freedom);
}
///
@@ -385,46 +379,46 @@ namespace MathNet.Numerics.Distributions
{
while (true)
{
- yield return SampleUnchecked(RandomSource, _location, _scale, _freedom);
+ yield return SampleUnchecked(_random, _location, _scale, _freedom);
}
}
///
/// Generates a sample from the Student t-distribution.
///
- /// The random number generator to use.
- /// The location of the Student t-distribution.
- /// The scale of the Student t-distribution.
- /// The degrees of freedom for the Student t-distribution.
+ /// The random number generator to use.
+ /// The location (μ) of the distribution.
+ /// The scale (σ) of the distribution.
+ /// The degrees of freedom (ν) for the distribution.
/// a sample from the distribution.
- public static double Sample(System.Random rng, double location, double scale, double dof)
+ public static double Sample(System.Random rnd, double location, double scale, double freedom)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(location, scale, dof))
+ if (Control.CheckDistributionParameters && !IsValidParameterSet(location, scale, freedom))
{
throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
}
- return SampleUnchecked(rng, location, scale, dof);
+ return SampleUnchecked(rnd, location, scale, freedom);
}
///
/// Generates a sequence of samples from the Student t-distribution using the Box-Muller algorithm.
///
- /// The random number generator to use.
- /// The location of the Student t-distribution.
- /// The scale of the Student t-distribution.
- /// The degrees of freedom for the Student t-distribution.
+ /// The random number generator to use.
+ /// The location (μ) of the distribution.
+ /// The scale (σ) of the distribution.
+ /// The degrees of freedom (ν) for the distribution.
/// a sequence of samples from the distribution.
- public static IEnumerable Samples(System.Random rng, double location, double scale, double dof)
+ public static IEnumerable Samples(System.Random rnd, double location, double scale, double freedom)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(location, scale, dof))
+ if (Control.CheckDistributionParameters && !IsValidParameterSet(location, scale, freedom))
{
throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
}
while (true)
{
- yield return SampleUnchecked(rng, location, scale, dof);
+ yield return SampleUnchecked(rnd, location, scale, freedom);
}
}
}
diff --git a/src/Numerics/Distributions/Weibull.cs b/src/Numerics/Distributions/Weibull.cs
index 200a39d5..3463fc2e 100644
--- a/src/Numerics/Distributions/Weibull.cs
+++ b/src/Numerics/Distributions/Weibull.cs
@@ -238,7 +238,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the density of the distribution (PDF), i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
///
/// The location at which to compute the density.
/// the density at .
@@ -258,7 +258,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log density of the distribution (lnPDF), i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
///
/// The location at which to compute the log density.
/// the log density at .
@@ -278,7 +278,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
@@ -300,7 +300,7 @@ namespace MathNet.Numerics.Distributions
/// The shape (k) of the Weibull distribution.
/// The scale (λ) of the Weibull distribution.
/// A sample from a Weibull distributed random variable.
- internal static double SampleUnchecked(System.Random rnd, double shape, double scale)
+ static double SampleUnchecked(System.Random rnd, double shape, double scale)
{
var x = rnd.NextDouble();
return scale*Math.Pow(-Math.Log(x), 1.0/shape);
@@ -312,7 +312,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public double Sample()
{
- return SampleUnchecked(RandomSource, _shape, _scale);
+ return SampleUnchecked(_random, _shape, _scale);
}
///
@@ -323,35 +323,35 @@ namespace MathNet.Numerics.Distributions
{
while (true)
{
- yield return SampleUnchecked(RandomSource, _shape, _scale);
+ yield return SampleUnchecked(_random, _shape, _scale);
}
}
///
/// Generates a sample from the Weibull distribution.
///
- /// The random number generator to use.
+ /// The random number generator to use.
/// The shape (k) of the Weibull distribution.
/// The scale (λ) of the Weibull distribution.
/// a sample from the distribution.
- public static double Sample(System.Random rng, double shape, double scale)
+ public static double Sample(System.Random rnd, double shape, double scale)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(shape, scale))
{
throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
}
- return SampleUnchecked(rng, shape, scale);
+ return SampleUnchecked(rnd, shape, scale);
}
///
/// Generates a sequence of samples from the Weibull distribution.
///
- /// The random number generator to use.
+ /// The random number generator to use.
/// The shape (k) of the Weibull distribution.
/// The scale (λ) of the Weibull distribution.
/// a sequence of samples from the distribution.
- public static IEnumerable Samples(System.Random rng, double shape, double scale)
+ public static IEnumerable Samples(System.Random rnd, double shape, double scale)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(shape, scale))
{
@@ -360,7 +360,7 @@ namespace MathNet.Numerics.Distributions
while (true)
{
- yield return SampleUnchecked(rng, shape, scale);
+ yield return SampleUnchecked(rnd, shape, scale);
}
}
}
diff --git a/src/Numerics/Distributions/Wishart.cs b/src/Numerics/Distributions/Wishart.cs
index 18ef9d22..923fdbc9 100644
--- a/src/Numerics/Distributions/Wishart.cs
+++ b/src/Numerics/Distributions/Wishart.cs
@@ -55,7 +55,7 @@ namespace MathNet.Numerics.Distributions
///
/// The degrees of freedom for the Wishart distribution.
///
- double _degreeOfFreedom;
+ double _degreesOfFreedom;
///
/// The scale matrix for the Wishart distribution.
@@ -70,40 +70,40 @@ namespace MathNet.Numerics.Distributions
///
/// Initializes a new instance of the class.
///
- /// The degrees of freedom (n) for the Wishart distribution.
+ /// The degrees of freedom (n) for the Wishart distribution.
/// The scale matrix (V) for the Wishart distribution.
- public Wishart(double degreeOfFreedom, Matrix scale)
+ public Wishart(double degreesOfFreedom, Matrix scale)
{
_random = new System.Random();
- SetParameters(degreeOfFreedom, scale);
+ SetParameters(degreesOfFreedom, scale);
}
///
/// Initializes a new instance of the class.
///
- /// The degrees of freedom (n) for the Wishart distribution.
+ /// The degrees of freedom (n) for the Wishart distribution.
/// The scale matrix (V) for the Wishart distribution.
/// The random number generator which is used to draw random samples.
- public Wishart(double degreeOfFreedom, Matrix scale, System.Random randomSource)
+ public Wishart(double degreesOfFreedom, Matrix scale, System.Random randomSource)
{
_random = randomSource ?? new System.Random();
- SetParameters(degreeOfFreedom, scale);
+ SetParameters(degreesOfFreedom, scale);
}
///
/// Sets the parameters of the distribution after checking their validity.
///
- /// The degrees of freedom (n) for the Wishart distribution.
+ /// The degrees of freedom (n) for the Wishart distribution.
/// The scale matrix (V) for the Wishart distribution.
/// When the parameters don't pass the function.
- void SetParameters(double degreeOfFreedom, Matrix scale)
+ void SetParameters(double degreesOfFreedom, Matrix scale)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(degreeOfFreedom, scale))
+ if (Control.CheckDistributionParameters && !IsValidParameterSet(degreesOfFreedom, scale))
{
throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
}
- _degreeOfFreedom = degreeOfFreedom;
+ _degreesOfFreedom = degreesOfFreedom;
_scale = scale;
_chol = Cholesky.Create(_scale);
}
@@ -111,10 +111,10 @@ namespace MathNet.Numerics.Distributions
///
/// Checks whether the parameters of the distribution are valid.
///
- /// The degrees of freedom (n) for the Wishart distribution.
+ /// The degrees of freedom (n) for the Wishart distribution.
/// The scale matrix (V) for the Wishart distribution.
/// true when the parameters are valid, false otherwise.
- static bool IsValidParameterSet(double degreeOfFreedom, Matrix scale)
+ static bool IsValidParameterSet(double degreesOfFreedom, Matrix scale)
{
if (scale.RowCount != scale.ColumnCount)
{
@@ -129,7 +129,7 @@ namespace MathNet.Numerics.Distributions
}
}
- if (degreeOfFreedom <= 0.0 || Double.IsNaN(degreeOfFreedom))
+ if (degreesOfFreedom <= 0.0 || Double.IsNaN(degreesOfFreedom))
{
return false;
}
@@ -140,9 +140,9 @@ namespace MathNet.Numerics.Distributions
///
/// Gets or sets the degrees of freedom (n) for the Wishart distribution.
///
- public double DegreeOfFreedom
+ public double DegreesOfFreedom
{
- get { return _degreeOfFreedom; }
+ get { return _degreesOfFreedom; }
set { SetParameters(value, _scale); }
}
@@ -152,7 +152,7 @@ namespace MathNet.Numerics.Distributions
public Matrix Scale
{
get { return _scale; }
- set { SetParameters(_degreeOfFreedom, value); }
+ set { SetParameters(_degreesOfFreedom, value); }
}
///
@@ -161,7 +161,7 @@ namespace MathNet.Numerics.Distributions
/// a string representation of the distribution.
public override string ToString()
{
- return "Wishart(DegreeOfFreedom = " + _degreeOfFreedom + ", Rows = " + _scale.RowCount + ", Columns = " + _scale.ColumnCount + ")";
+ return "Wishart(DegreesOfFreedom = " + _degreesOfFreedom + ", Rows = " + _scale.RowCount + ", Columns = " + _scale.ColumnCount + ")";
}
///
@@ -187,7 +187,7 @@ namespace MathNet.Numerics.Distributions
/// The mean of the distribution.
public Matrix Mean
{
- get { return _degreeOfFreedom*_scale; }
+ get { return _degreesOfFreedom*_scale; }
}
///
@@ -196,7 +196,7 @@ namespace MathNet.Numerics.Distributions
/// The mode of the distribution.
public Matrix Mode
{
- get { return (_degreeOfFreedom - _scale.RowCount - 1.0)*_scale; }
+ get { return (_degreesOfFreedom - _scale.RowCount - 1.0)*_scale; }
}
///
@@ -212,7 +212,7 @@ namespace MathNet.Numerics.Distributions
{
for (var j = 0; j < res.ColumnCount; j++)
{
- res.At(i, j, _degreeOfFreedom*((_scale.At(i, j)*_scale.At(i, j)) + (_scale.At(i, i)*_scale.At(j, j))));
+ res.At(i, j, _degreesOfFreedom*((_scale.At(i, j)*_scale.At(i, j)) + (_scale.At(i, i)*_scale.At(j, j))));
}
}
@@ -242,13 +242,13 @@ namespace MathNet.Numerics.Distributions
var gp = Math.Pow(Constants.Pi, p*(p - 1.0)/4.0);
for (var j = 1; j <= p; j++)
{
- gp *= SpecialFunctions.Gamma((_degreeOfFreedom + 1.0 - j)/2.0);
+ gp *= SpecialFunctions.Gamma((_degreesOfFreedom + 1.0 - j)/2.0);
}
- return Math.Pow(dX, (_degreeOfFreedom - p - 1.0)/2.0)
+ return Math.Pow(dX, (_degreesOfFreedom - p - 1.0)/2.0)
*Math.Exp(-0.5*siX.Trace())
- /Math.Pow(2.0, _degreeOfFreedom*p/2.0)
- /Math.Pow(_chol.Determinant, _degreeOfFreedom/2.0)
+ /Math.Pow(2.0, _degreesOfFreedom*p/2.0)
+ /Math.Pow(_chol.Determinant, _degreesOfFreedom/2.0)
/gp;
}
@@ -261,7 +261,7 @@ namespace MathNet.Numerics.Distributions
/// A random number from this distribution.
public Matrix Sample()
{
- return DoSample(RandomSource, _degreeOfFreedom, _scale, _chol);
+ return DoSample(RandomSource, _degreesOfFreedom, _scale, _chol);
}
///
@@ -271,28 +271,28 @@ namespace MathNet.Numerics.Distributions
/// Applied Statistics, Vol. 21, No. 3 (1972), pp. 341-345
///
/// The random number generator to use.
- /// The degrees of freedom (n) for the Wishart distribution.
+ /// The degrees of freedom (n) for the Wishart distribution.
/// The scale matrix (V) for the Wishart distribution.
/// a sequence of samples from the distribution.
- public static Matrix Sample(System.Random rnd, double degreeOfFreedom, Matrix scale)
+ public static Matrix Sample(System.Random rnd, double degreesOfFreedom, Matrix scale)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(degreeOfFreedom, scale))
+ if (Control.CheckDistributionParameters && !IsValidParameterSet(degreesOfFreedom, scale))
{
throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
}
- return DoSample(rnd, degreeOfFreedom, scale, Cholesky.Create(scale));
+ return DoSample(rnd, degreesOfFreedom, scale, Cholesky.Create(scale));
}
///
/// Samples the distribution.
///
/// The random number generator to use.
- /// The degrees of freedom (n) for the Wishart distribution.
+ /// The degrees of freedom (n) for the Wishart distribution.
/// The scale matrix (V) for the Wishart distribution.
/// The cholesky decomposition to use.
/// a random number from the distribution.
- static Matrix DoSample(System.Random rnd, double degreeOfFreedom, Matrix scale, Cholesky chol)
+ static Matrix DoSample(System.Random rnd, double degreesOfFreedom, Matrix scale, Cholesky chol)
{
var count = scale.RowCount;
@@ -301,7 +301,7 @@ namespace MathNet.Numerics.Distributions
var a = new DenseMatrix(count, count);
for (var d = 0; d < count; d++)
{
- a.At(d, d, Math.Sqrt(Gamma.Sample(rnd, (degreeOfFreedom - d)/2.0, 0.5)));
+ a.At(d, d, Math.Sqrt(Gamma.Sample(rnd, (degreesOfFreedom - d)/2.0, 0.5)));
}
for (var i = 1; i < count; i++)
diff --git a/src/Numerics/Distributions/Zipf.cs b/src/Numerics/Distributions/Zipf.cs
index f62ee110..b648427b 100644
--- a/src/Numerics/Distributions/Zipf.cs
+++ b/src/Numerics/Distributions/Zipf.cs
@@ -247,7 +247,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the probability mass (PMF), i.e. P(X = x).
+ /// Computes the probability mass (PMF) at k, i.e. P(X = k).
///
/// The location in the domain where we want to evaluate the probability mass function.
/// the probability mass at location .
@@ -257,7 +257,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log probability mass (lnPMF), i.e. ln(P(X = x)).
+ /// Computes the log probability mass (lnPMF) at k, i.e. ln(P(X = k)).
///
/// The location in the domain where we want to evaluate the log probability mass function.
/// the log probability mass at location .
@@ -267,7 +267,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution, i.e. P(X <= x).
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X <= x).
///
/// The location at which to compute the cumulative distribution function.
/// the cumulative distribution at location .
@@ -288,7 +288,7 @@ namespace MathNet.Numerics.Distributions
/// The s parameter of the distribution.
/// The n parameter of the distribution.
/// a random number from the Zipf distribution.
- internal static int SampleUnchecked(System.Random rnd, double s, int n)
+ static int SampleUnchecked(System.Random rnd, double s, int n)
{
var r = 0.0;
while (r == 0.0)
@@ -317,7 +317,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public int Sample()
{
- return SampleUnchecked(RandomSource, _s, _n);
+ return SampleUnchecked(_random, _s, _n);
}
///
@@ -328,7 +328,7 @@ namespace MathNet.Numerics.Distributions
{
while (true)
{
- yield return SampleUnchecked(RandomSource, _s, _n);
+ yield return SampleUnchecked(_random, _s, _n);
}
}
diff --git a/src/Numerics/Numerics.csproj b/src/Numerics/Numerics.csproj
index 0adb9ca3..8d56ad46 100644
--- a/src/Numerics/Numerics.csproj
+++ b/src/Numerics/Numerics.csproj
@@ -92,7 +92,7 @@
-
+
diff --git a/src/UnitTests/DistributionTests/Continuous/ChiSquareTests.cs b/src/UnitTests/DistributionTests/Continuous/ChiSquareTests.cs
index 08635927..416530e8 100644
--- a/src/UnitTests/DistributionTests/Continuous/ChiSquareTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/ChiSquareTests.cs
@@ -57,7 +57,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(Double.PositiveInfinity)]
public void CanCreateChiSquare(double dof)
{
- var n = new ChiSquare(dof);
+ var n = new ChiSquared(dof);
Assert.AreEqual(dof, n.DegreesOfFreedom);
}
@@ -72,7 +72,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(Double.NaN)]
public void ChiSquareCreateFailsWithBadParameters(double dof)
{
- Assert.Throws(() => new ChiSquare(dof));
+ Assert.Throws(() => new ChiSquared(dof));
}
///
@@ -81,8 +81,8 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void ValidateToString()
{
- var n = new ChiSquare(1.0);
- Assert.AreEqual("ChiSquare(DoF = 1)", n.ToString());
+ var n = new ChiSquared(1.0);
+ Assert.AreEqual("ChiSquared(k = 1)", n.ToString());
}
///
@@ -95,7 +95,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(Double.PositiveInfinity)]
public void CanSetDoF(double dof)
{
- new ChiSquare(1.0)
+ new ChiSquared(1.0)
{
DegreesOfFreedom = dof
};
@@ -110,7 +110,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(0.0)]
public void SetDofFailsWithNonPositiveDoF(double dof)
{
- var n = new ChiSquare(1.0);
+ var n = new ChiSquared(1.0);
Assert.Throws(() => n.DegreesOfFreedom = dof);
}
@@ -125,7 +125,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(Double.PositiveInfinity)]
public void ValidateMean(double dof)
{
- var n = new ChiSquare(dof);
+ var n = new ChiSquared(dof);
Assert.AreEqual(dof, n.Mean);
}
@@ -140,7 +140,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(Double.PositiveInfinity)]
public void ValidateVariance(double dof)
{
- var n = new ChiSquare(dof);
+ var n = new ChiSquared(dof);
Assert.AreEqual(2 * dof, n.Variance);
}
@@ -155,7 +155,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(Double.PositiveInfinity)]
public void ValidateStdDev(double dof)
{
- var n = new ChiSquare(dof);
+ var n = new ChiSquared(dof);
Assert.AreEqual(Math.Sqrt(n.Variance), n.StdDev);
}
@@ -170,7 +170,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(Double.PositiveInfinity)]
public void ValidateMode(double dof)
{
- var n = new ChiSquare(dof);
+ var n = new ChiSquared(dof);
Assert.AreEqual(dof - 2, n.Mode);
}
@@ -185,7 +185,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(Double.PositiveInfinity)]
public void ValidateMedian(double dof)
{
- var n = new ChiSquare(dof);
+ var n = new ChiSquared(dof);
Assert.AreEqual(dof - (2.0 / 3.0), n.Median);
}
@@ -195,7 +195,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void ValidateMinimum()
{
- var n = new ChiSquare(1.0);
+ var n = new ChiSquared(1.0);
Assert.AreEqual(0.0, n.Minimum);
}
@@ -205,7 +205,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void ValidateMaximum()
{
- var n = new ChiSquare(1.0);
+ var n = new ChiSquared(1.0);
Assert.AreEqual(Double.PositiveInfinity, n.Maximum);
}
@@ -240,7 +240,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(Double.PositiveInfinity, Double.PositiveInfinity)]
public void ValidateDensity(double dof, double x)
{
- var n = new ChiSquare(dof);
+ var n = new ChiSquared(dof);
Assert.AreEqual((Math.Pow(x, (dof / 2.0) - 1.0) * Math.Exp(-x / 2.0)) / (Math.Pow(2.0, dof / 2.0) * SpecialFunctions.Gamma(dof / 2.0)), n.Density(x));
}
@@ -275,7 +275,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(Double.PositiveInfinity, Double.PositiveInfinity)]
public void ValidateDensityLn(double dof, double x)
{
- var n = new ChiSquare(dof);
+ var n = new ChiSquared(dof);
Assert.AreEqual((-x / 2.0) + (((dof / 2.0) - 1.0) * Math.Log(x)) - ((dof / 2.0) * Math.Log(2)) - SpecialFunctions.GammaLn(dof / 2.0), n.DensityLn(x));
}
@@ -285,7 +285,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void CanSampleStatic()
{
- ChiSquare.Sample(new Random(), 2.0);
+ ChiSquared.Sample(new Random(), 2.0);
}
///
@@ -294,7 +294,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void FailSampleStatic()
{
- Assert.Throws(() => ChiSquare.Sample(new Random(), -1.0));
+ Assert.Throws(() => ChiSquared.Sample(new Random(), -1.0));
}
///
@@ -303,7 +303,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void CanSample()
{
- var n = new ChiSquare(1.0);
+ var n = new ChiSquared(1.0);
n.Sample();
}
@@ -313,7 +313,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void CanSampleSequence()
{
- var n = new ChiSquare(1.0);
+ var n = new ChiSquared(1.0);
var ied = n.Samples();
ied.Take(5).ToArray();
}
@@ -349,7 +349,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(Double.PositiveInfinity, Double.PositiveInfinity)]
public void ValidateCumulativeDistribution(double dof, double x)
{
- var n = new ChiSquare(dof);
+ var n = new ChiSquared(dof);
Assert.AreEqual(SpecialFunctions.GammaLowerIncomplete(dof / 2.0, x / 2.0) / SpecialFunctions.Gamma(dof / 2.0), n.CumulativeDistribution(x));
}
}
diff --git a/src/UnitTests/DistributionTests/Continuous/ChiTests.cs b/src/UnitTests/DistributionTests/Continuous/ChiTests.cs
index da700fe9..47b42ca9 100644
--- a/src/UnitTests/DistributionTests/Continuous/ChiTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/ChiTests.cs
@@ -80,7 +80,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void ValidateToString()
{
var n = new Chi(1.0);
- Assert.AreEqual("Chi(DoF = 1)", n.ToString());
+ Assert.AreEqual("Chi(k = 1)", n.ToString());
}
///
diff --git a/src/UnitTests/DistributionTests/Continuous/ErlangTests.cs b/src/UnitTests/DistributionTests/Continuous/ErlangTests.cs
index d934b075..786b4e6a 100644
--- a/src/UnitTests/DistributionTests/Continuous/ErlangTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/ErlangTests.cs
@@ -122,7 +122,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void ValidateToString()
{
var n = new Erlang(1, 2d);
- Assert.AreEqual("Erlang(Shape = 1, λ = 2)", n.ToString());
+ Assert.AreEqual("Erlang(k = 1, λ = 2)", n.ToString());
}
///
diff --git a/src/UnitTests/DistributionTests/Continuous/FisherSnedecorTests.cs b/src/UnitTests/DistributionTests/Continuous/FisherSnedecorTests.cs
index 2646fbfc..a83410e9 100644
--- a/src/UnitTests/DistributionTests/Continuous/FisherSnedecorTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/FisherSnedecorTests.cs
@@ -66,8 +66,8 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void CanCreateFisherSnedecor(double d1, double d2)
{
var n = new FisherSnedecor(d1, d2);
- Assert.AreEqual(d1, n.DegreeOfFreedom1);
- Assert.AreEqual(d2, n.DegreeOfFreedom2);
+ Assert.AreEqual(d1, n.DegreesOfFreedom1);
+ Assert.AreEqual(d2, n.DegreesOfFreedom2);
}
///
@@ -102,8 +102,8 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void ValidateToString()
{
- var n = new FisherSnedecor(2.0, 1.0);
- Assert.AreEqual("FisherSnedecor(DegreeOfFreedom1 = 2, DegreeOfFreedom2 = 1)", n.ToString());
+ var n = new FisherSnedecor(2d, 1d);
+ Assert.AreEqual("FisherSnedecor(d1 = 2, d2 = 1)", n.ToString());
}
///
@@ -114,11 +114,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(1.0)]
[TestCase(10.0)]
[TestCase(Double.PositiveInfinity)]
- public void CanSetDegreeOfFreedom1(double d1)
+ public void CanSetDegreesOfFreedom1(double d1)
{
new FisherSnedecor(1.0, 2.0)
{
- DegreeOfFreedom1 = d1
+ DegreesOfFreedom1 = d1
};
}
@@ -126,10 +126,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
/// Set degree of freedom 1 fails with negative value.
///
[Test]
- public void SetDegreeOfFreedom1FailsWithNegativeDegreeOfFreedom()
+ public void SetDegreesOfFreedom1FailsWithNegativeDegreeOfFreedom()
{
var n = new FisherSnedecor(1.0, 2.0);
- Assert.Throws(() => n.DegreeOfFreedom1 = -1.0);
+ Assert.Throws(() => n.DegreesOfFreedom1 = -1.0);
}
///
@@ -140,11 +140,11 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(1.0)]
[TestCase(10.0)]
[TestCase(Double.PositiveInfinity)]
- public void CanSetDegreeOfFreedom2(double d2)
+ public void CanSetDegreesOfFreedom2(double d2)
{
new FisherSnedecor(1.0, 2.0)
{
- DegreeOfFreedom2 = d2
+ DegreesOfFreedom2 = d2
};
}
@@ -152,10 +152,10 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
/// Set degree of freedom 2 fails with negative value.
///
[Test]
- public void SetDegreeOfFreedom2FailsWithNegativeDegreeOfFreedom()
+ public void SetDegreesOfFreedom2FailsWithNegativeDegreeOfFreedom()
{
var n = new FisherSnedecor(1.0, 2.0);
- Assert.Throws(() => n.DegreeOfFreedom2 = -1.0);
+ Assert.Throws(() => n.DegreesOfFreedom2 = -1.0);
}
///
diff --git a/src/UnitTests/DistributionTests/Continuous/StudentTTests.cs b/src/UnitTests/DistributionTests/Continuous/StudentTTests.cs
index 8448ef2f..22d19b02 100644
--- a/src/UnitTests/DistributionTests/Continuous/StudentTTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/StudentTTests.cs
@@ -1,4 +1,4 @@
-//
+//
// Math.NET Numerics, part of the Math.NET Project
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
@@ -100,7 +100,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void ValidateToString()
{
var n = new StudentT(1.0, 2.0, 1.0);
- Assert.AreEqual("StudentT(Location = 1, Scale = 2, DoF = 1)", n.ToString());
+ Assert.AreEqual("StudentT(μ = 1, σ = 2, ν = 1)", n.ToString());
}
///
diff --git a/src/UnitTests/DistributionTests/Discrete/ConwayMaxwellPoissonTests.cs b/src/UnitTests/DistributionTests/Discrete/ConwayMaxwellPoissonTests.cs
index bc0a2b69..43b5c113 100644
--- a/src/UnitTests/DistributionTests/Discrete/ConwayMaxwellPoissonTests.cs
+++ b/src/UnitTests/DistributionTests/Discrete/ConwayMaxwellPoissonTests.cs
@@ -50,7 +50,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
/// Can create ConwayMaxwellPoisson.
///
/// Lambda value.
- /// DegreeOfFreedom parameter.
+ /// DegreesOfFreedom parameter.
[TestCase(0.1, 0.0)]
[TestCase(1.0, 2.5)]
[TestCase(2.5, 3.0)]
@@ -99,9 +99,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
}
///
- /// Can set DegreeOfFreedom.
+ /// Can set DegreesOfFreedom.
///
- /// DegreeOfFreedom parameter.
+ /// DegreesOfFreedom parameter.
[TestCase(0.0)]
[TestCase(3.0)]
[TestCase(10.0)]
@@ -129,9 +129,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
}
///
- /// Set DegreeOfFreedom with bad values fails.
+ /// Set DegreesOfFreedom with bad values fails.
///
- /// DegreeOfFreedom parameter.
+ /// DegreesOfFreedom parameter.
[TestCase(-0.1)]
[TestCase(-1.0)]
[TestCase(-10.0)]
@@ -186,7 +186,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
/// Validate mean.
///
/// Lambda value.
- /// DegreeOfFreedom parameter.
+ /// DegreesOfFreedom parameter.
/// Expected value.
[TestCase(1, 1, 1.0)]
[TestCase(2, 1, 2.0)]
@@ -224,7 +224,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
/// Validate probability.
///
/// Lambda value.
- /// DegreeOfFreedom parameter.
+ /// DegreesOfFreedom parameter.
/// Input X value.
/// Expected value.
[TestCase(1.0, 1.0, 1, 0.367879441171442)]
@@ -243,7 +243,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
/// Validate probability log.
///
/// Lambda value.
- /// DegreeOfFreedom parameter.
+ /// DegreesOfFreedom parameter.
/// Input X value.
/// Expected value.
[TestCase(1.0, 1.0, 1, -1.0)]
@@ -283,7 +283,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
/// Validate cumulative distribution.
///
/// Lambda value.
- /// DegreeOfFreedom parameter.
+ /// DegreesOfFreedom parameter.
/// Input X value.
/// Expected value.
[TestCase(1.0, 1.0, 1, 0.735758882342885)]
diff --git a/src/UnitTests/DistributionTests/Multivariate/InverseWishartTests.cs b/src/UnitTests/DistributionTests/Multivariate/InverseWishartTests.cs
index 28677e8c..96447ab0 100644
--- a/src/UnitTests/DistributionTests/Multivariate/InverseWishartTests.cs
+++ b/src/UnitTests/DistributionTests/Multivariate/InverseWishartTests.cs
@@ -50,7 +50,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
///
/// Can create inverse Wishart.
///
- /// DegreeOfFreedom parameter.
+ /// DegreesOfFreedom parameter.
/// Scale matrix order.
[TestCase(0.1, 2)]
[TestCase(1.0, 5)]
@@ -60,7 +60,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
var matrix = MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(order);
var d = new InverseWishart(nu, matrix);
- Assert.AreEqual(nu, d.DegreeOfFreedom);
+ Assert.AreEqual(nu, d.DegreesOfFreedom);
for (var i = 0; i < d.Scale.RowCount; i++)
{
for (var j = 0; j < d.Scale.ColumnCount; j++)
@@ -73,7 +73,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
///
/// Fail create inverse Wishart with bad parameters.
///
- /// DegreeOfFreedom parameter.
+ /// DegreesOfFreedom parameter.
/// Scale matrix order.
[TestCase(0.1, 2)]
[TestCase(1.0, 5)]
@@ -89,7 +89,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
///
/// Fail create inverse Wishart with bad parameters.
///
- /// DegreeOfFreedom parameter.
+ /// DegreesOfFreedom parameter.
/// Scale matrix order.
[TestCase(-1.0, 2)]
[TestCase(Double.NaN, 5)]
@@ -149,13 +149,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
public void CanGetNu(double nu)
{
var d = new InverseWishart(nu, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(2));
- Assert.AreEqual(nu, d.DegreeOfFreedom);
+ Assert.AreEqual(nu, d.DegreesOfFreedom);
}
///
- /// Can set DegreeOfFreedom.
+ /// Can set DegreesOfFreedom.
///
- /// DegreeOfFreedom parameter.
+ /// DegreesOfFreedom parameter.
[TestCase(1.0)]
[TestCase(2.0)]
[TestCase(5.0)]
@@ -163,7 +163,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
{
new InverseWishart(1.0, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(2))
{
- DegreeOfFreedom = nu
+ DegreesOfFreedom = nu
};
}
@@ -201,7 +201,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
///
/// Validate mean.
///
- /// DegreeOfFreedom parameter.
+ /// DegreesOfFreedom parameter.
/// Scale matrix order.
[TestCase(0.1, 2)]
[TestCase(1.0, 5)]
@@ -223,7 +223,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
///
/// Validate mode.
///
- /// DegreeOfFreedom parameter.
+ /// DegreesOfFreedom parameter.
/// Scale matrix order.
[TestCase(0.1, 2)]
[TestCase(1.0, 5)]
@@ -245,7 +245,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
///
/// Validate variance.
///
- /// DegreeOfFreedom parameter.
+ /// DegreesOfFreedom parameter.
/// Scale matrix order.
[TestCase(0.1, 2)]
[TestCase(1.0, 5)]
@@ -269,7 +269,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
///
/// Validate density.
///
- /// DegreeOfFreedom parameter.
+ /// DegreesOfFreedom parameter.
/// Expected value.
[TestCase(1.0, 0.03228684517430723)]
[TestCase(2.0, 0.018096748360719193)]
diff --git a/src/UnitTests/DistributionTests/Multivariate/WishartTests.cs b/src/UnitTests/DistributionTests/Multivariate/WishartTests.cs
index 9708b26c..b7387841 100644
--- a/src/UnitTests/DistributionTests/Multivariate/WishartTests.cs
+++ b/src/UnitTests/DistributionTests/Multivariate/WishartTests.cs
@@ -50,7 +50,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
///
/// Can create wishart.
///
- /// DegreeOfFreedom parameter.
+ /// DegreesOfFreedom parameter.
/// Scale matrix order.
[TestCase(0.1, 2)]
[TestCase(1.0, 5)]
@@ -61,7 +61,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
var d = new Wishart(nu, matrix);
- Assert.AreEqual(nu, d.DegreeOfFreedom);
+ Assert.AreEqual(nu, d.DegreesOfFreedom);
for (var i = 0; i < d.Scale.RowCount; i++)
{
for (var j = 0; j < d.Scale.ColumnCount; j++)
@@ -74,7 +74,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
///
/// Fail create Wishart with bad parameters.
///
- /// DegreeOfFreedom parameter.
+ /// DegreesOfFreedom parameter.
/// Scale matrix order.
[TestCase(0.0, 2)]
[TestCase(0.1, 5)]
@@ -91,7 +91,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
///
/// Fail create Wishart with bad parameters.
///
- /// DegreeOfFreedom parameter.
+ /// DegreesOfFreedom parameter.
/// Scale matrix order.
[TestCase(-1.0, 2)]
[TestCase(Double.NaN, 5)]
@@ -140,26 +140,26 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
public void ValidateToString()
{
var d = new Wishart(1.0, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(2));
- Assert.AreEqual("Wishart(DegreeOfFreedom = 1, Rows = 2, Columns = 2)", d.ToString());
+ Assert.AreEqual("Wishart(DegreesOfFreedom = 1, Rows = 2, Columns = 2)", d.ToString());
}
///
- /// Can get DegreeOfFreedom.
+ /// Can get DegreesOfFreedom.
///
- /// DegreeOfFreedom parameter.
+ /// DegreesOfFreedom parameter.
[TestCase(1.0)]
[TestCase(2.0)]
[TestCase(5.0)]
public void CanGetNu(double nu)
{
var d = new Wishart(nu, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(2));
- Assert.AreEqual(nu, d.DegreeOfFreedom);
+ Assert.AreEqual(nu, d.DegreesOfFreedom);
}
///
- /// Can set DegreeOfFreedom.
+ /// Can set DegreesOfFreedom.
///
- /// DegreeOfFreedom parameter.
+ /// DegreesOfFreedom parameter.
[TestCase(1.0)]
[TestCase(2.0)]
[TestCase(5.0)]
@@ -167,7 +167,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
{
new Wishart(1.0, MatrixLoader.GenerateRandomPositiveDefiniteDenseMatrix(2))
{
- DegreeOfFreedom = nu
+ DegreesOfFreedom = nu
};
}
@@ -205,7 +205,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
///
/// Validate mean.
///
- /// DegreeOfFreedom parameter.
+ /// DegreesOfFreedom parameter.
/// Scale matrix order.
[TestCase(0.1, 2)]
[TestCase(1.0, 5)]
@@ -227,7 +227,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
///
/// Validate mode.
///
- /// DegreeOfFreedom parameter.
+ /// DegreesOfFreedom parameter.
/// Scale matrix order.
[TestCase(0.1, 2)]
[TestCase(1.0, 5)]
@@ -249,7 +249,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
///
/// Validate variance.
///
- /// DegreeOfFreedom parameter.
+ /// DegreesOfFreedom parameter.
/// Scale matrix order.
[TestCase(0.1, 2)]
[TestCase(1.0, 5)]
@@ -271,7 +271,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
///
/// Validate density.
///
- /// DegreeOfFreedom parameter.
+ /// DegreesOfFreedom parameter.
/// Expected value.
[TestCase(1.0, 0.014644982561926487)]
[TestCase(2.0, 0.041042499311949421)]