diff --git a/.gitattributes b/.gitattributes
index 2a674dba..24130e53 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -7,6 +7,7 @@
*.xml text
*.js text
*.ps1 text
+*.DotSettings text
*.csproj text merge=union
*.fsproj text merge=union
diff --git a/MathNet.Numerics.sln.DotSettings b/MathNet.Numerics.sln.DotSettings
index 857c5d9e..e3609001 100644
--- a/MathNet.Numerics.sln.DotSettings
+++ b/MathNet.Numerics.sln.DotSettings
@@ -54,6 +54,7 @@ OTHER DEALINGS IN THE SOFTWARE.
MC
MCMC
MSE
+ PDF
QR
SAD
SAS
diff --git a/src/Numerics/Distributions/Bernoulli.cs b/src/Numerics/Distributions/Bernoulli.cs
index 952a649d..27e1aac6 100644
--- a/src/Numerics/Distributions/Bernoulli.cs
+++ b/src/Numerics/Distributions/Bernoulli.cs
@@ -97,7 +97,7 @@ namespace MathNet.Numerics.Distributions
/// Sets the parameters of the distribution after checking their validity.
///
/// The probability of generating a one.
- /// When the parameters don't pass the function.
+ /// When the parameters are out of range.
void SetParameters(double p)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(p))
@@ -234,7 +234,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution at x, 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/Beta.cs b/src/Numerics/Distributions/Beta.cs
index 87e06dd8..62820dc6 100644
--- a/src/Numerics/Distributions/Beta.cs
+++ b/src/Numerics/Distributions/Beta.cs
@@ -108,7 +108,7 @@ namespace MathNet.Numerics.Distributions
///
/// The α shape parameter of the Beta distribution.
/// The β shape parameter of the Beta distribution.
- /// When the parameters don't pass the function.
+ /// When the parameters are out of range.
void SetParameters(double a, double b)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(a, b))
@@ -346,7 +346,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. ∂P(X ≤ x)/∂x.
///
/// The location at which to compute the density.
/// the density at .
@@ -402,7 +402,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(∂P(X ≤ x)/∂x).
///
/// 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 at x, 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/Binomial.cs b/src/Numerics/Distributions/Binomial.cs
index a69f5cbc..03f3f494 100644
--- a/src/Numerics/Distributions/Binomial.cs
+++ b/src/Numerics/Distributions/Binomial.cs
@@ -325,7 +325,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution at x, 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/Categorical.cs b/src/Numerics/Distributions/Categorical.cs
index 0e27f8d7..3e917ec8 100644
--- a/src/Numerics/Distributions/Categorical.cs
+++ b/src/Numerics/Distributions/Categorical.cs
@@ -166,7 +166,7 @@ namespace MathNet.Numerics.Distributions
///
/// An array of nonnegative ratios: this array does not need to be normalized
/// as this is often impossible using floating point arithmetic.
- /// When the parameters don't pass the function.
+ /// When the parameters are out of range.
void SetParameters(double[] p)
{
if (Control.CheckDistributionParameters && !IsValidProbabilityMass(p))
@@ -325,7 +325,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution at x, 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/Cauchy.cs b/src/Numerics/Distributions/Cauchy.cs
index 4d5a095c..bccd6f88 100644
--- a/src/Numerics/Distributions/Cauchy.cs
+++ b/src/Numerics/Distributions/Cauchy.cs
@@ -104,7 +104,7 @@ namespace MathNet.Numerics.Distributions
///
/// The location (x0) of the distribution.
/// The scale (γ) of the distribution. Must be greater than 0.
- /// When the parameters don't pass the function.
+ /// When the parameters are out of range.
void SetParameters(double location, double scale)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(location, scale))
@@ -216,7 +216,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. ∂P(X ≤ x)/∂x.
///
/// The location at which to compute the density.
/// the density at .
@@ -226,7 +226,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(∂P(X ≤ x)/∂x).
///
/// 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 at x, 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/Chi.cs b/src/Numerics/Distributions/Chi.cs
index 8ffc6f4e..3e82b5ba 100644
--- a/src/Numerics/Distributions/Chi.cs
+++ b/src/Numerics/Distributions/Chi.cs
@@ -96,7 +96,7 @@ namespace MathNet.Numerics.Distributions
/// Sets the parameters of the distribution after checking their validity.
///
/// The degrees of freedom for the Chi distribution.
- /// When the parameters don't pass the function.
+ /// When the parameters are out of range.
void SetParameters(double freedom)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(freedom))
@@ -210,7 +210,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. ∂P(X ≤ x)/∂x.
///
/// The location at which to compute the density.
/// the density at .
@@ -220,7 +220,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(∂P(X ≤ x)/∂x).
///
/// 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 at x, 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/ChiSquared.cs b/src/Numerics/Distributions/ChiSquared.cs
index 37e7c53b..b792af99 100644
--- a/src/Numerics/Distributions/ChiSquared.cs
+++ b/src/Numerics/Distributions/ChiSquared.cs
@@ -94,7 +94,7 @@ namespace MathNet.Numerics.Distributions
/// Sets the parameters of the distribution after checking their validity.
///
/// The degrees of freedom (k) of the distribution.
- /// When the parameters don't pass the function.
+ /// When the parameters are out of range.
void SetParameters(double freedom)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(freedom))
@@ -196,7 +196,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. ∂P(X ≤ x)/∂x.
///
/// The location at which to compute the density.
/// the density at .
@@ -206,7 +206,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(∂P(X ≤ x)/∂x).
///
/// 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 at x, 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/ContinuousUniform.cs b/src/Numerics/Distributions/ContinuousUniform.cs
index 88f08ee1..4dc046d7 100644
--- a/src/Numerics/Distributions/ContinuousUniform.cs
+++ b/src/Numerics/Distributions/ContinuousUniform.cs
@@ -1,4 +1,4 @@
-//
+//
// Math.NET Numerics, part of the Math.NET Project
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
@@ -108,7 +108,7 @@ namespace MathNet.Numerics.Distributions
///
/// Lower bound.
/// Upper bound; must be at least as large as .
- /// When the parameters don't pass the function.
+ /// When the parameters are out of range.
void SetParameters(double lower, double upper)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(lower, upper))
@@ -223,7 +223,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. ∂P(X ≤ x)/∂x.
///
/// The location at which to compute the density.
/// the density at .
@@ -238,7 +238,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(∂P(X ≤ x)/∂x).
///
/// 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 at x, 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/ConwayMaxwellPoisson.cs b/src/Numerics/Distributions/ConwayMaxwellPoisson.cs
index 18175ce3..19bcf8ad 100644
--- a/src/Numerics/Distributions/ConwayMaxwellPoisson.cs
+++ b/src/Numerics/Distributions/ConwayMaxwellPoisson.cs
@@ -127,7 +127,7 @@ namespace MathNet.Numerics.Distributions
///
/// The lambda (λ) parameter.
/// The rate of decay (ν) parameter.
- /// When the parameters don't pass the function.
+ /// When the parameters are out of range.
void SetParameters(double lambda, double nu)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(lambda, nu))
@@ -366,7 +366,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution at x, 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/Dirichlet.cs b/src/Numerics/Distributions/Dirichlet.cs
index bf7fe599..98151366 100644
--- a/src/Numerics/Distributions/Dirichlet.cs
+++ b/src/Numerics/Distributions/Dirichlet.cs
@@ -153,7 +153,7 @@ namespace MathNet.Numerics.Distributions
/// Sets the parameters of the distribution after checking their validity.
///
/// The parameters of the Dirichlet distribution.
- /// When the parameters don't pass the function.
+ /// When the parameters are out of range.
void SetParameters(double[] alpha)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(alpha))
diff --git a/src/Numerics/Distributions/DiscreteUniform.cs b/src/Numerics/Distributions/DiscreteUniform.cs
index e5e1a491..94f5de18 100644
--- a/src/Numerics/Distributions/DiscreteUniform.cs
+++ b/src/Numerics/Distributions/DiscreteUniform.cs
@@ -102,7 +102,7 @@ namespace MathNet.Numerics.Distributions
///
/// Lower bound.
/// Upper bound; must be at least as large as .
- /// When the parameters don't pass the function.
+ /// When the parameters are out of range.
void SetParameters(int lower, int upper)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(lower, upper))
@@ -244,7 +244,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution at x, 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/Erlang.cs b/src/Numerics/Distributions/Erlang.cs
index a13a9cb9..0798664c 100644
--- a/src/Numerics/Distributions/Erlang.cs
+++ b/src/Numerics/Distributions/Erlang.cs
@@ -124,6 +124,7 @@ namespace MathNet.Numerics.Distributions
///
/// The shape (k) of the Erlang distribution.
/// The rate or inverse scale (λ) of the Erlang distribution.
+ /// When the parameters are out of range.
void SetParameters(double shape, double rate)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(shape, rate))
@@ -335,7 +336,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. ∂P(X ≤ x)/∂x.
///
/// The location at which to compute the density.
/// the density at .
@@ -360,7 +361,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(∂P(X ≤ x)/∂x).
///
/// The location at which to compute the log density.
/// the log density at .
@@ -385,7 +386,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution at x, 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/Exponential.cs b/src/Numerics/Distributions/Exponential.cs
index a05f1d53..1ea2171e 100644
--- a/src/Numerics/Distributions/Exponential.cs
+++ b/src/Numerics/Distributions/Exponential.cs
@@ -94,7 +94,7 @@ namespace MathNet.Numerics.Distributions
/// Sets the parameters of the distribution after checking their validity.
///
/// The rate (λ) parameter of the Exponential distribution.
- /// When the parameters don't pass the function.
+ /// When the parameters are out of range.
void SetParameters(double rate)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(rate))
@@ -196,7 +196,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. ∂P(X ≤ x)/∂x.
///
/// The location at which to compute the density.
/// the density at .
@@ -211,7 +211,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(∂P(X ≤ x)/∂x).
///
/// 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 at x, 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/FisherSnedecor.cs b/src/Numerics/Distributions/FisherSnedecor.cs
index 7e9b3abd..a40c210c 100644
--- a/src/Numerics/Distributions/FisherSnedecor.cs
+++ b/src/Numerics/Distributions/FisherSnedecor.cs
@@ -99,6 +99,7 @@ namespace MathNet.Numerics.Distributions
///
/// The first degree of freedom (d1) of the distribution.
/// The second degree of freedom (d2) of the distribution.
+ /// When the parameters are out of range.
void SetParameters(double d1, double d2)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(d1, d2))
@@ -242,7 +243,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. ∂P(X ≤ x)/∂x.
///
/// The location at which to compute the density.
/// the density at .
@@ -252,7 +253,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(∂P(X ≤ x)/∂x).
///
/// The location at which to compute the log density.
/// the log density at .
@@ -262,7 +263,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution at x, 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/Gamma.cs b/src/Numerics/Distributions/Gamma.cs
index 84662304..e1a6364e 100644
--- a/src/Numerics/Distributions/Gamma.cs
+++ b/src/Numerics/Distributions/Gamma.cs
@@ -129,7 +129,7 @@ namespace MathNet.Numerics.Distributions
///
/// The shape (k, α) of the Gamma distribution.
/// The rate or inverse scale (β) of the Gamma distribution.
- /// When the parameters don't pass the function.
+ /// When the parameters are out of range.
void SetParameters(double shape, double rate)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(shape, rate))
@@ -336,7 +336,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. ∂P(X ≤ x)/∂x.
///
/// The location at which to compute the density.
/// the density at .
@@ -361,7 +361,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(∂P(X ≤ x)/∂x).
///
/// 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 at x, 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/Geometric.cs b/src/Numerics/Distributions/Geometric.cs
index d6170c56..f3b3fbfa 100644
--- a/src/Numerics/Distributions/Geometric.cs
+++ b/src/Numerics/Distributions/Geometric.cs
@@ -99,7 +99,7 @@ namespace MathNet.Numerics.Distributions
/// Sets the parameters of the distribution after checking their validity.
///
/// The probability of generating a one.
- /// When the parameters don't pass the function.
+ /// When the parameters are out of range.
void SetParameters(double p)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(p))
@@ -232,7 +232,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution at x, 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/Hypergeometric.cs b/src/Numerics/Distributions/Hypergeometric.cs
index 59c210c4..fa0dfb6c 100644
--- a/src/Numerics/Distributions/Hypergeometric.cs
+++ b/src/Numerics/Distributions/Hypergeometric.cs
@@ -109,6 +109,7 @@ namespace MathNet.Numerics.Distributions
/// The size of the population (N).
/// The number successes within the population (K, M).
/// The number of draws without replacement (n).
+ /// When the parameters are out of range.
void SetParameters(int population, int success, int draws)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(population, success, draws))
@@ -280,7 +281,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution at x, 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/IContinuousDistribution.cs b/src/Numerics/Distributions/IContinuousDistribution.cs
index b72e53d7..3f496795 100644
--- a/src/Numerics/Distributions/IContinuousDistribution.cs
+++ b/src/Numerics/Distributions/IContinuousDistribution.cs
@@ -59,14 +59,14 @@ namespace MathNet.Numerics.Distributions
double Maximum { get; }
///
- /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. ∂P(X ≤ x)/∂x.
///
/// The location at which to compute the density.
/// the density at .
double Density(double x);
///
- /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(∂P(X ≤ x)/∂x).
///
/// The location at which to compute the log density.
/// the log density at .
diff --git a/src/Numerics/Distributions/IUnivariateDistribution.cs b/src/Numerics/Distributions/IUnivariateDistribution.cs
index 10f08ccc..df481737 100644
--- a/src/Numerics/Distributions/IUnivariateDistribution.cs
+++ b/src/Numerics/Distributions/IUnivariateDistribution.cs
@@ -63,7 +63,7 @@ namespace MathNet.Numerics.Distributions
double Skewness { get; }
///
- /// Computes the cumulative distribution (CDF) of the distribution at x, 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 4430c105..55b5eb39 100644
--- a/src/Numerics/Distributions/InverseGamma.cs
+++ b/src/Numerics/Distributions/InverseGamma.cs
@@ -100,7 +100,7 @@ namespace MathNet.Numerics.Distributions
///
/// The shape (α) of the inverse Gamma distribution.
/// The scale (β) of the inverse Gamma distribution.
- /// When the parameters don't pass the function.
+ /// When the parameters are out of range.
void SetParameters(double shape, double scale)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(shape, scale))
@@ -237,7 +237,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. ∂P(X ≤ x)/∂x.
///
/// The location at which to compute the density.
/// the density at .
@@ -252,7 +252,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(∂P(X ≤ x)/∂x).
///
/// 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 at x, 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/InverseWishart.cs b/src/Numerics/Distributions/InverseWishart.cs
index b5bbc8b0..eb98786f 100644
--- a/src/Numerics/Distributions/InverseWishart.cs
+++ b/src/Numerics/Distributions/InverseWishart.cs
@@ -119,7 +119,7 @@ namespace MathNet.Numerics.Distributions
///
/// 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.
+ /// When the parameters are out of range.
void SetParameters(double degreesOfFreedom, Matrix scale)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(degreesOfFreedom, scale))
diff --git a/src/Numerics/Distributions/Laplace.cs b/src/Numerics/Distributions/Laplace.cs
index 35a78f67..d5a2833e 100644
--- a/src/Numerics/Distributions/Laplace.cs
+++ b/src/Numerics/Distributions/Laplace.cs
@@ -111,7 +111,7 @@ namespace MathNet.Numerics.Distributions
///
/// The location (μ) of the Laplace distribution.
/// The scale (b) of the Laplace distribution.
- /// When the parameters don't pass the function.
+ /// When the parameters are out of range.
void SetParameters(double location, double scale)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(location, scale))
@@ -223,7 +223,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. ∂P(X ≤ x)/∂x.
///
/// The location at which to compute the density.
/// the density at .
@@ -233,7 +233,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(∂P(X ≤ x)/∂x).
///
/// 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 at x, 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/LogNormal.cs b/src/Numerics/Distributions/LogNormal.cs
index e8c11fd7..a827ecbd 100644
--- a/src/Numerics/Distributions/LogNormal.cs
+++ b/src/Numerics/Distributions/LogNormal.cs
@@ -59,7 +59,7 @@ namespace MathNet.Numerics.Distributions
/// random number generator.
///
/// The log-scale (μ) of the logarithm of the distribution.
- /// The shape (σ) of the logarithm of the distribution.
+ /// The shape (σ) of the logarithm of the distribution. Range: σ ≥ 0.
public LogNormal(double mu, double sigma)
{
_random = new System.Random();
@@ -72,7 +72,7 @@ namespace MathNet.Numerics.Distributions
/// random number generator.
///
/// The log-scale (μ) of the distribution.
- /// The shape (σ) of the distribution.
+ /// The shape (σ) of the distribution. Range: σ ≥ 0.
/// The random number generator which is used to draw random samples.
public LogNormal(double mu, double sigma, System.Random randomSource)
{
@@ -81,25 +81,40 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Constructs a log-normal distribution with the desired mean and variance. The distribution will
- /// be initialized with the default random number generator.
+ /// Constructs a log-normal distribution with the desired mu and sigma parameters.
+ ///
+ /// The log-scale (μ) of the distribution.
+ /// The shape (σ) of the distribution. Range: σ ≥ 0.
+ /// The random number generator which is used to draw random samples. Optional, can be null.
+ /// A log-normal distribution.
+ public static LogNormal WithMuSigma(double mu, double sigma, System.Random randomSource = null)
+ {
+ return new LogNormal(mu, sigma, randomSource);
+ }
+
+ ///
+ /// Constructs a log-normal distribution with the desired mean and variance.
///
/// The mean of the log-normal distribution.
/// The variance of the log-normal distribution.
- /// a log-normal distribution.
- public static LogNormal WithMeanVariance(double mean, double var)
+ /// The random number generator which is used to draw random samples. Optional, can be null.
+ /// A log-normal distribution.
+ public static LogNormal WithMeanVariance(double mean, double var, System.Random randomSource = null)
{
var sigma2 = Math.Log(var/(mean*mean) + 1.0);
- return new LogNormal(Math.Log(mean) - sigma2/2.0, Math.Sqrt(sigma2));
+ return new LogNormal(Math.Log(mean) - sigma2 / 2.0, Math.Sqrt(sigma2), randomSource);
}
///
/// Estimates the log-normal distribution parameters from sample data with maximum-likelihood.
///
- public static LogNormal Estimate(IEnumerable samples)
+ /// The samples to estimate the distribution parameters from.
+ /// The random number generator which is used to draw random samples. Optional, can be null.
+ /// A log-normal distribution.
+ public static LogNormal Estimate(IEnumerable samples, System.Random randomSource = null)
{
var muSigma2 = samples.Select(s => Math.Log(s)).MeanVariance();
- return new LogNormal(muSigma2.Item1, Math.Sqrt(muSigma2.Item2));
+ return new LogNormal(muSigma2.Item1, Math.Sqrt(muSigma2.Item2), randomSource);
}
///
@@ -111,26 +126,15 @@ namespace MathNet.Numerics.Distributions
return "LogNormal(μ = " + _mu + ", σ = " + _sigma + ")";
}
- ///
- /// Checks whether the parameters of the distribution are valid.
- ///
- /// The log-scale (μ) of the distribution.
- /// The shape (σ) of the distribution.
- /// true when the parameters are valid, false otherwise.
- static bool IsValidParameterSet(double mu, double sigma)
- {
- return sigma >= 0.0 && !Double.IsNaN(mu);
- }
-
///
/// Sets the parameters of the distribution after checking their validity.
///
/// The log-scale (μ) of the distribution.
- /// The shape (σ) of the distribution.
- /// When the parameters don't pass the function.
+ /// The shape (σ) of the distribution. Range: σ ≥ 0.
+ /// When the parameters are out of range.
void SetParameters(double mu, double sigma)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(mu, sigma))
+ if (sigma < 0.0 || Double.IsNaN(mu) || Double.IsNaN(sigma))
{
throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
}
@@ -149,7 +153,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Gets or sets the shape (σ) (standard deviation of the logarithm) of the distribution.
+ /// Gets or sets the shape (σ) (standard deviation of the logarithm) of the distribution. Range: σ ≥ 0.
///
public double Sigma
{
@@ -251,7 +255,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. ∂P(X ≤ x)/∂x.
///
/// The location at which to compute the density.
/// the density at .
@@ -262,12 +266,12 @@ namespace MathNet.Numerics.Distributions
return 0.0;
}
- var a = (Math.Log(x) - _mu)/_sigma;
+ var a = (Math.Log(x) - _mu) / _sigma;
return Math.Exp(-0.5*a*a)/(x*_sigma*Constants.Sqrt2Pi);
}
///
- /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(∂P(X ≤ x)/∂x).
///
/// The location at which to compute the log density.
/// the log density at .
@@ -278,23 +282,20 @@ namespace MathNet.Numerics.Distributions
return Double.NegativeInfinity;
}
- var a = (Math.Log(x) - _mu)/_sigma;
+ var a = (Math.Log(x) - _mu) / _sigma;
return (-0.5*a*a) - Math.Log(x*_sigma) - Constants.LogSqrt2Pi;
}
///
- /// Computes the cumulative distribution (CDF) of the distribution at x, 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 .
public double CumulativeDistribution(double x)
{
- if (x < 0.0)
- {
- return 0.0;
- }
-
- return 0.5*(1.0 + SpecialFunctions.Erf((Math.Log(x) - _mu)/(_sigma*Constants.Sqrt2)));
+ return x < 0.0
+ ? 0.0
+ : 0.5*(1.0 + SpecialFunctions.Erf((Math.Log(x) - _mu)/(_sigma*Constants.Sqrt2)));
}
///
@@ -303,7 +304,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public double Sample()
{
- return Math.Exp(Normal.SampleUnchecked(_random, _mu, _sigma));
+ return Math.Exp(Normal.Sample(_random, _mu, _sigma));
}
///
@@ -312,7 +313,63 @@ namespace MathNet.Numerics.Distributions
/// a sequence of samples from the distribution.
public IEnumerable Samples()
{
- return Normal.SamplesUnchecked(_random, _mu, _sigma).Select(Math.Exp);
+ return Normal.Samples(_random, _mu, _sigma).Select(Math.Exp);
+ }
+
+ ///
+ /// Computes the probability density of the distribution (PDF) at x, i.e. ∂P(X ≤ x)/∂x.
+ ///
+ /// The location at which to compute the density.
+ /// The log-scale (μ) of the distribution.
+ /// The shape (σ) of the distribution. Range: σ ≥ 0.
+ /// the density at .
+ public static double PDF(double mu, double sigma, double x)
+ {
+ if (sigma < 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+
+ if (x < 0.0)
+ {
+ return 0.0;
+ }
+
+ var a = (Math.Log(x) - mu) / sigma;
+ return Math.Exp(-0.5*a*a)/(x*sigma*Constants.Sqrt2Pi);
+ }
+
+ ///
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(∂P(X ≤ x)/∂x).
+ ///
+ /// The location at which to compute the density.
+ /// The log-scale (μ) of the distribution.
+ /// The shape (σ) of the distribution. Range: σ ≥ 0.
+ /// the log density at .
+ public static double PDFLn(double mu, double sigma, double x)
+ {
+ if (sigma < 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+
+ if (x < 0.0)
+ {
+ return Double.NegativeInfinity;
+ }
+
+ var a = (Math.Log(x) - mu) / sigma;
+ return (-0.5*a*a) - Math.Log(x*sigma) - Constants.LogSqrt2Pi;
+ }
+
+ ///
+ /// 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 log-scale (μ) of the distribution.
+ /// The shape (σ) of the distribution. Range: σ ≥ 0.
+ /// the cumulative distribution at location .
+ public static double CDF(double mu, double sigma, double x)
+ {
+ if (sigma < 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+
+ return x < 0.0
+ ? 0.0
+ : 0.5*(1.0 + SpecialFunctions.Erf((Math.Log(x) - mu)/(sigma*Constants.Sqrt2)));
}
///
@@ -320,7 +377,7 @@ namespace MathNet.Numerics.Distributions
///
/// The random number generator to use.
/// The log-scale (μ) of the distribution.
- /// The shape (σ) of the distribution.
+ /// The shape (σ) of the distribution. Range: σ ≥ 0.
/// a sample from the distribution.
public static double Sample(System.Random rnd, double mu, double sigma)
{
@@ -332,7 +389,7 @@ namespace MathNet.Numerics.Distributions
///
/// The random number generator to use.
/// The log-scale (μ) of the distribution.
- /// The shape (σ) of the distribution.
+ /// The shape (σ) of the distribution. Range: σ ≥ 0.
/// a sequence of samples from the distribution.
public static IEnumerable Samples(System.Random rnd, double mu, double sigma)
{
diff --git a/src/Numerics/Distributions/MatrixNormal.cs b/src/Numerics/Distributions/MatrixNormal.cs
index 26e58c21..5391f6a2 100644
--- a/src/Numerics/Distributions/MatrixNormal.cs
+++ b/src/Numerics/Distributions/MatrixNormal.cs
@@ -150,7 +150,7 @@ namespace MathNet.Numerics.Distributions
/// The mean of the matrix normal.
/// The covariance matrix for the rows.
/// The covariance matrix for the columns.
- /// When the parameters don't pass the function.
+ /// When the parameters are out of range.
void SetParameters(Matrix m, Matrix v, Matrix k)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(m, v, k))
diff --git a/src/Numerics/Distributions/Multinomial.cs b/src/Numerics/Distributions/Multinomial.cs
index 82821a8b..01388f3d 100644
--- a/src/Numerics/Distributions/Multinomial.cs
+++ b/src/Numerics/Distributions/Multinomial.cs
@@ -165,7 +165,7 @@ namespace MathNet.Numerics.Distributions
/// An array of nonnegative ratios: this array does not need to be normalized
/// as this is often impossible using floating point arithmetic.
/// The number of trials.
- /// When the parameters don't pass the function.
+ /// When the parameters are out of range.
void SetParameters(double[] p, int n)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(p, n))
diff --git a/src/Numerics/Distributions/NegativeBinomial.cs b/src/Numerics/Distributions/NegativeBinomial.cs
index 12cf30fe..62907812 100644
--- a/src/Numerics/Distributions/NegativeBinomial.cs
+++ b/src/Numerics/Distributions/NegativeBinomial.cs
@@ -103,7 +103,7 @@ namespace MathNet.Numerics.Distributions
///
/// The number of failures until the experiment stopped.
/// The probability of a trial resulting in success.
- /// When the parameters don't pass the function.
+ /// When the parameters are out of range.
void SetParameters(double r, double p)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(r, p))
@@ -244,7 +244,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution at x, 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/Normal.cs b/src/Numerics/Distributions/Normal.cs
index 8f5e7d7d..737098b4 100644
--- a/src/Numerics/Distributions/Normal.cs
+++ b/src/Numerics/Distributions/Normal.cs
@@ -78,7 +78,7 @@ namespace MathNet.Numerics.Distributions
/// be initialized with the default random number generator.
///
/// The mean (μ) of the normal distribution.
- /// The standard deviation (σ) of the normal distribution.
+ /// The standard deviation (σ) of the normal distribution. Range: σ ≥ 0.
public Normal(double mean, double stddev)
{
_random = new System.Random();
@@ -90,7 +90,7 @@ namespace MathNet.Numerics.Distributions
/// be initialized with the default random number generator.
///
/// The mean (μ) of the normal distribution.
- /// The standard deviation (σ) of the normal distribution.
+ /// The standard deviation (σ) of the normal distribution. Range: σ ≥ 0.
/// The random number generator which is used to draw random samples.
public Normal(double mean, double stddev, System.Random randomSource)
{
@@ -99,48 +99,51 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Constructs a normal distribution from a mean and standard deviation. The distribution will
- /// be initialized with the default random number generator.
+ /// Constructs a normal distribution from a mean and standard deviation.
///
/// The mean (μ) of the normal distribution.
- /// The standard deviation (σ) of the normal distribution.
+ /// The standard deviation (σ) of the normal distribution. Range: σ ≥ 0.
+ /// The random number generator which is used to draw random samples. Optional, can be null.
/// a normal distribution.
- public static Normal WithMeanStdDev(double mean, double stddev)
+ public static Normal WithMeanStdDev(double mean, double stddev, System.Random randomSource = null)
{
- return new Normal(mean, stddev);
+ return new Normal(mean, stddev, randomSource);
}
///
- /// Constructs a normal distribution from a mean and variance. The distribution will
- /// be initialized with the default random number generator.
+ /// Constructs a normal distribution from a mean and variance.
///
/// The mean (μ) of the normal distribution.
- /// The variance of the normal distribution.
- /// a normal distribution.
- public static Normal WithMeanVariance(double mean, double var)
+ /// The variance (σ^2) of the normal distribution.
+ /// The random number generator which is used to draw random samples. Optional, can be null.
+ /// A normal distribution.
+ public static Normal WithMeanVariance(double mean, double var, System.Random randomSource = null)
{
- return new Normal(mean, Math.Sqrt(var));
+ return new Normal(mean, Math.Sqrt(var), randomSource);
}
///
- /// Constructs a normal distribution from a mean and precision. The distribution will
- /// be initialized with the default random number generator.
+ /// Constructs a normal distribution from a mean and precision.
///
/// The mean (μ) of the normal distribution.
/// The precision of the normal distribution.
- /// a normal distribution.
- public static Normal WithMeanPrecision(double mean, double precision)
+ /// The random number generator which is used to draw random samples. Optional, can be null.
+ /// A normal distribution.
+ public static Normal WithMeanPrecision(double mean, double precision, System.Random randomSource = null)
{
- return new Normal(mean, 1.0/Math.Sqrt(precision));
+ return new Normal(mean, 1.0/Math.Sqrt(precision), randomSource);
}
///
/// Estimates the normal distribution parameters from sample data with maximum-likelihood.
///
- public static Normal Estimate(IEnumerable samples)
+ /// The samples to estimate the distribution parameters from.
+ /// The random number generator which is used to draw random samples. Optional, can be null.
+ /// A normal distribution.
+ public static Normal Estimate(IEnumerable samples, System.Random randomSource = null)
{
var meanVariance = samples.MeanVariance();
- return new Normal(meanVariance.Item1, Math.Sqrt(meanVariance.Item2));
+ return new Normal(meanVariance.Item1, Math.Sqrt(meanVariance.Item2), randomSource);
}
///
@@ -152,26 +155,15 @@ namespace MathNet.Numerics.Distributions
return "Normal(μ = " + _mean + ", σ = " + _stdDev + ")";
}
- ///
- /// Checks whether the parameters of the distribution are valid.
- ///
- /// The mean (μ) of the normal distribution.
- /// The standard deviation (σ) of the normal distribution.
- /// true when the parameters are valid, false otherwise.
- static bool IsValidParameterSet(double mean, double stddev)
- {
- return stddev >= 0.0 && !Double.IsNaN(mean);
- }
-
///
/// Sets the parameters of the distribution after checking their validity.
///
/// The mean (μ) of the normal distribution.
- /// The standard deviation (σ) of the normal distribution.
- /// When the parameters don't pass the function.
+ /// The standard deviation (σ) of the normal distribution. Range: σ ≥ 0.
+ /// When the parameters are out of range.
void SetParameters(double mean, double stddev)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(mean, stddev))
+ if (stddev < 0.0 || Double.IsNaN(mean) || Double.IsNaN(stddev))
{
throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
}
@@ -190,7 +182,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Gets or sets the standard deviation (σ) of the normal distribution.
+ /// Gets or sets the standard deviation (σ) of the normal distribution. Range: σ ≥ 0.
///
public double StdDev
{
@@ -203,7 +195,7 @@ namespace MathNet.Numerics.Distributions
///
public double Variance
{
- get { return _stdDev * _stdDev; }
+ get { return _stdDev*_stdDev; }
set { SetParameters(_mean, Math.Sqrt(value)); }
}
@@ -212,10 +204,10 @@ namespace MathNet.Numerics.Distributions
///
public double Precision
{
- get { return 1.0 / (_stdDev * _stdDev); }
+ get { return 1.0/(_stdDev*_stdDev); }
set
{
- var sdev = 1.0 / Math.Sqrt(value);
+ var sdev = 1.0/Math.Sqrt(value);
// Handle the case when the precision is -0.
if (Double.IsInfinity(sdev))
{
@@ -283,71 +275,35 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the density of the normal distribution (PDF), i.e. dP(X <= x)/dx.
- ///
- /// The mean (μ) of the normal distribution.
- /// The standard deviation (σ) of the normal distribution.
- /// The location at which to compute the density.
- /// the density at .
- internal static double Density(double mean, double stddev, double x)
- {
- var d = (x - mean)/stddev;
- return Math.Exp(-0.5*d*d)/(Constants.Sqrt2Pi*stddev);
- }
-
- ///
- /// Computes the log density of the normal distribution (lnPDF), i.e. ln(dP(X <= x)/dx).
- ///
- /// The mean (μ) of the normal distribution.
- /// The standard deviation (σ) of the normal distribution.
- /// The location at which to compute the density.
- /// the log density at .
- internal static double DensityLn(double mean, double stddev, double x)
- {
- var d = (x - mean)/stddev;
- return (-0.5*d*d) - Math.Log(stddev) - Constants.LogSqrt2Pi;
- }
-
- ///
- /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. ∂P(X ≤ x)/∂x.
///
/// The location at which to compute the density.
/// the density at .
public double Density(double x)
{
- return Density(_mean, _stdDev, x);
+ var d = (x - _mean)/_stdDev;
+ return Math.Exp(-0.5*d*d)/(Constants.Sqrt2Pi*_stdDev);
}
///
- /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(∂P(X ≤ x)/∂x).
///
/// The location at which to compute the log density.
/// the log density at .
public double DensityLn(double x)
{
- return DensityLn(_mean, _stdDev, x);
+ var d = (x - _mean)/_stdDev;
+ return (-0.5*d*d) - Math.Log(_stdDev) - Constants.LogSqrt2Pi;
}
///
- /// Computes the cumulative distribution function (CDF) of the normal distribution, i.e. P(X <= x).
- ///
- /// The mean (μ) of the normal distribution.
- /// The standard deviation (σ) of the normal distribution.
- /// The location at which to compute the cumulative density.
- /// the cumulative density at .
- internal static double CumulativeDistribution(double mean, double stddev, double x)
- {
- return 0.5*(1.0 + SpecialFunctions.Erf((x - mean)/(stddev*Constants.Sqrt2)));
- }
-
- ///
- /// Computes the cumulative distribution (CDF) of the distribution at x, 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 .
public double CumulativeDistribution(double x)
{
- return CumulativeDistribution(_mean, _stdDev, x);
+ return 0.5*(1.0 + SpecialFunctions.Erf((x - _mean)/(_stdDev*Constants.Sqrt2)));
}
///
@@ -361,6 +317,29 @@ namespace MathNet.Numerics.Distributions
return _mean - (_stdDev*Constants.Sqrt2*SpecialFunctions.ErfcInv(2.0*p));
}
+ ///
+ /// Generates a sample from the normal distribution using the Box-Muller algorithm.
+ ///
+ /// a sample from the distribution.
+ public double Sample()
+ {
+ return _mean + (_stdDev*SampleStandardBoxMuller(_random).Item1);
+ }
+
+ ///
+ /// Generates a sequence of samples from the normal distribution using the Box-Muller algorithm.
+ ///
+ /// a sequence of samples from the distribution.
+ public IEnumerable Samples()
+ {
+ while (true)
+ {
+ var sample = SampleStandardBoxMuller(_random);
+ yield return _mean + (_stdDev*sample.Item1);
+ yield return _mean + (_stdDev*sample.Item2);
+ }
+ }
+
///
/// Samples a pair of standard normal distributed random variables using the Box-Muller algorithm.
///
@@ -368,65 +347,77 @@ namespace MathNet.Numerics.Distributions
/// a pair of random numbers from the standard normal distribution.
static Tuple SampleStandardBoxMuller(System.Random rnd)
{
- var v1 = (2.0*rnd.NextDouble()) - 1.0;
- var v2 = (2.0*rnd.NextDouble()) - 1.0;
- var r = (v1*v1) + (v2*v2);
+ var v1 = (2.0 * rnd.NextDouble()) - 1.0;
+ var v2 = (2.0 * rnd.NextDouble()) - 1.0;
+ var r = (v1 * v1) + (v2 * v2);
while (r >= 1.0 || r == 0.0)
{
- v1 = (2.0*rnd.NextDouble()) - 1.0;
- v2 = (2.0*rnd.NextDouble()) - 1.0;
- r = (v1*v1) + (v2*v2);
+ v1 = (2.0 * rnd.NextDouble()) - 1.0;
+ v2 = (2.0 * rnd.NextDouble()) - 1.0;
+ r = (v1 * v1) + (v2 * v2);
}
- var fac = Math.Sqrt(-2.0*Math.Log(r)/r);
- return new Tuple(v1*fac, v2*fac);
+ var fac = Math.Sqrt(-2.0 * Math.Log(r) / r);
+ return new Tuple(v1 * fac, v2 * fac);
}
///
- /// Samples the distribution.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. ∂P(X ≤ x)/∂x.
///
- /// 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 double SampleUnchecked(System.Random rnd, double mean, double stddev)
+ /// The standard deviation (σ) of the normal distribution. Range: σ ≥ 0.
+ /// The location at which to compute the density.
+ /// the density at .
+ public static double PDF(double mean, double stddev, double x)
{
- return mean + (stddev*SampleStandardBoxMuller(rnd).Item1);
+ if (stddev < 0.0) throw new ArgumentOutOfRangeException("stddev", Resources.InvalidDistributionParameters);
+
+ var d = (x - mean)/stddev;
+ return Math.Exp(-0.5*d*d)/(Constants.Sqrt2Pi*stddev);
}
///
- /// Samples the distribution.
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(∂P(X ≤ x)/∂x).
///
- /// 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)
+ /// The standard deviation (σ) of the normal distribution. Range: σ ≥ 0.
+ /// The location at which to compute the density.
+ /// the log density at .
+ public static double PDFLn(double mean, double stddev, double x)
{
- while (true)
- {
- var sample = SampleStandardBoxMuller(rnd);
- yield return mean + (stddev*sample.Item1);
- yield return mean + (stddev*sample.Item2);
- }
+ if (stddev < 0.0) throw new ArgumentOutOfRangeException("stddev", Resources.InvalidDistributionParameters);
+
+ var d = (x - mean)/stddev;
+ return (-0.5*d*d) - Math.Log(stddev) - Constants.LogSqrt2Pi;
}
///
- /// Generates a sample from the normal distribution using the Box-Muller algorithm.
+ /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X ≤ x).
///
- /// a sample from the distribution.
- public double Sample()
+ /// The location at which to compute the cumulative distribution function.
+ /// The mean (μ) of the normal distribution.
+ /// The standard deviation (σ) of the normal distribution. Range: σ ≥ 0.
+ /// the cumulative distribution at location .
+ public static double CDF(double mean, double stddev, double x)
{
- return SampleUnchecked(_random, _mean, _stdDev);
+ if (stddev < 0.0) throw new ArgumentOutOfRangeException("stddev", Resources.InvalidDistributionParameters);
+
+ return 0.5*(1.0 + SpecialFunctions.Erf((x - mean)/(stddev*Constants.Sqrt2)));
}
///
- /// Generates a sequence of samples from the normal distribution using the Box-Muller algorithm.
+ /// Computes the inverse of the cumulative distribution function (InvCDF) for the distribution
+ /// at the given probability.
///
- /// a sequence of samples from the distribution.
- public IEnumerable Samples()
+ /// The location at which to compute the inverse cumulative density.
+ /// The mean (μ) of the normal distribution.
+ /// The standard deviation (σ) of the normal distribution. Range: σ ≥ 0.
+ /// the inverse cumulative density at .
+ public static double InvCDF(double mean, double stddev, double p)
{
- return SamplesUnchecked(_random, _mean, _stdDev);
+ if (stddev < 0.0) throw new ArgumentOutOfRangeException("stddev", Resources.InvalidDistributionParameters);
+
+ return mean - (stddev*Constants.Sqrt2*SpecialFunctions.ErfcInv(2.0*p));
}
///
@@ -434,16 +425,13 @@ namespace MathNet.Numerics.Distributions
///
/// The random number generator to use.
/// The mean (μ) of the normal distribution.
- /// The standard deviation (σ) of the normal distribution.
+ /// The standard deviation (σ) of the normal distribution. Range: σ ≥ 0.
/// a sample from the distribution.
public static double Sample(System.Random rnd, double mean, double stddev)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(mean, stddev))
- {
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
- }
+ if (stddev < 0.0) throw new ArgumentOutOfRangeException("stddev", Resources.InvalidDistributionParameters);
- return SampleUnchecked(rnd, mean, stddev);
+ return mean + (stddev*SampleStandardBoxMuller(rnd).Item1);
}
///
@@ -451,16 +439,18 @@ namespace MathNet.Numerics.Distributions
///
/// The random number generator to use.
/// The mean (μ) of the normal distribution.
- /// The standard deviation (σ) of the normal distribution.
+ /// The standard deviation (σ) of the normal distribution. Range: σ ≥ 0.
/// a sequence of samples from the distribution.
public static IEnumerable Samples(System.Random rnd, double mean, double stddev)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(mean, stddev))
+ if (stddev < 0.0) throw new ArgumentOutOfRangeException("stddev", Resources.InvalidDistributionParameters);
+
+ while (true)
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ var sample = SampleStandardBoxMuller(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 8037da03..5f6d7c28 100644
--- a/src/Numerics/Distributions/NormalGamma.cs
+++ b/src/Numerics/Distributions/NormalGamma.cs
@@ -166,7 +166,7 @@ namespace MathNet.Numerics.Distributions
/// The scale of the mean.
/// The shape of the precision.
/// The inverse scale of the precision.
- /// When the parameters don't pass the function.
+ /// When the parameters are out of range.
void SetParameters(double meanLocation, double meanScale, double precShape, double precInvScale)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(meanLocation, meanScale, precShape, precInvScale))
diff --git a/src/Numerics/Distributions/Pareto.cs b/src/Numerics/Distributions/Pareto.cs
index ac54731a..5f46ce74 100644
--- a/src/Numerics/Distributions/Pareto.cs
+++ b/src/Numerics/Distributions/Pareto.cs
@@ -103,7 +103,7 @@ namespace MathNet.Numerics.Distributions
///
/// The scale (xm) of the distribution.
/// The shape (α) of the distribution.
- /// When the parameters don't pass the function.
+ /// When the parameters are out of range.
void SetParameters(double scale, double shape)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(scale, shape))
@@ -231,7 +231,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. ∂P(X ≤ x)/∂x.
///
/// The location at which to compute the density.
/// the density at .
@@ -241,7 +241,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(∂P(X ≤ x)/∂x).
///
/// 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 at x, 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/Poisson.cs b/src/Numerics/Distributions/Poisson.cs
index abf5fc5b..0a675430 100644
--- a/src/Numerics/Distributions/Poisson.cs
+++ b/src/Numerics/Distributions/Poisson.cs
@@ -96,7 +96,7 @@ namespace MathNet.Numerics.Distributions
/// Sets the parameters of the distribution after checking their validity.
///
/// The mean (λ) of the distribution.
- /// When the parameters don't pass the function.
+ /// When the parameters are out of range.
void SetParameters(double lambda)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(lambda))
@@ -220,7 +220,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution at x, 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/Rayleigh.cs b/src/Numerics/Distributions/Rayleigh.cs
index 3b34823a..834ee329 100644
--- a/src/Numerics/Distributions/Rayleigh.cs
+++ b/src/Numerics/Distributions/Rayleigh.cs
@@ -99,7 +99,7 @@ namespace MathNet.Numerics.Distributions
/// Sets the parameters of the distribution after checking their validity.
///
/// The scale (σ) of the distribution.
- /// When the parameters don't pass the function.
+ /// When the parameters are out of range.
void SetParameters(double scale)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(scale))
@@ -201,7 +201,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. ∂P(X ≤ x)/∂x.
///
/// The location at which to compute the density.
/// the density at .
@@ -211,7 +211,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(∂P(X ≤ x)/∂x).
///
/// 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 at x, 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/Stable.cs b/src/Numerics/Distributions/Stable.cs
index 0d94d035..b422d641 100644
--- a/src/Numerics/Distributions/Stable.cs
+++ b/src/Numerics/Distributions/Stable.cs
@@ -112,6 +112,7 @@ namespace MathNet.Numerics.Distributions
/// The skewness (β) of the distribution.
/// The scale (c) of the distribution.
/// The location (μ) of the distribution.
+ /// When the parameters are out of range.
void SetParameters(double alpha, double beta, double scale, double location)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(alpha, beta, scale, location))
@@ -303,7 +304,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. ∂P(X ≤ x)/∂x.
///
/// The location at which to compute the density.
/// the density at .
@@ -346,7 +347,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(∂P(X ≤ x)/∂x).
///
/// The location at which to compute the log density.
/// the log density at .
@@ -356,7 +357,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution at x, 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/StudentT.cs b/src/Numerics/Distributions/StudentT.cs
index e7ded7e9..0823a476 100644
--- a/src/Numerics/Distributions/StudentT.cs
+++ b/src/Numerics/Distributions/StudentT.cs
@@ -129,7 +129,7 @@ namespace MathNet.Numerics.Distributions
/// 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.
+ /// When the parameters are out of range.
void SetParameters(double location, double scale, double freedom)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(location, scale, freedom))
@@ -288,7 +288,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. ∂P(X ≤ x)/∂x.
///
/// The location at which to compute the density.
/// the density at .
@@ -297,7 +297,7 @@ namespace MathNet.Numerics.Distributions
// TODO JVG we can probably do a better job for Cauchy special case
if (_freedom >= 1e+8d)
{
- return Normal.Density(_location, _scale, x);
+ return Normal.PDF(_location, _scale, x);
}
var d = (x - _location)/_scale;
@@ -308,7 +308,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(∂P(X ≤ x)/∂x).
///
/// The location at which to compute the log density.
/// the log density at .
@@ -317,7 +317,7 @@ namespace MathNet.Numerics.Distributions
// TODO JVG we can probably do a better job for Cauchy special case
if (_freedom >= 1e+8d)
{
- return Normal.DensityLn(_location, _scale, x);
+ return Normal.PDFLn(_location, _scale, x);
}
var d = (x - _location)/_scale;
@@ -328,7 +328,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution at x, 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 .
@@ -337,7 +337,7 @@ namespace MathNet.Numerics.Distributions
// TODO JVG we can probably do a better job for Cauchy special case
if (Double.IsPositiveInfinity(_freedom))
{
- return Normal.CumulativeDistribution(_location, _scale, x);
+ return Normal.CDF(_location, _scale, x);
}
var k = (x - _location)/_scale;
@@ -359,7 +359,7 @@ namespace MathNet.Numerics.Distributions
static double SampleUnchecked(System.Random rnd, double location, double scale, double freedom)
{
var gamma = Gamma.SampleUnchecked(rnd, 0.5*freedom, 0.5);
- return Normal.SampleUnchecked(rnd, location, scale*Math.Sqrt(freedom/gamma));
+ return Normal.Sample(rnd, location, scale*Math.Sqrt(freedom/gamma));
}
///
diff --git a/src/Numerics/Distributions/Weibull.cs b/src/Numerics/Distributions/Weibull.cs
index 3463fc2e..aeacd3b2 100644
--- a/src/Numerics/Distributions/Weibull.cs
+++ b/src/Numerics/Distributions/Weibull.cs
@@ -110,7 +110,7 @@ namespace MathNet.Numerics.Distributions
///
/// The shape (k) of the Weibull distribution.
/// The scale (λ) of the Weibull distribution.
- /// When the parameters don't pass the function.
+ /// When the parameters are out of range.
void SetParameters(double shape, double scale)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(shape, scale))
@@ -238,7 +238,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the probability density of the distribution (PDF) at x, i.e. dP(X <= x)/dx.
+ /// Computes the probability density of the distribution (PDF) at x, i.e. ∂P(X ≤ x)/∂x.
///
/// The location at which to compute the density.
/// the density at .
@@ -258,7 +258,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(dP(X <= x)/dx).
+ /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(∂P(X ≤ x)/∂x).
///
/// 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 at x, 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/Wishart.cs b/src/Numerics/Distributions/Wishart.cs
index 923fdbc9..14a5703c 100644
--- a/src/Numerics/Distributions/Wishart.cs
+++ b/src/Numerics/Distributions/Wishart.cs
@@ -95,7 +95,7 @@ namespace MathNet.Numerics.Distributions
///
/// 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.
+ /// When the parameters are out of range.
void SetParameters(double degreesOfFreedom, Matrix scale)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(degreesOfFreedom, scale))
diff --git a/src/Numerics/Distributions/Zipf.cs b/src/Numerics/Distributions/Zipf.cs
index b648427b..61a3a49c 100644
--- a/src/Numerics/Distributions/Zipf.cs
+++ b/src/Numerics/Distributions/Zipf.cs
@@ -109,6 +109,7 @@ namespace MathNet.Numerics.Distributions
///
/// The s parameter of the distribution.
/// The n parameter of the distribution.
+ /// When the parameters are out of range.
void SetParameters(double s, int n)
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(s, n))
@@ -267,7 +268,7 @@ namespace MathNet.Numerics.Distributions
}
///
- /// Computes the cumulative distribution (CDF) of the distribution at x, 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/UnitTests/DistributionTests/Continuous/LogNormalTests.cs b/src/UnitTests/DistributionTests/Continuous/LogNormalTests.cs
index c8503de8..84167ef5 100644
--- a/src/UnitTests/DistributionTests/Continuous/LogNormalTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/LogNormalTests.cs
@@ -378,6 +378,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
{
var n = new LogNormal(mu, sigma);
AssertHelpers.AlmostEqual(p, n.Density(x), 14);
+ AssertHelpers.AlmostEqual(p, LogNormal.PDF(mu, sigma, x), 14);
}
///
@@ -419,6 +420,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
{
var n = new LogNormal(mu, sigma);
AssertHelpers.AlmostEqual(p, n.DensityLn(x), 14);
+ AssertHelpers.AlmostEqual(p, LogNormal.PDFLn(mu, sigma, x), 14);
}
///
@@ -518,6 +520,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
{
var n = new LogNormal(mu, sigma);
AssertHelpers.AlmostEqual(f, n.CumulativeDistribution(x), 8);
+ AssertHelpers.AlmostEqual(f, LogNormal.CDF(mu, sigma, x), 8);
}
///
diff --git a/src/UnitTests/DistributionTests/Continuous/NormalTests.cs b/src/UnitTests/DistributionTests/Continuous/NormalTests.cs
index a0a68323..55e19e18 100644
--- a/src/UnitTests/DistributionTests/Continuous/NormalTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/NormalTests.cs
@@ -368,6 +368,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
var d = (mean - x) / sdev;
var pdf = Math.Exp(-0.5 * d * d) / (sdev * Constants.Sqrt2Pi);
Assert.AreEqual(pdf, n.Density(x));
+ Assert.AreEqual(pdf, Normal.PDF(mean, sdev, x));
}
}
@@ -391,6 +392,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
var d = (mean - x) / sdev;
var pdfln = (-0.5 * (d * d)) - Math.Log(sdev) - Constants.LogSqrt2Pi;
Assert.AreEqual(pdfln, n.DensityLn(x));
+ Assert.AreEqual(pdfln, Normal.PDFLn(mean, sdev, x));
}
}
@@ -471,6 +473,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
{
var n = Normal.WithMeanStdDev(5.0, 2.0);
AssertHelpers.AlmostEqual(f, n.CumulativeDistribution(x), 10);
+ AssertHelpers.AlmostEqual(f, Normal.CDF(5.0, 2.0, x), 10);
}
///
@@ -492,6 +495,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
{
var n = Normal.WithMeanStdDev(5.0, 2.0);
AssertHelpers.AlmostEqual(x, n.InverseCumulativeDistribution(f), 15);
+ AssertHelpers.AlmostEqual(x, Normal.InvCDF(5.0, 2.0, f), 15);
}
///