Browse Source

Distributions: switch default RNG from MersenneTwister to SystemRandomSource

optimization-3
Christoph Ruegg 13 years ago
parent
commit
6e004968c6
  1. 6
      src/Numerics/Distributions/Bernoulli.cs
  2. 6
      src/Numerics/Distributions/Beta.cs
  3. 6
      src/Numerics/Distributions/Binomial.cs
  4. 8
      src/Numerics/Distributions/Categorical.cs
  5. 6
      src/Numerics/Distributions/Cauchy.cs
  6. 6
      src/Numerics/Distributions/Chi.cs
  7. 6
      src/Numerics/Distributions/ChiSquared.cs
  8. 6
      src/Numerics/Distributions/ContinuousUniform.cs
  9. 6
      src/Numerics/Distributions/ConwayMaxwellPoisson.cs
  10. 10
      src/Numerics/Distributions/Dirichlet.cs
  11. 6
      src/Numerics/Distributions/DiscreteUniform.cs
  12. 6
      src/Numerics/Distributions/Erlang.cs
  13. 6
      src/Numerics/Distributions/Exponential.cs
  14. 6
      src/Numerics/Distributions/FisherSnedecor.cs
  15. 6
      src/Numerics/Distributions/Gamma.cs
  16. 6
      src/Numerics/Distributions/Geometric.cs
  17. 6
      src/Numerics/Distributions/Hypergeometric.cs
  18. 6
      src/Numerics/Distributions/InverseGamma.cs
  19. 6
      src/Numerics/Distributions/InverseWishart.cs
  20. 6
      src/Numerics/Distributions/Laplace.cs
  21. 6
      src/Numerics/Distributions/LogNormal.cs
  22. 6
      src/Numerics/Distributions/MatrixNormal.cs
  23. 8
      src/Numerics/Distributions/Multinomial.cs
  24. 6
      src/Numerics/Distributions/NegativeBinomial.cs
  25. 6
      src/Numerics/Distributions/Normal.cs
  26. 6
      src/Numerics/Distributions/NormalGamma.cs
  27. 6
      src/Numerics/Distributions/Pareto.cs
  28. 6
      src/Numerics/Distributions/Poisson.cs
  29. 6
      src/Numerics/Distributions/Rayleigh.cs
  30. 6
      src/Numerics/Distributions/Stable.cs
  31. 8
      src/Numerics/Distributions/StudentT.cs
  32. 6
      src/Numerics/Distributions/Triangular.cs
  33. 6
      src/Numerics/Distributions/Weibull.cs
  34. 14
      src/Numerics/Distributions/Wishart.cs
  35. 6
      src/Numerics/Distributions/Zipf.cs

6
src/Numerics/Distributions/Bernoulli.cs

@ -59,7 +59,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentOutOfRangeException">If the Bernoulli parameter is not in the range [0,1].</exception>
public Bernoulli(double p)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(p);
}
@ -71,7 +71,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentOutOfRangeException">If the Bernoulli parameter is not in the range [0,1].</exception>
public Bernoulli(double p, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(p);
}
@ -124,7 +124,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

6
src/Numerics/Distributions/Beta.cs

@ -66,7 +66,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="b">The β shape parameter of the Beta distribution. Range: β ≥ 0.</param>
public Beta(double a, double b)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(a, b);
}
@ -78,7 +78,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public Beta(double a, double b, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(a, b);
}
@ -132,7 +132,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

6
src/Numerics/Distributions/Binomial.cs

@ -62,7 +62,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="n"/> is negative.</exception>
public Binomial(double p, int n)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(p, n);
}
@ -76,7 +76,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="n"/> is negative.</exception>
public Binomial(double p, int n, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(p, n);
}
@ -142,7 +142,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

8
src/Numerics/Distributions/Categorical.cs

@ -66,7 +66,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentException">If any of the probabilities are negative or do not sum to one.</exception>
public Categorical(double[] probabilityMass)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(probabilityMass);
}
@ -79,7 +79,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentException">If any of the probabilities are negative or do not sum to one.</exception>
public Categorical(double[] probabilityMass, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(probabilityMass);
}
@ -105,7 +105,7 @@ namespace MathNet.Numerics.Distributions
p[i] = histogram[i].Count;
}
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(p);
}
@ -208,7 +208,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

6
src/Numerics/Distributions/Cauchy.cs

@ -66,7 +66,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="scale">The scale (γ) of the distribution. Range: γ > 0.</param>
public Cauchy(double location, double scale)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(location, scale);
}
@ -78,7 +78,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public Cauchy(double location, double scale, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(location, scale);
}
@ -132,7 +132,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

6
src/Numerics/Distributions/Chi.cs

@ -59,7 +59,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="freedom">The degrees of freedom (k) of the distribution. Range: k > 0.</param>
public Chi(double freedom)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(freedom);
}
@ -70,7 +70,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public Chi(double freedom, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(freedom);
}
@ -113,7 +113,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

6
src/Numerics/Distributions/ChiSquared.cs

@ -57,7 +57,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="freedom">The degrees of freedom (k) of the distribution. Range: k > 0.</param>
public ChiSquared(double freedom)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(freedom);
}
@ -68,7 +68,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public ChiSquared(double freedom, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(freedom);
}
@ -111,7 +111,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

6
src/Numerics/Distributions/ContinuousUniform.cs

@ -67,7 +67,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentException">If the upper bound is smaller than the lower bound.</exception>
public ContinuousUniform(double lower, double upper)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(lower, upper);
}
@ -80,7 +80,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentException">If the upper bound is smaller than the lower bound.</exception>
public ContinuousUniform(double lower, double upper, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(lower, upper);
}
@ -134,7 +134,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

6
src/Numerics/Distributions/ConwayMaxwellPoisson.cs

@ -87,7 +87,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="nu">The rate of decay (ν) parameter. Range: ν ≥ 0.</param>
public ConwayMaxwellPoisson(double lambda, double nu)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(lambda, nu);
}
@ -99,7 +99,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public ConwayMaxwellPoisson(double lambda, double nu, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(lambda, nu);
}
@ -164,7 +164,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

10
src/Numerics/Distributions/Dirichlet.cs

@ -57,7 +57,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="alpha">An array with the Dirichlet parameters.</param>
public Dirichlet(double[] alpha)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(alpha);
}
@ -69,7 +69,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public Dirichlet(double[] alpha, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(alpha);
}
@ -87,7 +87,7 @@ namespace MathNet.Numerics.Distributions
parm[i] = alpha;
}
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(parm);
}
@ -106,7 +106,7 @@ namespace MathNet.Numerics.Distributions
parm[i] = alpha;
}
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(parm);
}
@ -180,7 +180,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

6
src/Numerics/Distributions/DiscreteUniform.cs

@ -60,7 +60,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="upper">Upper bound. Range: lower ≤ upper.</param>
public DiscreteUniform(int lower, int upper)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(lower, upper);
}
@ -72,7 +72,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public DiscreteUniform(int lower, int upper, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(lower, upper);
}
@ -139,7 +139,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

6
src/Numerics/Distributions/Erlang.cs

@ -60,7 +60,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="rate">The rate or inverse scale (λ) of the Erlang distribution. Range: λ ≥ 0.</param>
public Erlang(int shape, double rate)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(shape, rate);
}
@ -72,7 +72,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public Erlang(int shape, double rate, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(shape, rate);
}
@ -167,7 +167,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

6
src/Numerics/Distributions/Exponential.cs

@ -57,7 +57,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="rate">The rate (λ) parameter of the distribution. Range: λ ≥ 0.</param>
public Exponential(double rate)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(rate);
}
@ -68,7 +68,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public Exponential(double rate, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(rate);
}
@ -111,7 +111,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

6
src/Numerics/Distributions/FisherSnedecor.cs

@ -59,7 +59,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="d2">The second degree of freedom (d2) of the distribution. Range: d2 > 0.</param>
public FisherSnedecor(double d1, double d2)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(d1, d2);
}
@ -71,7 +71,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public FisherSnedecor(double d1, double d2, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(d1, d2);
}
@ -125,7 +125,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

6
src/Numerics/Distributions/Gamma.cs

@ -67,7 +67,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="rate">The rate or inverse scale (β) of the Gamma distribution. Range: β ≥ 0.</param>
public Gamma(double shape, double rate)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(shape, rate);
}
@ -79,7 +79,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public Gamma(double shape, double rate, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(shape, rate);
}
@ -174,7 +174,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

6
src/Numerics/Distributions/Geometric.cs

@ -58,7 +58,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="p">The probability (p) of generating one. Range: 0 ≤ p ≤ 1.</param>
public Geometric(double p)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(p);
}
@ -69,7 +69,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public Geometric(double p, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(p);
}
@ -122,7 +122,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

6
src/Numerics/Distributions/Hypergeometric.cs

@ -64,7 +64,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="draws">The number of draws without replacement (n).</param>
public Hypergeometric(int population, int success, int draws)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(population, success, draws);
}
@ -77,7 +77,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public Hypergeometric(int population, int success, int draws, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(population, success, draws);
}
@ -129,7 +129,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

6
src/Numerics/Distributions/InverseGamma.cs

@ -61,7 +61,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="scale">The scale (β) of the distribution. Range: β > 0.</param>
public InverseGamma(double shape, double scale)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(shape, scale);
}
@ -73,7 +73,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public InverseGamma(double shape, double scale, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(shape, scale);
}
@ -127,7 +127,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

6
src/Numerics/Distributions/InverseWishart.cs

@ -66,7 +66,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="scale">The scale matrix (Ψ) for the inverse Wishart distribution.</param>
public InverseWishart(double degreesOfFreedom, Matrix<double> scale)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(degreesOfFreedom, scale);
}
@ -78,7 +78,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public InverseWishart(double degreesOfFreedom, Matrix<double> scale, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(degreesOfFreedom, scale);
}
@ -157,7 +157,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

6
src/Numerics/Distributions/Laplace.cs

@ -70,7 +70,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentException">If <paramref name="scale"/> is negative.</exception>
public Laplace(double location, double scale)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(location, scale);
}
@ -83,7 +83,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentException">If <paramref name="scale"/> is negative.</exception>
public Laplace(double location, double scale, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(location, scale);
}
@ -137,7 +137,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

6
src/Numerics/Distributions/LogNormal.cs

@ -63,7 +63,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="sigma">The shape (σ) of the logarithm of the distribution. Range: σ ≥ 0.</param>
public LogNormal(double mu, double sigma)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(mu, sigma);
}
@ -77,7 +77,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public LogNormal(double mu, double sigma, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(mu, sigma);
}
@ -169,7 +169,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

6
src/Numerics/Distributions/MatrixNormal.cs

@ -75,7 +75,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentOutOfRangeException">If the dimensions of the mean and two covariance matrices don't match.</exception>
public MatrixNormal(Matrix<double> m, Matrix<double> v, Matrix<double> k)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(m, v, k);
}
@ -89,7 +89,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentOutOfRangeException">If the dimensions of the mean and two covariance matrices don't match.</exception>
public MatrixNormal(Matrix<double> m, Matrix<double> v, Matrix<double> k, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(m, v, k);
}
@ -199,7 +199,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

8
src/Numerics/Distributions/Multinomial.cs

@ -75,7 +75,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="n"/> is negative.</exception>
public Multinomial(double[] p, int n)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(p, n);
}
@ -90,7 +90,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="n"/> is negative.</exception>
public Multinomial(double[] p, int n, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(p, n);
}
@ -119,7 +119,7 @@ namespace MathNet.Numerics.Distributions
}
SetParameters(p, n);
RandomSource = MersenneTwister.Default;
RandomSource = SystemRandomSource.Default;
}
/// <summary>
@ -202,7 +202,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

6
src/Numerics/Distributions/NegativeBinomial.cs

@ -61,7 +61,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="p">The probability (p) of a trial resulting in success. Range: 0 ≤ p ≤ 1.</param>
public NegativeBinomial(double r, double p)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(r, p);
}
@ -73,7 +73,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public NegativeBinomial(double r, double p, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(r, p);
}
@ -140,7 +140,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>
/// Gets the mean of the distribution.

6
src/Numerics/Distributions/Normal.cs

@ -82,7 +82,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="stddev">The standard deviation (σ) of the normal distribution. Range: σ ≥ 0.</param>
public Normal(double mean, double stddev)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(mean, stddev);
}
@ -95,7 +95,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public Normal(double mean, double stddev, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(mean, stddev);
}
@ -225,7 +225,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

6
src/Numerics/Distributions/NormalGamma.cs

@ -119,7 +119,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="precisionInverseScale">The inverse scale of the precision.</param>
public NormalGamma(double meanLocation, double meanScale, double precisionShape, double precisionInverseScale)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(meanLocation, meanScale, precisionShape, precisionInverseScale);
}
@ -133,7 +133,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public NormalGamma(double meanLocation, double meanScale, double precisionShape, double precisionInverseScale, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(meanLocation, meanScale, precisionShape, precisionInverseScale);
}
@ -223,7 +223,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

6
src/Numerics/Distributions/Pareto.cs

@ -62,7 +62,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentException">If <paramref name="scale"/> or <paramref name="shape"/> are negative.</exception>
public Pareto(double scale, double shape)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(scale, shape);
}
@ -75,7 +75,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentException">If <paramref name="scale"/> or <paramref name="shape"/> are negative.</exception>
public Pareto(double scale, double shape, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(scale, shape);
}
@ -129,7 +129,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

6
src/Numerics/Distributions/Poisson.cs

@ -56,7 +56,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="System.ArgumentOutOfRangeException">If <paramref name="lambda"/> is equal or less then 0.0.</exception>
public Poisson(double lambda)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(lambda);
}
@ -68,7 +68,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="System.ArgumentOutOfRangeException">If <paramref name="lambda"/> is equal or less then 0.0.</exception>
public Poisson(double lambda, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(lambda);
}
@ -123,7 +123,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

6
src/Numerics/Distributions/Rayleigh.cs

@ -61,7 +61,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentException">If <paramref name="scale"/> is negative.</exception>
public Rayleigh(double scale)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(scale);
}
@ -73,7 +73,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentException">If <paramref name="scale"/> is negative.</exception>
public Rayleigh(double scale, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(scale);
}
@ -116,7 +116,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

6
src/Numerics/Distributions/Stable.cs

@ -66,7 +66,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="location">The location (μ) of the distribution.</param>
public Stable(double alpha, double beta, double scale, double location)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(alpha, beta, scale, location);
}
@ -80,7 +80,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public Stable(double alpha, double beta, double scale, double location, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(alpha, beta, scale, location);
}
@ -157,7 +157,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

8
src/Numerics/Distributions/StudentT.cs

@ -70,7 +70,7 @@ namespace MathNet.Numerics.Distributions
/// </summary>
public StudentT()
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(0.0, 1.0, 1.0);
}
@ -83,7 +83,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="freedom">The degrees of freedom (ν) for the distribution. Range: ν > 0.</param>
public StudentT(double location, double scale, double freedom)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(location, scale, freedom);
}
@ -97,7 +97,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public StudentT(double location, double scale, double freedom, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(location, scale, freedom);
}
@ -162,7 +162,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

6
src/Numerics/Distributions/Triangular.cs

@ -60,7 +60,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentException">If the upper bound is smaller than the mode or if the mode is smaller than the lower bound.</exception>
public Triangular(double lower, double upper, double mode)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(lower, upper, mode);
}
@ -74,7 +74,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentException">If the upper bound is smaller than the mode or if the mode is smaller than the lower bound.</exception>
public Triangular(double lower, double upper, double mode, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(lower, upper, mode);
}
@ -130,7 +130,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

6
src/Numerics/Distributions/Weibull.cs

@ -70,7 +70,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="scale">The scale (λ) of the Weibull distribution. Range: λ > 0.</param>
public Weibull(double shape, double scale)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(shape, scale);
}
@ -82,7 +82,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public Weibull(double shape, double scale, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(shape, scale);
}
@ -137,7 +137,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

14
src/Numerics/Distributions/Wishart.cs

@ -75,7 +75,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="scale">The scale matrix (V) for the Wishart distribution.</param>
public Wishart(double degreesOfFreedom, Matrix<double> scale)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(degreesOfFreedom, scale);
}
@ -87,7 +87,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public Wishart(double degreesOfFreedom, Matrix<double> scale, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(degreesOfFreedom, scale);
}
@ -171,15 +171,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set
{
if (value == null)
{
throw new ArgumentNullException();
}
_random = value;
}
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

6
src/Numerics/Distributions/Zipf.cs

@ -69,7 +69,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="n">The n parameter of the distribution.</param>
public Zipf(double s, int n)
{
_random = MersenneTwister.Default;
_random = SystemRandomSource.Default;
SetParameters(s, n);
}
@ -81,7 +81,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public Zipf(double s, int n, System.Random randomSource)
{
_random = randomSource ?? MersenneTwister.Default;
_random = randomSource ?? SystemRandomSource.Default;
SetParameters(s, n);
}
@ -146,7 +146,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? MersenneTwister.Default; }
set { _random = value ?? SystemRandomSource.Default; }
}
/// <summary>

Loading…
Cancel
Save