Browse Source

Distributions: ctor overloads that accept Random argument

v2
Christoph Ruegg 13 years ago
parent
commit
77fa705335
  1. 16
      src/Numerics/Distributions/Continuous/Beta.cs
  2. 30
      src/Numerics/Distributions/Continuous/Cauchy.cs
  3. 18
      src/Numerics/Distributions/Continuous/Chi.cs
  4. 17
      src/Numerics/Distributions/Continuous/ChiSquare.cs
  5. 19
      src/Numerics/Distributions/Continuous/ContinuousUniform.cs
  6. 23
      src/Numerics/Distributions/Continuous/Erlang.cs
  7. 18
      src/Numerics/Distributions/Continuous/Exponential.cs
  8. 25
      src/Numerics/Distributions/Continuous/FisherSnedecor.cs
  9. 15
      src/Numerics/Distributions/Continuous/Gamma.cs
  10. 23
      src/Numerics/Distributions/Continuous/InverseGamma.cs
  11. 31
      src/Numerics/Distributions/Continuous/Laplace.cs
  12. 24
      src/Numerics/Distributions/Continuous/LogNormal.cs
  13. 29
      src/Numerics/Distributions/Continuous/Normal.cs
  14. 28
      src/Numerics/Distributions/Continuous/Pareto.cs
  15. 23
      src/Numerics/Distributions/Continuous/Rayleigh.cs
  16. 33
      src/Numerics/Distributions/Continuous/Stable.cs
  17. 21
      src/Numerics/Distributions/Continuous/StudentT.cs
  18. 15
      src/Numerics/Distributions/Continuous/Weibull.cs
  19. 15
      src/Numerics/Distributions/Discrete/Bernoulli.cs
  20. 17
      src/Numerics/Distributions/Discrete/Binomial.cs
  21. 18
      src/Numerics/Distributions/Discrete/Categorical.cs
  22. 23
      src/Numerics/Distributions/Discrete/ConwayMaxwellPoisson.cs
  23. 15
      src/Numerics/Distributions/Discrete/DiscreteUniform.cs
  24. 15
      src/Numerics/Distributions/Discrete/Geometric.cs
  25. 16
      src/Numerics/Distributions/Discrete/Hypergeometric.cs
  26. 17
      src/Numerics/Distributions/Discrete/NegativeBinomial.cs
  27. 16
      src/Numerics/Distributions/Discrete/Poisson.cs
  28. 23
      src/Numerics/Distributions/Discrete/Zipf.cs
  29. 53
      src/Numerics/Distributions/Multivariate/Dirichlet.cs
  30. 28
      src/Numerics/Distributions/Multivariate/InverseWishart.cs
  31. 38
      src/Numerics/Distributions/Multivariate/MatrixNormal.cs
  32. 23
      src/Numerics/Distributions/Multivariate/Multinomial.cs
  33. 46
      src/Numerics/Distributions/Multivariate/NormalGamma.cs
  34. 28
      src/Numerics/Distributions/Multivariate/Wishart.cs
  35. 2
      src/Numerics/Numerics.csproj
  36. 5
      src/Numerics/Statistics/MCMC/HybridMC.cs
  37. 3
      src/Numerics/Statistics/MCMC/UnivariateHybridMC.cs
  38. 15
      src/UnitTests/IntegralTransformsTests/FourierTest.cs
  39. 9
      src/UnitTests/IntegralTransformsTests/HartleyTest.cs
  40. 43
      src/UnitTests/IntegralTransformsTests/InverseTransformTest.cs
  41. 9
      src/UnitTests/IntegralTransformsTests/MatchingNaiveTransformTest.cs
  42. 13
      src/UnitTests/IntegralTransformsTests/ParsevalTheoremTest.cs
  43. 5
      src/UnitTests/InterpolationTests/LinearInterpolationCase.cs
  44. 30
      src/UnitTests/LinearAlgebraTests/Complex/MatrixLoader.cs
  45. 4
      src/UnitTests/LinearAlgebraTests/Complex/MatrixStructureTheory.cs
  46. 30
      src/UnitTests/LinearAlgebraTests/Complex32/MatrixLoader.cs
  47. 4
      src/UnitTests/LinearAlgebraTests/Complex32/MatrixStructureTheory.cs
  48. 30
      src/UnitTests/LinearAlgebraTests/Double/MatrixLoader.cs
  49. 4
      src/UnitTests/LinearAlgebraTests/Double/MatrixStructureTheory.cs
  50. 30
      src/UnitTests/LinearAlgebraTests/Single/MatrixLoader.cs
  51. 4
      src/UnitTests/LinearAlgebraTests/Single/MatrixStructureTheory.cs
  52. 27
      src/UnitTests/StatisticsTests/MCMCTests/RejectionSamplerTests.cs
  53. 7
      src/UnitTests/StatisticsTests/StatisticsTests.cs

16
src/Numerics/Distributions/Continuous/Beta.cs

@ -71,8 +71,21 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentOutOfRangeException">If any of the Beta parameters are negative.</exception> /// <exception cref="ArgumentOutOfRangeException">If any of the Beta parameters are negative.</exception>
public Beta(double a, double b) public Beta(double a, double b)
{ {
_random = new Random();
SetParameters(a, b);
}
/// <summary>
/// Initializes a new instance of the Beta class.
/// </summary>
/// <param name="a">The a shape parameter of the Beta distribution.</param>
/// <param name="b">The b shape parameter of the Beta distribution.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
/// <exception cref="ArgumentOutOfRangeException">If any of the Beta parameters are negative.</exception>
public Beta(double a, double b, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(a, b); SetParameters(a, b);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -143,7 +156,6 @@ namespace MathNet.Numerics.Distributions
public Random RandomSource public Random RandomSource
{ {
get { return _random; } get { return _random; }
set set
{ {
if (value == null) if (value == null)

30
src/Numerics/Distributions/Continuous/Cauchy.cs

@ -54,27 +54,33 @@ namespace MathNet.Numerics.Distributions
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Cauchy"/> class with the location parameter set to 0 and the scale parameter set to 1 /// Initializes a new instance of the <see cref="Cauchy"/> class with the location parameter set to 0 and the scale parameter set to 1
/// </summary> /// </summary>
public Cauchy() public Cauchy() : this(0, 1)
: this(0, 1)
{ {
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Cauchy"/> class. /// Initializes a new instance of the <see cref="Cauchy"/> class.
/// </summary> /// </summary>
/// <param name="location"> /// <param name="location">The location parameter for the distribution.</param>
/// The location parameter for the distribution. /// <param name="scale">The scale parameter for the distribution.</param>
/// </param> /// <exception cref="ArgumentException">If <paramref name="scale"/> is negative.</exception>
/// <param name="scale">
/// The scale parameter for the distribution.
/// </param>
/// <exception cref="ArgumentException">
/// If <paramref name="scale"/> is negative.
/// </exception>
public Cauchy(double location, double scale) public Cauchy(double location, double scale)
{ {
_random = new Random();
SetParameters(location, scale);
}
/// <summary>
/// Initializes a new instance of the <see cref="Cauchy"/> class.
/// </summary>
/// <param name="location">The location parameter for the distribution.</param>
/// <param name="scale">The scale parameter for the distribution.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
/// <exception cref="ArgumentException">If <paramref name="scale"/> is negative.</exception>
public Cauchy(double location, double scale, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(location, scale); SetParameters(location, scale);
RandomSource = new Random();
} }
/// <summary> /// <summary>

18
src/Numerics/Distributions/Continuous/Chi.cs

@ -57,13 +57,22 @@ namespace MathNet.Numerics.Distributions
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Chi"/> class. /// Initializes a new instance of the <see cref="Chi"/> class.
/// </summary> /// </summary>
/// <param name="dof"> /// <param name="dof">The degrees of freedom for the Chi distribution.</param>
/// The degrees of freedom for the Chi distribution.
/// </param>
public Chi(double dof) public Chi(double dof)
{ {
_random = new Random();
SetParameters(dof);
}
/// <summary>
/// Initializes a new instance of the <see cref="Chi"/> class.
/// </summary>
/// <param name="dof">The degrees of freedom for the Chi distribution.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public Chi(double dof, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(dof); SetParameters(dof);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -123,7 +132,6 @@ namespace MathNet.Numerics.Distributions
public Random RandomSource public Random RandomSource
{ {
get { return _random; } get { return _random; }
set set
{ {
if (value == null) if (value == null)

17
src/Numerics/Distributions/Continuous/ChiSquare.cs

@ -54,13 +54,22 @@ namespace MathNet.Numerics.Distributions
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ChiSquare"/> class. /// Initializes a new instance of the <see cref="ChiSquare"/> class.
/// </summary> /// </summary>
/// <param name="dof"> /// <param name="dof">The degrees of freedom for the ChiSquare distribution.</param>
/// The degrees of freedom for the ChiSquare distribution.
/// </param>
public ChiSquare(double dof) public ChiSquare(double dof)
{ {
_random = new Random();
SetParameters(dof);
}
/// <summary>
/// Initializes a new instance of the <see cref="ChiSquare"/> class.
/// </summary>
/// <param name="dof">The degrees of freedom for the ChiSquare distribution.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public ChiSquare(double dof, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(dof); SetParameters(dof);
RandomSource = new Random();
} }
/// <summary> /// <summary>

19
src/Numerics/Distributions/Continuous/ContinuousUniform.cs

@ -63,8 +63,7 @@ namespace MathNet.Numerics.Distributions
/// <summary> /// <summary>
/// Initializes a new instance of the ContinuousUniform class with lower bound 0 and upper bound 1. /// Initializes a new instance of the ContinuousUniform class with lower bound 0 and upper bound 1.
/// </summary> /// </summary>
public ContinuousUniform() public ContinuousUniform() : this(0.0, 1.0)
: this(0.0, 1.0)
{ {
} }
@ -76,8 +75,21 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentException">If the upper bound is smaller than the lower bound.</exception> /// <exception cref="ArgumentException">If the upper bound is smaller than the lower bound.</exception>
public ContinuousUniform(double lower, double upper) public ContinuousUniform(double lower, double upper)
{ {
_random = new Random();
SetParameters(lower, upper);
}
/// <summary>
/// Initializes a new instance of the ContinuousUniform class with given lower and upper bounds.
/// </summary>
/// <param name="lower">Lower bound.</param>
/// <param name="upper">Upper bound; must be at least as large as lower.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
/// <exception cref="ArgumentException">If the upper bound is smaller than the lower bound.</exception>
public ContinuousUniform(double lower, double upper, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(lower, upper); SetParameters(lower, upper);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -155,7 +167,6 @@ namespace MathNet.Numerics.Distributions
public Random RandomSource public Random RandomSource
{ {
get { return _random; } get { return _random; }
set set
{ {
if (value == null) if (value == null)

23
src/Numerics/Distributions/Continuous/Erlang.cs

@ -61,16 +61,24 @@ namespace MathNet.Numerics.Distributions
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Erlang"/> class. /// Initializes a new instance of the <see cref="Erlang"/> class.
/// </summary> /// </summary>
/// <param name="shape"> /// <param name="shape">The shape of the Erlang distribution.</param>
/// The shape of the Erlang distribution. /// <param name="invScale">The inverse scale of the Erlang distribution.</param>
/// </param>
/// <param name="invScale">
/// The inverse scale of the Erlang distribution.
/// </param>
public Erlang(int shape, double invScale) public Erlang(int shape, double invScale)
{ {
_random = new Random();
SetParameters(shape, invScale);
}
/// <summary>
/// Initializes a new instance of the <see cref="Erlang"/> class.
/// </summary>
/// <param name="shape">The shape of the Erlang distribution.</param>
/// <param name="invScale">The inverse scale of the Erlang distribution.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public Erlang(int shape, double invScale, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(shape, invScale); SetParameters(shape, invScale);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -186,7 +194,6 @@ namespace MathNet.Numerics.Distributions
public Random RandomSource public Random RandomSource
{ {
get { return _random; } get { return _random; }
set set
{ {
if (value == null) if (value == null)

18
src/Numerics/Distributions/Continuous/Exponential.cs

@ -54,13 +54,22 @@ namespace MathNet.Numerics.Distributions
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Exponential"/> class. /// Initializes a new instance of the <see cref="Exponential"/> class.
/// </summary> /// </summary>
/// <param name="lambda"> /// <param name="lambda">The lambda parameter of the Exponential distribution.</param>
/// The lambda parameter of the Exponential distribution.
/// </param>
public Exponential(double lambda) public Exponential(double lambda)
{ {
_random = new Random();
SetParameters(lambda);
}
/// <summary>
/// Initializes a new instance of the <see cref="Exponential"/> class.
/// </summary>
/// <param name="lambda">The lambda parameter of the Exponential distribution.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public Exponential(double lambda, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(lambda); SetParameters(lambda);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -125,7 +134,6 @@ namespace MathNet.Numerics.Distributions
public Random RandomSource public Random RandomSource
{ {
get { return _random; } get { return _random; }
set set
{ {
if (value == null) if (value == null)

25
src/Numerics/Distributions/Continuous/FisherSnedecor.cs

@ -59,16 +59,24 @@ namespace MathNet.Numerics.Distributions
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="FisherSnedecor"/> class. /// Initializes a new instance of the <see cref="FisherSnedecor"/> class.
/// </summary> /// </summary>
/// <param name="d1"> /// <param name="d1">The first parameter - degree of freedom.</param>
/// The first parameter - degree of freedom. /// <param name="d2">The second parameter - degree of freedom.</param>
/// </param>
/// <param name="d2">
/// The second parameter - degree of freedom.
/// </param>
public FisherSnedecor(double d1, double d2) public FisherSnedecor(double d1, double d2)
{ {
_random = new Random();
SetParameters(d1, d2);
}
/// <summary>
/// Initializes a new instance of the <see cref="FisherSnedecor"/> class.
/// </summary>
/// <param name="d1">The first parameter - degree of freedom.</param>
/// <param name="d2">The second parameter - degree of freedom.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public FisherSnedecor(double d1, double d2, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(d1, d2); SetParameters(d1, d2);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -145,12 +153,11 @@ namespace MathNet.Numerics.Distributions
public Random RandomSource public Random RandomSource
{ {
get { return _random; } get { return _random; }
set set
{ {
if (value == null) if (value == null)
{ {
throw new ArgumentNullException(Resources.InvalidDistributionParameters); throw new ArgumentNullException();
} }
_random = value; _random = value;

15
src/Numerics/Distributions/Continuous/Gamma.cs

@ -71,8 +71,20 @@ namespace MathNet.Numerics.Distributions
/// <param name="invScale">The inverse scale of the Gamma distribution.</param> /// <param name="invScale">The inverse scale of the Gamma distribution.</param>
public Gamma(double shape, double invScale) public Gamma(double shape, double invScale)
{ {
_random = new Random();
SetParameters(shape, invScale);
}
/// <summary>
/// Initializes a new instance of the Gamma class.
/// </summary>
/// <param name="shape">The shape of the Gamma distribution.</param>
/// <param name="invScale">The inverse scale of the Gamma distribution.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public Gamma(double shape, double invScale, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(shape, invScale); SetParameters(shape, invScale);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -189,7 +201,6 @@ namespace MathNet.Numerics.Distributions
public Random RandomSource public Random RandomSource
{ {
get { return _random; } get { return _random; }
set set
{ {
if (value == null) if (value == null)

23
src/Numerics/Distributions/Continuous/InverseGamma.cs

@ -60,16 +60,24 @@ namespace MathNet.Numerics.Distributions
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="InverseGamma"/> class. /// Initializes a new instance of the <see cref="InverseGamma"/> class.
/// </summary> /// </summary>
/// <param name="shape"> /// <param name="shape">The shape (alpha) parameter of the inverse Gamma distribution.</param>
/// The shape (alpha) parameter of the inverse Gamma distribution. /// <param name="scale">The scale (beta) parameter of the inverse Gamma distribution.</param>
/// </param>
/// <param name="scale">
/// The scale (beta) parameter of the inverse Gamma distribution.
/// </param>
public InverseGamma(double shape, double scale) public InverseGamma(double shape, double scale)
{ {
SetParameters(shape, scale);
_random = new Random(); _random = new Random();
SetParameters(shape, scale);
}
/// <summary>
/// Initializes a new instance of the <see cref="InverseGamma"/> class.
/// </summary>
/// <param name="shape">The shape (alpha) parameter of the inverse Gamma distribution.</param>
/// <param name="scale">The scale (beta) parameter of the inverse Gamma distribution.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public InverseGamma(double shape, double scale, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(shape, scale);
} }
/// <summary> /// <summary>
@ -155,7 +163,6 @@ namespace MathNet.Numerics.Distributions
public Random RandomSource public Random RandomSource
{ {
get { return _random; } get { return _random; }
set set
{ {
if (value == null) if (value == null)

31
src/Numerics/Distributions/Continuous/Laplace.cs

@ -76,27 +76,33 @@ namespace MathNet.Numerics.Distributions
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Laplace"/> class (location = 0, scale = 1). /// Initializes a new instance of the <see cref="Laplace"/> class (location = 0, scale = 1).
/// </summary> /// </summary>
public Laplace() public Laplace() : this(0.0, 1.0)
: this(0.0, 1.0)
{ {
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Laplace"/> class. /// Initializes a new instance of the <see cref="Laplace"/> class.
/// </summary> /// </summary>
/// <param name="location"> /// <param name="location">The location for the Laplace distribution.</param>
/// The location for the Laplace distribution. /// <param name="scale">The scale for the Laplace distribution.</param>
/// </param> /// <exception cref="ArgumentException">If <paramref name="scale"/> is negative.</exception>
/// <param name="scale">
/// The scale for the Laplace distribution.
/// </param>
/// <exception cref="ArgumentException">
/// If <paramref name="scale"/> is negative.
/// </exception>
public Laplace(double location, double scale) public Laplace(double location, double scale)
{ {
_random = new Random();
SetParameters(location, scale);
}
/// <summary>
/// Initializes a new instance of the <see cref="Laplace"/> class.
/// </summary>
/// <param name="location">The location for the Laplace distribution.</param>
/// <param name="scale">The scale for the Laplace distribution.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
/// <exception cref="ArgumentException">If <paramref name="scale"/> is negative.</exception>
public Laplace(double location, double scale, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(location, scale); SetParameters(location, scale);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -154,7 +160,6 @@ namespace MathNet.Numerics.Distributions
public Random RandomSource public Random RandomSource
{ {
get { return _random; } get { return _random; }
set set
{ {
if (value == null) if (value == null)

24
src/Numerics/Distributions/Continuous/LogNormal.cs

@ -61,16 +61,26 @@ namespace MathNet.Numerics.Distributions
/// The distribution will be initialized with the default <seealso cref="System.Random"/> /// The distribution will be initialized with the default <seealso cref="System.Random"/>
/// random number generator. /// random number generator.
/// </summary> /// </summary>
/// <param name="mu"> /// <param name="mu">The mu of the logarithm of the distribution.</param>
/// The mu of the logarithm of the distribution. /// <param name="sigma">The standard deviation of the logarithm of the distribution.</param>
/// </param>
/// <param name="sigma">
/// The standard deviation of the logarithm of the distribution.
/// </param>
public LogNormal(double mu, double sigma) public LogNormal(double mu, double sigma)
{ {
_random = new Random();
SetParameters(mu, sigma);
}
/// <summary>
/// Initializes a new instance of the <see cref="LogNormal"/> class.
/// The distribution will be initialized with the default <seealso cref="System.Random"/>
/// random number generator.
/// </summary>
/// <param name="mu">The mu of the logarithm of the distribution.</param>
/// <param name="sigma">The standard deviation of the logarithm of the distribution.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public LogNormal(double mu, double sigma, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(mu, sigma); SetParameters(mu, sigma);
RandomSource = new Random();
} }
/// <summary> /// <summary>

29
src/Numerics/Distributions/Continuous/Normal.cs

@ -61,8 +61,17 @@ namespace MathNet.Numerics.Distributions
/// and standard deviation 1.0. The distribution will /// and standard deviation 1.0. The distribution will
/// be initialized with the default <seealso cref="System.Random"/> random number generator. /// be initialized with the default <seealso cref="System.Random"/> random number generator.
/// </summary> /// </summary>
public Normal() public Normal() : this(0.0, 1.0)
: this(0.0, 1.0) {
}
/// <summary>
/// Initializes a new instance of the Normal class. This is a normal distribution with mean 0.0
/// and standard deviation 1.0. The distribution will
/// be initialized with the default <seealso cref="System.Random"/> random number generator.
/// </summary>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public Normal(Random randomSource) : this(0.0, 1.0, randomSource)
{ {
} }
@ -74,8 +83,21 @@ namespace MathNet.Numerics.Distributions
/// <param name="stddev">The standard deviation of the normal distribution.</param> /// <param name="stddev">The standard deviation of the normal distribution.</param>
public Normal(double mean, double stddev) public Normal(double mean, double stddev)
{ {
_random = new Random();
SetParameters(mean, stddev);
}
/// <summary>
/// Initializes a new instance of the Normal class with a particular mean and standard deviation. The distribution will
/// be initialized with the default <seealso cref="System.Random"/> random number generator.
/// </summary>
/// <param name="mean">The mean of the normal distribution.</param>
/// <param name="stddev">The standard deviation of the normal distribution.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public Normal(double mean, double stddev, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(mean, stddev); SetParameters(mean, stddev);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -185,7 +207,6 @@ namespace MathNet.Numerics.Distributions
public Random RandomSource public Random RandomSource
{ {
get { return _random; } get { return _random; }
set set
{ {
if (value == null) if (value == null)

28
src/Numerics/Distributions/Continuous/Pareto.cs

@ -61,19 +61,26 @@ namespace MathNet.Numerics.Distributions
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Pareto"/> class. /// Initializes a new instance of the <see cref="Pareto"/> class.
/// </summary> /// </summary>
/// <param name="scale"> /// <param name="scale">The scale parameter of the distribution.</param>
/// The scale parameter of the distribution. /// <param name="shape">The shape parameter of the distribution.</param>
/// </param> /// <exception cref="ArgumentException">If <paramref name="scale"/> or <paramref name="shape"/> are negative.</exception>
/// <param name="shape">
/// The shape parameter of the distribution.
/// </param>
/// <exception cref="ArgumentException">
/// If <paramref name="scale"/> or <paramref name="shape"/> are negative.
/// </exception>
public Pareto(double scale, double shape) public Pareto(double scale, double shape)
{ {
_random = new Random();
SetParameters(scale, shape);
}
/// <summary>
/// Initializes a new instance of the <see cref="Pareto"/> class.
/// </summary>
/// <param name="scale">The scale parameter of the distribution.</param>
/// <param name="shape">The shape parameter of the distribution.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
/// <exception cref="ArgumentException">If <paramref name="scale"/> or <paramref name="shape"/> are negative.</exception>
public Pareto(double scale, double shape, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(scale, shape); SetParameters(scale, shape);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -151,7 +158,6 @@ namespace MathNet.Numerics.Distributions
public Random RandomSource public Random RandomSource
{ {
get { return _random; } get { return _random; }
set set
{ {
if (value == null) if (value == null)

23
src/Numerics/Distributions/Continuous/Rayleigh.cs

@ -57,16 +57,24 @@ namespace MathNet.Numerics.Distributions
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Rayleigh"/> class. /// Initializes a new instance of the <see cref="Rayleigh"/> class.
/// </summary> /// </summary>
/// <param name="scale"> /// <param name="scale">The scale parameter of the distribution.</param>
/// The scale parameter of the distribution. /// <exception cref="ArgumentException">If <paramref name="scale"/> is negative.</exception>
/// </param>
/// <exception cref="ArgumentException">
/// If <paramref name="scale"/> is negative.
/// </exception>
public Rayleigh(double scale) public Rayleigh(double scale)
{ {
_random = new Random();
SetParameters(scale);
}
/// <summary>
/// Initializes a new instance of the <see cref="Rayleigh"/> class.
/// </summary>
/// <param name="scale">The scale parameter of the distribution.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
/// <exception cref="ArgumentException">If <paramref name="scale"/> is negative.</exception>
public Rayleigh(double scale, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(scale); SetParameters(scale);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -131,7 +139,6 @@ namespace MathNet.Numerics.Distributions
public Random RandomSource public Random RandomSource
{ {
get { return _random; } get { return _random; }
set set
{ {
if (value == null) if (value == null)

33
src/Numerics/Distributions/Continuous/Stable.cs

@ -72,22 +72,28 @@ namespace MathNet.Numerics.Distributions
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Stable"/> class. /// Initializes a new instance of the <see cref="Stable"/> class.
/// </summary> /// </summary>
/// <param name="alpha"> /// <param name="alpha">The stability parameter of the distribution.</param>
/// The stability parameter of the distribution. /// <param name="beta">The skewness parameter of the distribution.</param>
/// </param> /// <param name="scale">The scale parameter of the distribution.</param>
/// <param name="beta"> /// <param name="location">The location parameter of the distribution.</param>
/// The skewness parameter of the distribution.
/// </param>
/// <param name="scale">
/// The scale parameter of the distribution.
/// </param>
/// <param name="location">
/// The location parameter of the distribution.
/// </param>
public Stable(double alpha, double beta, double scale, double location) public Stable(double alpha, double beta, double scale, double location)
{ {
_random = new Random();
SetParameters(alpha, beta, scale, location);
}
/// <summary>
/// Initializes a new instance of the <see cref="Stable"/> class.
/// </summary>
/// <param name="alpha">The stability parameter of the distribution.</param>
/// <param name="beta">The skewness parameter of the distribution.</param>
/// <param name="scale">The scale parameter of the distribution.</param>
/// <param name="location">The location parameter of the distribution.</param>
/// <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, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(alpha, beta, scale, location); SetParameters(alpha, beta, scale, location);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -200,7 +206,6 @@ namespace MathNet.Numerics.Distributions
public Random RandomSource public Random RandomSource
{ {
get { return _random; } get { return _random; }
set set
{ {
if (value == null) if (value == null)

21
src/Numerics/Distributions/Continuous/StudentT.cs

@ -77,8 +77,7 @@ namespace MathNet.Numerics.Distributions
/// scale 1.0 and degrees of freedom 1. The distribution will /// scale 1.0 and degrees of freedom 1. The distribution will
/// be initialized with the default <seealso cref="System.Random"/> random number generator. /// be initialized with the default <seealso cref="System.Random"/> random number generator.
/// </summary> /// </summary>
public StudentT() public StudentT() : this(0.0, 1.0, 1.0)
: this(0.0, 1.0, 1.0)
{ {
} }
@ -92,8 +91,23 @@ namespace MathNet.Numerics.Distributions
/// <param name="dof">The degrees of freedom for the Student t-distribution.</param> /// <param name="dof">The degrees of freedom for the Student t-distribution.</param>
public StudentT(double location, double scale, double dof) public StudentT(double location, double scale, double dof)
{ {
_random = new Random();
SetParameters(location, scale, dof);
}
/// <summary>
/// Initializes a new instance of the StudentT class with a particular location, scale and degrees of
/// freedom. The distribution will
/// be initialized with the default <seealso cref="System.Random"/> random number generator.
/// </summary>
/// <param name="location">The location of the Student t-distribution.</param>
/// <param name="scale">The scale of the Student t-distribution.</param>
/// <param name="dof">The degrees of freedom for the Student t-distribution.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public StudentT(double location, double scale, double dof, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(location, scale, dof); SetParameters(location, scale, dof);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -179,7 +193,6 @@ namespace MathNet.Numerics.Distributions
public Random RandomSource public Random RandomSource
{ {
get { return _random; } get { return _random; }
set set
{ {
if (value == null) if (value == null)

15
src/Numerics/Distributions/Continuous/Weibull.cs

@ -78,8 +78,20 @@ namespace MathNet.Numerics.Distributions
/// <param name="scale">The inverse scale of the Weibull distribution.</param> /// <param name="scale">The inverse scale of the Weibull distribution.</param>
public Weibull(double shape, double scale) public Weibull(double shape, double scale)
{ {
_random = new Random();
SetParameters(shape, scale);
}
/// <summary>
/// Initializes a new instance of the Weibull class.
/// </summary>
/// <param name="shape">The shape of the Weibull distribution.</param>
/// <param name="scale">The inverse scale of the Weibull distribution.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public Weibull(double shape, double scale, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(shape, scale); SetParameters(shape, scale);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -153,7 +165,6 @@ namespace MathNet.Numerics.Distributions
public Random RandomSource public Random RandomSource
{ {
get { return _random; } get { return _random; }
set set
{ {
if (value == null) if (value == null)

15
src/Numerics/Distributions/Discrete/Bernoulli.cs

@ -59,8 +59,20 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentOutOfRangeException">If the Bernoulli parameter is not in the range [0,1].</exception> /// <exception cref="ArgumentOutOfRangeException">If the Bernoulli parameter is not in the range [0,1].</exception>
public Bernoulli(double p) public Bernoulli(double p)
{ {
_random = new Random();
SetParameters(p);
}
/// <summary>
/// Initializes a new instance of the Bernoulli class.
/// </summary>
/// <param name="p">The probability of generating one.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
/// <exception cref="ArgumentOutOfRangeException">If the Bernoulli parameter is not in the range [0,1].</exception>
public Bernoulli(double p, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(p); SetParameters(p);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -120,7 +132,6 @@ namespace MathNet.Numerics.Distributions
public Random RandomSource public Random RandomSource
{ {
get { return _random; } get { return _random; }
set set
{ {
if (value == null) if (value == null)

17
src/Numerics/Distributions/Discrete/Binomial.cs

@ -66,8 +66,22 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="n"/> is negative.</exception> /// <exception cref="ArgumentOutOfRangeException">If <paramref name="n"/> is negative.</exception>
public Binomial(double p, int n) public Binomial(double p, int n)
{ {
_random = new Random();
SetParameters(p, n);
}
/// <summary>
/// Initializes a new instance of the Binomial class.
/// </summary>
/// <param name="p">The success probability of a trial.</param>
/// <param name="n">The number of trials.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="p"/> is not in the interval [0.0,1.0].</exception>
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="n"/> is negative.</exception>
public Binomial(double p, int n, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(p, n); SetParameters(p, n);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -146,7 +160,6 @@ namespace MathNet.Numerics.Distributions
public Random RandomSource public Random RandomSource
{ {
get { return _random; } get { return _random; }
set set
{ {
if (value == null) if (value == null)

18
src/Numerics/Distributions/Discrete/Categorical.cs

@ -63,8 +63,21 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentException">If any of the probabilities are negative or do not sum to one.</exception> /// <exception cref="ArgumentException">If any of the probabilities are negative or do not sum to one.</exception>
public Categorical(double[] probabilityMass) public Categorical(double[] probabilityMass)
{ {
_random = new Random();
SetParameters(probabilityMass);
}
/// <summary>
/// Initializes a new instance of the Categorical class.
/// </summary>
/// <param name="probabilityMass">An array of nonnegative ratios: this array does not need to be normalized
/// as this is often impossible using floating point arithmetic.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
/// <exception cref="ArgumentException">If any of the probabilities are negative or do not sum to one.</exception>
public Categorical(double[] probabilityMass, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(probabilityMass); SetParameters(probabilityMass);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -89,8 +102,8 @@ namespace MathNet.Numerics.Distributions
p[i] = histogram[i].Count; p[i] = histogram[i].Count;
} }
_random = new Random();
SetParameters(p); SetParameters(p);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -196,7 +209,6 @@ namespace MathNet.Numerics.Distributions
public Random RandomSource public Random RandomSource
{ {
get { return _random; } get { return _random; }
set set
{ {
if (value == null) if (value == null)

23
src/Numerics/Distributions/Discrete/ConwayMaxwellPoisson.cs

@ -87,16 +87,24 @@ namespace MathNet.Numerics.Distributions
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ConwayMaxwellPoisson"/> class. /// Initializes a new instance of the <see cref="ConwayMaxwellPoisson"/> class.
/// </summary> /// </summary>
/// <param name="lambda"> /// <param name="lambda">The lambda parameter.</param>
/// The lambda parameter. /// <param name="nu">The nu parameter.</param>
/// </param>
/// <param name="nu">
/// The nu parameter.
/// </param>
public ConwayMaxwellPoisson(double lambda, double nu) public ConwayMaxwellPoisson(double lambda, double nu)
{ {
_random = new Random();
SetParameters(lambda, nu);
}
/// <summary>
/// Initializes a new instance of the <see cref="ConwayMaxwellPoisson"/> class.
/// </summary>
/// <param name="lambda">The lambda parameter.</param>
/// <param name="nu">The nu parameter.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public ConwayMaxwellPoisson(double lambda, double nu, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(lambda, nu); SetParameters(lambda, nu);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -178,7 +186,6 @@ namespace MathNet.Numerics.Distributions
public Random RandomSource public Random RandomSource
{ {
get { return _random; } get { return _random; }
set set
{ {
if (value == null) if (value == null)

15
src/Numerics/Distributions/Discrete/DiscreteUniform.cs

@ -64,8 +64,20 @@ namespace MathNet.Numerics.Distributions
/// <param name="upper">Upper bound; must be at least as large as <paramref name="lower"/>.</param> /// <param name="upper">Upper bound; must be at least as large as <paramref name="lower"/>.</param>
public DiscreteUniform(int lower, int upper) public DiscreteUniform(int lower, int upper)
{ {
_random = new Random();
SetParameters(lower, upper);
}
/// <summary>
/// Initializes a new instance of the DiscreteUniform class.
/// </summary>
/// <param name="lower">Lower bound.</param>
/// <param name="upper">Upper bound; must be at least as large as <paramref name="lower"/>.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public DiscreteUniform(int lower, int upper, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(lower, upper); SetParameters(lower, upper);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -140,7 +152,6 @@ namespace MathNet.Numerics.Distributions
public Random RandomSource public Random RandomSource
{ {
get { return _random; } get { return _random; }
set set
{ {
if (value == null) if (value == null)

15
src/Numerics/Distributions/Discrete/Geometric.cs

@ -59,8 +59,20 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentOutOfRangeException">If the Geometric parameter is not in the range [0,1].</exception> /// <exception cref="ArgumentOutOfRangeException">If the Geometric parameter is not in the range [0,1].</exception>
public Geometric(double p) public Geometric(double p)
{ {
_random = new Random();
SetParameters(p);
}
/// <summary>
/// Initializes a new instance of the Geometric class.
/// </summary>
/// <param name="p">The probability of generating one.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
/// <exception cref="ArgumentOutOfRangeException">If the Geometric parameter is not in the range [0,1].</exception>
public Geometric(double p, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(p); SetParameters(p);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -122,7 +134,6 @@ namespace MathNet.Numerics.Distributions
public Random RandomSource public Random RandomSource
{ {
get { return _random; } get { return _random; }
set set
{ {
if (value == null) if (value == null)

16
src/Numerics/Distributions/Discrete/Hypergeometric.cs

@ -77,8 +77,21 @@ namespace MathNet.Numerics.Distributions
/// <param name="n">The n parameter of the distribution.</param> /// <param name="n">The n parameter of the distribution.</param>
public Hypergeometric(int populationSize, int m, int n) public Hypergeometric(int populationSize, int m, int n)
{ {
_random = new Random();
SetParameters(populationSize, m, n);
}
/// <summary>
/// Initializes a new instance of the Hypergeometric class.
/// </summary>
/// <param name="populationSize">The population size.</param>
/// <param name="m">The m parameter of the distribution.</param>
/// <param name="n">The n parameter of the distribution.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public Hypergeometric(int populationSize, int m, int n, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(populationSize, m, n); SetParameters(populationSize, m, n);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -167,7 +180,6 @@ namespace MathNet.Numerics.Distributions
public Random RandomSource public Random RandomSource
{ {
get { return _random; } get { return _random; }
set set
{ {
if (value == null) if (value == null)

17
src/Numerics/Distributions/Discrete/NegativeBinomial.cs

@ -64,7 +64,6 @@ namespace MathNet.Numerics.Distributions
public double R public double R
{ {
get { return _r; } get { return _r; }
set { SetParameters(value, _p); } set { SetParameters(value, _p); }
} }
@ -74,7 +73,6 @@ namespace MathNet.Numerics.Distributions
public double P public double P
{ {
get { return _p; } get { return _p; }
set { SetParameters(_r, value); } set { SetParameters(_r, value); }
} }
@ -85,8 +83,20 @@ namespace MathNet.Numerics.Distributions
/// <param name="p">The probability of a trial resulting in success.</param> /// <param name="p">The probability of a trial resulting in success.</param>
public NegativeBinomial(double r, double p) public NegativeBinomial(double r, double p)
{ {
_random = new Random();
SetParameters(r, p);
}
/// <summary>
/// Initializes a new instance of the <see cref="NegativeBinomial"/> class.
/// </summary>
/// <param name="r">The number of trials.</param>
/// <param name="p">The probability of a trial resulting in success.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public NegativeBinomial(double r, double p, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(r, p); SetParameters(r, p);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -146,7 +156,6 @@ namespace MathNet.Numerics.Distributions
public Random RandomSource public Random RandomSource
{ {
get { return _random; } get { return _random; }
set set
{ {
if (value == null) if (value == null)

16
src/Numerics/Distributions/Discrete/Poisson.cs

@ -56,7 +56,6 @@ namespace MathNet.Numerics.Distributions
public double Lambda public double Lambda
{ {
get { return _lambda; } get { return _lambda; }
set { SetParameters(value); } set { SetParameters(value); }
} }
@ -67,8 +66,20 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="System.ArgumentOutOfRangeException">If <paramref name="lambda"/> is equal or less then 0.0.</exception> /// <exception cref="System.ArgumentOutOfRangeException">If <paramref name="lambda"/> is equal or less then 0.0.</exception>
public Poisson(double lambda) public Poisson(double lambda)
{ {
_random = new Random();
SetParameters(lambda);
}
/// <summary>
/// Initializes a new instance of the <see cref="Poisson"/> class.
/// </summary>
/// <param name="lambda">The Poisson distribution parameter λ.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
/// <exception cref="System.ArgumentOutOfRangeException">If <paramref name="lambda"/> is equal or less then 0.0.</exception>
public Poisson(double lambda, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(lambda); SetParameters(lambda);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -115,7 +126,6 @@ namespace MathNet.Numerics.Distributions
public Random RandomSource public Random RandomSource
{ {
get { return _random; } get { return _random; }
set set
{ {
if (value == null) if (value == null)

23
src/Numerics/Distributions/Discrete/Zipf.cs

@ -62,16 +62,24 @@ namespace MathNet.Numerics.Distributions
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Zipf"/> class. /// Initializes a new instance of the <see cref="Zipf"/> class.
/// </summary> /// </summary>
/// <param name="s"> /// <param name="s">The s parameter of the distribution.</param>
/// The s parameter of the distribution. /// <param name="n">The n parameter of the distribution.</param>
/// </param>
/// <param name="n">
/// The n parameter of the distribution.
/// </param>
public Zipf(double s, int n) public Zipf(double s, int n)
{ {
_random = new Random();
SetParameters(s, n);
}
/// <summary>
/// Initializes a new instance of the <see cref="Zipf"/> class.
/// </summary>
/// <param name="s">The s parameter of the distribution.</param>
/// <param name="n">The n parameter of the distribution.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public Zipf(double s, int n, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(s, n); SetParameters(s, n);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -143,7 +151,6 @@ namespace MathNet.Numerics.Distributions
public Random RandomSource public Random RandomSource
{ {
get { return _random; } get { return _random; }
set set
{ {
if (value == null) if (value == null)

53
src/Numerics/Distributions/Multivariate/Dirichlet.cs

@ -62,21 +62,27 @@ namespace MathNet.Numerics.Distributions
/// <param name="alpha">An array with the Dirichlet parameters.</param> /// <param name="alpha">An array with the Dirichlet parameters.</param>
public Dirichlet(double[] alpha) public Dirichlet(double[] alpha)
{ {
_random = new Random();
SetParameters(alpha); SetParameters(alpha);
RandomSource = new Random();
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Dirichlet"/> class. /// Initializes a new instance of the Dirichlet class. The distribution will
/// <seealso cref="System.Random"/> /// be initialized with the default <seealso cref="System.Random"/> random number generator.
/// random number generator.
/// </summary> /// </summary>
/// <param name="alpha"> /// <param name="alpha">An array with the Dirichlet parameters.</param>
/// The value of each parameter of the Dirichlet distribution. /// <param name="randomSource">The random number generator which is used to draw random samples.</param>
/// </param> public Dirichlet(double[] alpha, Random randomSource)
/// <param name="k"> {
/// The dimension of the Dirichlet distribution. _random = randomSource ?? new Random();
/// </param> SetParameters(alpha);
}
/// <summary>
/// Initializes a new instance of the <see cref="Dirichlet"/> class.
/// <seealso cref="System.Random"/>random number generator.</summary>
/// <param name="alpha">The value of each parameter of the Dirichlet distribution.</param>
/// <param name="k">The dimension of the Dirichlet distribution.</param>
public Dirichlet(double alpha, int k) public Dirichlet(double alpha, int k)
{ {
// Create a parameter structure. // Create a parameter structure.
@ -86,8 +92,27 @@ namespace MathNet.Numerics.Distributions
parm[i] = alpha; parm[i] = alpha;
} }
_random = new Random();
SetParameters(parm);
}
/// <summary>
/// Initializes a new instance of the <see cref="Dirichlet"/> class.
/// <seealso cref="System.Random"/>random number generator.</summary>
/// <param name="alpha">The value of each parameter of the Dirichlet distribution.</param>
/// <param name="k">The dimension of the Dirichlet distribution.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public Dirichlet(double alpha, int k, Random randomSource)
{
// Create a parameter structure.
var parm = new double[k];
for (var i = 0; i < k; i++)
{
parm[i] = alpha;
}
_random = randomSource ?? new Random();
SetParameters(parm); SetParameters(parm);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -301,11 +326,7 @@ namespace MathNet.Numerics.Distributions
/// </summary> /// </summary>
public Random RandomSource public Random RandomSource
{ {
get get { return _random; }
{
return _random;
}
set set
{ {
if (value == null) if (value == null)

28
src/Numerics/Distributions/Multivariate/InverseWishart.cs

@ -67,16 +67,24 @@ namespace MathNet.Numerics.Distributions
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="InverseWishart"/> class. /// Initializes a new instance of the <see cref="InverseWishart"/> class.
/// </summary> /// </summary>
/// <param name="nu"> /// <param name="nu">The degrees of freedom for the inverse Wishart distribution.</param>
/// The degrees of freedom for the inverse Wishart distribution. /// <param name="s">The scale matrix for the inverse Wishart distribution.</param>
/// </param>
/// <param name="s">
/// The scale matrix for the inverse Wishart distribution.
/// </param>
public InverseWishart(double nu, Matrix<double> s) public InverseWishart(double nu, Matrix<double> s)
{ {
_random = new Random();
SetParameters(nu, s);
}
/// <summary>
/// Initializes a new instance of the <see cref="InverseWishart"/> class.
/// </summary>
/// <param name="nu">The degrees of freedom for the inverse Wishart distribution.</param>
/// <param name="s">The scale matrix for the inverse Wishart distribution.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public InverseWishart(double nu, Matrix<double> s, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(nu, s); SetParameters(nu, s);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -172,11 +180,7 @@ namespace MathNet.Numerics.Distributions
/// </summary> /// </summary>
public Random RandomSource public Random RandomSource
{ {
get get { return _random; }
{
return _random;
}
set set
{ {
if (value == null) if (value == null)

38
src/Numerics/Distributions/Multivariate/MatrixNormal.cs

@ -68,22 +68,28 @@ namespace MathNet.Numerics.Distributions
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="MatrixNormal"/> class. /// Initializes a new instance of the <see cref="MatrixNormal"/> class.
/// </summary> /// </summary>
/// <param name="m"> /// <param name="m">The mean of the matrix normal.</param>
/// The mean of the matrix normal. /// <param name="v">The covariance matrix for the rows.</param>
/// </param> /// <param name="k">The covariance matrix for the columns.</param>
/// <param name="v"> /// <exception cref="ArgumentOutOfRangeException">If the dimensions of the mean and two covariance matrices don't match.</exception>
/// The covariance matrix for the rows.
/// </param>
/// <param name="k">
/// The covariance matrix for the columns.
/// </param>
/// <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) public MatrixNormal(Matrix<double> m, Matrix<double> v, Matrix<double> k)
{ {
_random = new Random();
SetParameters(m, v, k);
}
/// <summary>
/// Initializes a new instance of the <see cref="MatrixNormal"/> class.
/// </summary>
/// <param name="m">The mean of the matrix normal.</param>
/// <param name="v">The covariance matrix for the rows.</param>
/// <param name="k">The covariance matrix for the columns.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
/// <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 randomSource)
{
_random = randomSource ?? new Random();
SetParameters(m, v, k); SetParameters(m, v, k);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -212,11 +218,7 @@ namespace MathNet.Numerics.Distributions
/// </summary> /// </summary>
public Random RandomSource public Random RandomSource
{ {
get get { return _random; }
{
return _random;
}
set set
{ {
if (value == null) if (value == null)

23
src/Numerics/Distributions/Multivariate/Multinomial.cs

@ -73,8 +73,23 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="n"/> is negative.</exception> /// <exception cref="ArgumentOutOfRangeException">If <paramref name="n"/> is negative.</exception>
public Multinomial(double[] p, int n) public Multinomial(double[] p, int n)
{ {
_random = new Random();
SetParameters(p, n);
}
/// <summary>
/// Initializes a new instance of the Multinomial class.
/// </summary>
/// <param name="p">An array of nonnegative ratios: this array does not need to be normalized
/// as this is often impossible using floating point arithmetic.</param>
/// <param name="n">The number of trials.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
/// <exception cref="ArgumentOutOfRangeException">If any of the probabilities are negative or do not sum to one.</exception>
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="n"/> is negative.</exception>
public Multinomial(double[] p, int n, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(p, n); SetParameters(p, n);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -198,11 +213,7 @@ namespace MathNet.Numerics.Distributions
/// </summary> /// </summary>
public Random RandomSource public Random RandomSource
{ {
get get { return _random; }
{
return _random;
}
set set
{ {
if (value == null) if (value == null)

46
src/Numerics/Distributions/Multivariate/NormalGamma.cs

@ -49,12 +49,8 @@ namespace MathNet.Numerics.Distributions
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="MeanPrecisionPair"/> struct. /// Initializes a new instance of the <see cref="MeanPrecisionPair"/> struct.
/// </summary> /// </summary>
/// <param name="m"> /// <param name="m">The mean of the pair.</param>
/// The mean of the pair. /// <param name="p">The precision of the pair.</param>
/// </param>
/// <param name="p">
/// The precision of the pair.
/// </param>
public MeanPrecisionPair(double m, double p) public MeanPrecisionPair(double m, double p)
{ {
_mean = m; _mean = m;
@ -141,22 +137,28 @@ namespace MathNet.Numerics.Distributions
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="NormalGamma"/> class. /// Initializes a new instance of the <see cref="NormalGamma"/> class.
/// </summary> /// </summary>
/// <param name="meanLocation"> /// <param name="meanLocation">The location of the mean.</param>
/// The location of the mean. /// <param name="meanScale">The scale of the mean.</param>
/// </param> /// <param name="precisionShape">The shape of the precision.</param>
/// <param name="meanScale"> /// <param name="precisionInverseScale">The inverse scale of the precision.</param>
/// The scale of the mean.
/// </param>
/// <param name="precisionShape">
/// The shape of the precision.
/// </param>
/// <param name="precisionInverseScale">
/// The inverse scale of the precision.
/// </param>
public NormalGamma(double meanLocation, double meanScale, double precisionShape, double precisionInverseScale) public NormalGamma(double meanLocation, double meanScale, double precisionShape, double precisionInverseScale)
{ {
SetParameters(meanLocation, meanScale, precisionShape, precisionInverseScale);
_random = new Random(); _random = new Random();
SetParameters(meanLocation, meanScale, precisionShape, precisionInverseScale);
}
/// <summary>
/// Initializes a new instance of the <see cref="NormalGamma"/> class.
/// </summary>
/// <param name="meanLocation">The location of the mean.</param>
/// <param name="meanScale">The scale of the mean.</param>
/// <param name="precisionShape">The shape of the precision.</param>
/// <param name="precisionInverseScale">The inverse scale of the precision.</param>
/// <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, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(meanLocation, meanScale, precisionShape, precisionInverseScale);
} }
/// <summary> /// <summary>
@ -279,11 +281,7 @@ namespace MathNet.Numerics.Distributions
/// </summary> /// </summary>
public Random RandomSource public Random RandomSource
{ {
get get { return _random; }
{
return _random;
}
set set
{ {
if (value == null) if (value == null)

28
src/Numerics/Distributions/Multivariate/Wishart.cs

@ -69,16 +69,24 @@ namespace MathNet.Numerics.Distributions
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Wishart"/> class. /// Initializes a new instance of the <see cref="Wishart"/> class.
/// </summary> /// </summary>
/// <param name="nu"> /// <param name="nu">The degrees of freedom for the Wishart distribution.</param>
/// The degrees of freedom for the Wishart distribution. /// <param name="s">The scale matrix for the Wishart distribution.</param>
/// </param>
/// <param name="s">
/// The scale matrix for the Wishart distribution.
/// </param>
public Wishart(double nu, Matrix<double> s) public Wishart(double nu, Matrix<double> s)
{ {
_random = new Random();
SetParameters(nu, s);
}
/// <summary>
/// Initializes a new instance of the <see cref="Wishart"/> class.
/// </summary>
/// <param name="nu">The degrees of freedom for the Wishart distribution.</param>
/// <param name="s">The scale matrix for the Wishart distribution.</param>
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public Wishart(double nu, Matrix<double> s, Random randomSource)
{
_random = randomSource ?? new Random();
SetParameters(nu, s); SetParameters(nu, s);
RandomSource = new Random();
} }
/// <summary> /// <summary>
@ -174,11 +182,7 @@ namespace MathNet.Numerics.Distributions
/// </summary> /// </summary>
public Random RandomSource public Random RandomSource
{ {
get get { return _random; }
{
return _random;
}
set set
{ {
if (value == null) if (value == null)

2
src/Numerics/Numerics.csproj

@ -384,8 +384,6 @@
<Compile Include="IntegralTransforms\HartleyOptions.cs" /> <Compile Include="IntegralTransforms\HartleyOptions.cs" />
<Compile Include="GlobalizationHelper.cs" /> <Compile Include="GlobalizationHelper.cs" />
<Compile Include="Interpolation\Algorithms\EquidistantPolynomialInterpolation.cs" /> <Compile Include="Interpolation\Algorithms\EquidistantPolynomialInterpolation.cs" />
<Compile Include="IPrecisionSupport.cs" />
<Compile Include="Interpolation\EquidistantPolynomialInterpolation.cs" />
<Compile Include="IntegralTransforms\Algorithms\DiscreteFourierTransform.Options.cs" /> <Compile Include="IntegralTransforms\Algorithms\DiscreteFourierTransform.Options.cs" />
<Compile Include="IntegralTransforms\Algorithms\DiscreteFourierTransform.Bluestein.cs" /> <Compile Include="IntegralTransforms\Algorithms\DiscreteFourierTransform.Bluestein.cs" />
<Compile Include="IntegralTransforms\Algorithms\DiscreteFourierTransform.Naive.cs" /> <Compile Include="IntegralTransforms\Algorithms\DiscreteFourierTransform.Naive.cs" />

5
src/Numerics/Statistics/MCMC/HybridMC.cs

@ -184,10 +184,7 @@ namespace MathNet.Numerics.Statistics.Mcmc
private void Initialize(double[] x0) private void Initialize(double[] x0)
{ {
Current = (double[])x0.Clone(); Current = (double[])x0.Clone();
_pDistribution = new Normal(0, 1) _pDistribution = new Normal(0.0, 1.0, RandomSource);
{
RandomSource = RandomSource
};
} }
/// <summary> /// <summary>

3
src/Numerics/Statistics/MCMC/UnivariateHybridMC.cs

@ -162,9 +162,8 @@ namespace MathNet.Numerics.Statistics.Mcmc
: base(x0, pdfLnP, frogLeapSteps, stepSize, burnInterval, randomSource, diff) : base(x0, pdfLnP, frogLeapSteps, stepSize, burnInterval, randomSource, diff)
{ {
MomentumStdDev = pSdv; MomentumStdDev = pSdv;
_distribution = new Normal(0, MomentumStdDev) {RandomSource = RandomSource}; _distribution = new Normal(0.0, MomentumStdDev, RandomSource);
Burn(BurnInterval); Burn(BurnInterval);
} }
/// <summary> /// <summary>

15
src/UnitTests/IntegralTransformsTests/FourierTest.cs

@ -43,12 +43,9 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
/// <summary> /// <summary>
/// Continuous uniform distribution. /// Continuous uniform distribution.
/// </summary> /// </summary>
private IContinuousDistribution GetUniform(int seed) IContinuousDistribution GetUniform(int seed)
{ {
return new ContinuousUniform(-1, 1) return new ContinuousUniform(-1, 1, new Random(seed));
{
RandomSource = new Random(seed)
};
} }
/// <summary> /// <summary>
@ -98,18 +95,18 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
var dft = new DiscreteFourierTransform(); var dft = new DiscreteFourierTransform();
Assert.Throws( Assert.Throws(
typeof(ArgumentException), typeof (ArgumentException),
() => dft.Radix2Forward(samples, FourierOptions.Default)); () => dft.Radix2Forward(samples, FourierOptions.Default));
Assert.Throws( Assert.Throws(
typeof(ArgumentException), typeof (ArgumentException),
() => dft.Radix2Inverse(samples, FourierOptions.Default)); () => dft.Radix2Inverse(samples, FourierOptions.Default));
Assert.Throws( Assert.Throws(
typeof(ArgumentException), typeof (ArgumentException),
() => DiscreteFourierTransform.Radix2(samples, -1)); () => DiscreteFourierTransform.Radix2(samples, -1));
Assert.Throws( Assert.Throws(
typeof(ArgumentException), typeof (ArgumentException),
() => DiscreteFourierTransform.Radix2Parallel(samples, -1)); () => DiscreteFourierTransform.Radix2Parallel(samples, -1));
} }
} }

9
src/UnitTests/IntegralTransformsTests/HartleyTest.cs

@ -43,12 +43,9 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
/// <summary> /// <summary>
/// Continuous uniform distribution. /// Continuous uniform distribution.
/// </summary> /// </summary>
private IContinuousDistribution GetUniform(int seed) IContinuousDistribution GetUniform(int seed)
{ {
return new ContinuousUniform(-1, 1) return new ContinuousUniform(-1, 1, new Random(seed));
{
RandomSource = new Random(seed)
};
} }
/// <summary> /// <summary>
@ -59,7 +56,7 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
/// <param name="inverse">Is inverse.</param> /// <param name="inverse">Is inverse.</param>
/// <param name="dft">DFT function delegate.</param> /// <param name="dft">DFT function delegate.</param>
/// <param name="hartley">Hartley transform delegate.</param> /// <param name="hartley">Hartley transform delegate.</param>
private static void VerifyMatchesDft( static void VerifyMatchesDft(
double[] samples, double[] samples,
double maximumError, double maximumError,
bool inverse, bool inverse,

43
src/UnitTests/IntegralTransformsTests/InverseTransformTest.cs

@ -43,12 +43,9 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
/// <summary> /// <summary>
/// Continuous uniform distribution. /// Continuous uniform distribution.
/// </summary> /// </summary>
private IContinuousDistribution GetUniform(int seed) IContinuousDistribution GetUniform(int seed)
{ {
return new ContinuousUniform(-1, 1) return new ContinuousUniform(-1, 1, new Random(seed));
{
RandomSource = new Random(seed)
};
} }
/// <summary> /// <summary>
@ -58,7 +55,7 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
/// <param name="maximumError">Maximum error value.</param> /// <param name="maximumError">Maximum error value.</param>
/// <param name="forward">Forward delegate.</param> /// <param name="forward">Forward delegate.</param>
/// <param name="inverse">Inverse delegate.</param> /// <param name="inverse">Inverse delegate.</param>
private void VerifyIsReversibleComplex( void VerifyIsReversibleComplex(
int count, int count,
double maximumError, double maximumError,
Func<Complex[], Complex[]> forward, Func<Complex[], Complex[]> forward,
@ -84,7 +81,7 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
/// <param name="maximumError">Maximum error value.</param> /// <param name="maximumError">Maximum error value.</param>
/// <param name="forward">Forward delegate.</param> /// <param name="forward">Forward delegate.</param>
/// <param name="inverse">Inverse delegate.</param> /// <param name="inverse">Inverse delegate.</param>
private void VerifyIsReversibleReal( void VerifyIsReversibleReal(
int count, int count,
double maximumError, double maximumError,
Func<double[], double[]> forward, Func<double[], double[]> forward,
@ -134,15 +131,15 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
0x8000, 0x8000,
1e-12, 1e-12,
s => s =>
{ {
dft.Radix2Forward(s, options); dft.Radix2Forward(s, options);
return s; return s;
}, },
s => s =>
{ {
dft.Radix2Inverse(s, options); dft.Radix2Inverse(s, options);
return s; return s;
}); });
} }
/// <summary> /// <summary>
@ -159,15 +156,15 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
0x7FFF, 0x7FFF,
1e-12, 1e-12,
s => s =>
{ {
dft.BluesteinForward(s, options); dft.BluesteinForward(s, options);
return s; return s;
}, },
s => s =>
{ {
dft.BluesteinInverse(s, options); dft.BluesteinInverse(s, options);
return s; return s;
}); });
} }
/// <summary> /// <summary>

9
src/UnitTests/IntegralTransformsTests/MatchingNaiveTransformTest.cs

@ -43,12 +43,9 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
/// <summary> /// <summary>
/// Continuous uniform distribution. /// Continuous uniform distribution.
/// </summary> /// </summary>
private IContinuousDistribution GetUniform(int seed) IContinuousDistribution GetUniform(int seed)
{ {
return new ContinuousUniform(-1, 1) return new ContinuousUniform(-1, 1, new Random(seed));
{
RandomSource = new Random(seed)
};
} }
/// <summary> /// <summary>
@ -58,7 +55,7 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
/// <param name="maximumError">Maximum error.</param> /// <param name="maximumError">Maximum error.</param>
/// <param name="naive">Naive transform.</param> /// <param name="naive">Naive transform.</param>
/// <param name="fast">Fast delegate.</param> /// <param name="fast">Fast delegate.</param>
private static void VerifyMatchesNaiveComplex( static void VerifyMatchesNaiveComplex(
Complex[] samples, Complex[] samples,
double maximumError, double maximumError,
Func<Complex[], Complex[]> naive, Func<Complex[], Complex[]> naive,

13
src/UnitTests/IntegralTransformsTests/ParsevalTheoremTest.cs

@ -26,6 +26,7 @@
namespace MathNet.Numerics.UnitTests.IntegralTransformsTests namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
{ {
using System;
using System.Linq; using System.Linq;
using System.Numerics; using System.Numerics;
using Distributions; using Distributions;
@ -44,12 +45,9 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
/// <summary> /// <summary>
/// Continuous uniform distribution. /// Continuous uniform distribution.
/// </summary> /// </summary>
private IContinuousDistribution GetUniform(int seed) IContinuousDistribution GetUniform(int seed)
{ {
return new ContinuousUniform(-1, 1) return new ContinuousUniform(-1, 1, new Random(seed));
{
RandomSource = new System.Random(seed)
};
} }
/// <summary> /// <summary>
@ -85,7 +83,7 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
{ {
var samples = SignalGenerator.Random(x => x, GetUniform(1), count); var samples = SignalGenerator.Random(x => x, GetUniform(1), count);
var timeSpaceEnergy = (from s in samples select s * s).Mean(); var timeSpaceEnergy = (from s in samples select s*s).Mean();
var work = new double[samples.Length]; var work = new double[samples.Length];
samples.CopyTo(work, 0); samples.CopyTo(work, 0);
@ -94,8 +92,9 @@ namespace MathNet.Numerics.UnitTests.IntegralTransformsTests
var dht = new DiscreteHartleyTransform(); var dht = new DiscreteHartleyTransform();
work = dht.NaiveForward(work, HartleyOptions.Default); work = dht.NaiveForward(work, HartleyOptions.Default);
var frequencySpaceEnergy = (from s in work select s * s).Mean(); var frequencySpaceEnergy = (from s in work select s*s).Mean();
Assert.AreEqual(timeSpaceEnergy, frequencySpaceEnergy, 1e-12); Assert.AreEqual(timeSpaceEnergy, frequencySpaceEnergy, 1e-12);
} }
} }
} }

5
src/UnitTests/InterpolationTests/LinearInterpolationCase.cs

@ -52,10 +52,7 @@ namespace MathNet.Numerics.UnitTests.InterpolationTests
public static void Build(out double[] x, out double[] y, out double[] xtest, out double[] ytest, int samples = 3, double sampleOffset = -0.5, double slope = 2.0, double intercept = -1.0) public static void Build(out double[] x, out double[] y, out double[] xtest, out double[] ytest, int samples = 3, double sampleOffset = -0.5, double slope = 2.0, double intercept = -1.0)
{ {
// Fixed-seed "random" distribution to ensure we always test with the same data // Fixed-seed "random" distribution to ensure we always test with the same data
var uniform = new ContinuousUniform var uniform = new ContinuousUniform(0.0, 1.0, new MersenneTwister(42));
{
RandomSource = new MersenneTwister(42)
};
// build linear samples // build linear samples
x = new double[samples]; x = new double[samples];

30
src/UnitTests/LinearAlgebraTests/Complex/MatrixLoader.cs

@ -116,10 +116,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
public static Matrix GenerateRandomDenseMatrix(int row, int col) public static Matrix GenerateRandomDenseMatrix(int row, int col)
{ {
// Fill a matrix with standard random numbers. // Fill a matrix with standard random numbers.
var normal = new Normal var normal = new Normal(new MersenneTwister(1));
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new DenseMatrix(row, col); var matrixA = new DenseMatrix(row, col);
for (var i = 0; i < row; i++) for (var i = 0; i < row; i++)
{ {
@ -140,10 +137,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
public static Matrix<Complex> GenerateRandomPositiveDefiniteHermitianDenseMatrix(int order) public static Matrix<Complex> GenerateRandomPositiveDefiniteHermitianDenseMatrix(int order)
{ {
// Fill a matrix with standard random numbers. // Fill a matrix with standard random numbers.
var normal = new Normal var normal = new Normal(new MersenneTwister(1));
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new DenseMatrix(order); var matrixA = new DenseMatrix(order);
for (var i = 0; i < order; i++) for (var i = 0; i < order; i++)
{ {
@ -165,10 +159,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
public static Vector GenerateRandomDenseVector(int order) public static Vector GenerateRandomDenseVector(int order)
{ {
// Fill a matrix with standard random numbers. // Fill a matrix with standard random numbers.
var normal = new Normal var normal = new Normal(new MersenneTwister(1));
{
RandomSource = new MersenneTwister(1)
};
var v = new DenseVector(order); var v = new DenseVector(order);
for (var i = 0; i < order; i++) for (var i = 0; i < order; i++)
{ {
@ -187,10 +178,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
public static Matrix GenerateRandomUserDefinedMatrix(int row, int col) public static Matrix GenerateRandomUserDefinedMatrix(int row, int col)
{ {
// Fill a matrix with standard random numbers. // Fill a matrix with standard random numbers.
var normal = new Normal var normal = new Normal(new MersenneTwister(1));
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new UserDefinedMatrix(row, col); var matrixA = new UserDefinedMatrix(row, col);
for (var i = 0; i < row; i++) for (var i = 0; i < row; i++)
{ {
@ -211,10 +199,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
public static Matrix<Complex> GenerateRandomPositiveDefiniteHermitianUserDefinedMatrix(int order) public static Matrix<Complex> GenerateRandomPositiveDefiniteHermitianUserDefinedMatrix(int order)
{ {
// Fill a matrix with standard random numbers. // Fill a matrix with standard random numbers.
var normal = new Normal var normal = new Normal(new MersenneTwister(1));
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new UserDefinedMatrix(order); var matrixA = new UserDefinedMatrix(order);
for (var i = 0; i < order; i++) for (var i = 0; i < order; i++)
{ {
@ -236,10 +221,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
public static Vector GenerateRandomUserDefinedVector(int order) public static Vector GenerateRandomUserDefinedVector(int order)
{ {
// Fill a matrix with standard random numbers. // Fill a matrix with standard random numbers.
var normal = new Normal var normal = new Normal(new MersenneTwister(1));
{
RandomSource = new MersenneTwister(1)
};
var v = new UserDefinedVector(order); var v = new UserDefinedVector(order);
for (var i = 0; i < order; i++) for (var i = 0; i < order; i++)
{ {

4
src/UnitTests/LinearAlgebraTests/Complex/MatrixStructureTheory.cs

@ -77,7 +77,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
protected override Matrix<Complex> CreateDenseRandom(int rows, int columns, int seed) protected override Matrix<Complex> CreateDenseRandom(int rows, int columns, int seed)
{ {
var dist = new Normal {RandomSource = new MersenneTwister(seed)}; var dist = new Normal(new MersenneTwister(seed));
return new DenseMatrix(rows, columns, Enumerable.Range(0, rows*columns).Select(k => new Complex(dist.Sample(), dist.Sample())).ToArray()); return new DenseMatrix(rows, columns, Enumerable.Range(0, rows*columns).Select(k => new Complex(dist.Sample(), dist.Sample())).ToArray());
} }
@ -93,7 +93,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
protected override Vector<Complex> CreateVectorRandom(int size, int seed) protected override Vector<Complex> CreateVectorRandom(int size, int seed)
{ {
var dist = new Normal {RandomSource = new MersenneTwister(seed)}; var dist = new Normal(new MersenneTwister(seed));
return new DenseVector(Enumerable.Range(0, size).Select(k => new Complex(dist.Sample(), dist.Sample())).ToArray()); return new DenseVector(Enumerable.Range(0, size).Select(k => new Complex(dist.Sample(), dist.Sample())).ToArray());
} }
} }

30
src/UnitTests/LinearAlgebraTests/Complex32/MatrixLoader.cs

@ -116,10 +116,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
public static Matrix GenerateRandomDenseMatrix(int row, int col) public static Matrix GenerateRandomDenseMatrix(int row, int col)
{ {
// Fill a matrix with standard random numbers. // Fill a matrix with standard random numbers.
var normal = new Normal var normal = new Normal(new MersenneTwister(1));
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new DenseMatrix(row, col); var matrixA = new DenseMatrix(row, col);
for (var i = 0; i < row; i++) for (var i = 0; i < row; i++)
{ {
@ -140,10 +137,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
public static Matrix<Complex32> GenerateRandomPositiveDefiniteHermitianDenseMatrix(int order) public static Matrix<Complex32> GenerateRandomPositiveDefiniteHermitianDenseMatrix(int order)
{ {
// Fill a matrix with standard random numbers. // Fill a matrix with standard random numbers.
var normal = new Normal var normal = new Normal(new MersenneTwister(1));
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new DenseMatrix(order); var matrixA = new DenseMatrix(order);
for (var i = 0; i < order; i++) for (var i = 0; i < order; i++)
{ {
@ -165,10 +159,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
public static Vector GenerateRandomDenseVector(int order) public static Vector GenerateRandomDenseVector(int order)
{ {
// Fill a matrix with standard random numbers. // Fill a matrix with standard random numbers.
var normal = new Normal var normal = new Normal(new MersenneTwister(1));
{
RandomSource = new MersenneTwister(1)
};
var v = new DenseVector(order); var v = new DenseVector(order);
for (var i = 0; i < order; i++) for (var i = 0; i < order; i++)
{ {
@ -187,10 +178,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
public static Matrix GenerateRandomUserDefinedMatrix(int row, int col) public static Matrix GenerateRandomUserDefinedMatrix(int row, int col)
{ {
// Fill a matrix with standard random numbers. // Fill a matrix with standard random numbers.
var normal = new Normal var normal = new Normal(new MersenneTwister(1));
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new UserDefinedMatrix(row, col); var matrixA = new UserDefinedMatrix(row, col);
for (var i = 0; i < row; i++) for (var i = 0; i < row; i++)
{ {
@ -211,10 +199,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
public static Matrix<Complex32> GenerateRandomPositiveDefiniteHermitianUserDefinedMatrix(int order) public static Matrix<Complex32> GenerateRandomPositiveDefiniteHermitianUserDefinedMatrix(int order)
{ {
// Fill a matrix with standard random numbers. // Fill a matrix with standard random numbers.
var normal = new Normal var normal = new Normal(new MersenneTwister(1));
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new UserDefinedMatrix(order); var matrixA = new UserDefinedMatrix(order);
for (var i = 0; i < order; i++) for (var i = 0; i < order; i++)
{ {
@ -236,10 +221,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
public static Vector GenerateRandomUserDefinedVector(int order) public static Vector GenerateRandomUserDefinedVector(int order)
{ {
// Fill a matrix with standard random numbers. // Fill a matrix with standard random numbers.
var normal = new Normal var normal = new Normal(new MersenneTwister(1));
{
RandomSource = new MersenneTwister(1)
};
var v = new UserDefinedVector(order); var v = new UserDefinedVector(order);
for (var i = 0; i < order; i++) for (var i = 0; i < order; i++)
{ {

4
src/UnitTests/LinearAlgebraTests/Complex32/MatrixStructureTheory.cs

@ -77,7 +77,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
protected override Matrix<Complex32> CreateDenseRandom(int rows, int columns, int seed) protected override Matrix<Complex32> CreateDenseRandom(int rows, int columns, int seed)
{ {
var dist = new Normal {RandomSource = new MersenneTwister(seed)}; var dist = new Normal(new MersenneTwister(seed));
return new DenseMatrix(rows, columns, Enumerable.Range(0, rows*columns).Select(k => new Complex32((float) dist.Sample(), (float) dist.Sample())).ToArray()); return new DenseMatrix(rows, columns, Enumerable.Range(0, rows*columns).Select(k => new Complex32((float) dist.Sample(), (float) dist.Sample())).ToArray());
} }
@ -93,7 +93,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
protected override Vector<Complex32> CreateVectorRandom(int size, int seed) protected override Vector<Complex32> CreateVectorRandom(int size, int seed)
{ {
var dist = new Normal {RandomSource = new MersenneTwister(seed)}; var dist = new Normal(new MersenneTwister(seed));
return new DenseVector(Enumerable.Range(0, size).Select(k => new Complex32((float) dist.Sample(), (float) dist.Sample())).ToArray()); return new DenseVector(Enumerable.Range(0, size).Select(k => new Complex32((float) dist.Sample(), (float) dist.Sample())).ToArray());
} }
} }

30
src/UnitTests/LinearAlgebraTests/Double/MatrixLoader.cs

@ -115,10 +115,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
public static Matrix GenerateRandomDenseMatrix(int row, int col) public static Matrix GenerateRandomDenseMatrix(int row, int col)
{ {
// Fill a matrix with standard random numbers. // Fill a matrix with standard random numbers.
var normal = new Normal var normal = new Normal(new MersenneTwister(1));
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new DenseMatrix(row, col); var matrixA = new DenseMatrix(row, col);
for (var i = 0; i < row; i++) for (var i = 0; i < row; i++)
{ {
@ -139,10 +136,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
public static Matrix<double> GenerateRandomPositiveDefiniteDenseMatrix(int order) public static Matrix<double> GenerateRandomPositiveDefiniteDenseMatrix(int order)
{ {
// Fill a matrix with standard random numbers. // Fill a matrix with standard random numbers.
var normal = new Normal var normal = new Normal(new MersenneTwister(1));
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new DenseMatrix(order); var matrixA = new DenseMatrix(order);
for (var i = 0; i < order; i++) for (var i = 0; i < order; i++)
{ {
@ -164,10 +158,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
public static Vector GenerateRandomDenseVector(int order) public static Vector GenerateRandomDenseVector(int order)
{ {
// Fill a matrix with standard random numbers. // Fill a matrix with standard random numbers.
var normal = new Normal var normal = new Normal(new MersenneTwister(1));
{
RandomSource = new MersenneTwister(1)
};
var v = new DenseVector(order); var v = new DenseVector(order);
for (var i = 0; i < order; i++) for (var i = 0; i < order; i++)
{ {
@ -186,10 +177,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
public static Matrix GenerateRandomUserDefinedMatrix(int row, int col) public static Matrix GenerateRandomUserDefinedMatrix(int row, int col)
{ {
// Fill a matrix with standard random numbers. // Fill a matrix with standard random numbers.
var normal = new Normal var normal = new Normal(new MersenneTwister(1));
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new UserDefinedMatrix(row, col); var matrixA = new UserDefinedMatrix(row, col);
for (var i = 0; i < row; i++) for (var i = 0; i < row; i++)
{ {
@ -210,10 +198,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
public static Matrix<double> GenerateRandomPositiveDefiniteUserDefinedMatrix(int order) public static Matrix<double> GenerateRandomPositiveDefiniteUserDefinedMatrix(int order)
{ {
// Fill a matrix with standard random numbers. // Fill a matrix with standard random numbers.
var normal = new Normal var normal = new Normal(new MersenneTwister(1));
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new UserDefinedMatrix(order); var matrixA = new UserDefinedMatrix(order);
for (var i = 0; i < order; i++) for (var i = 0; i < order; i++)
{ {
@ -235,10 +220,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
public static Vector GenerateRandomUserDefinedVector(int order) public static Vector GenerateRandomUserDefinedVector(int order)
{ {
// Fill a matrix with standard random numbers. // Fill a matrix with standard random numbers.
var normal = new Normal var normal = new Normal(new MersenneTwister(1));
{
RandomSource = new MersenneTwister(1)
};
var v = new UserDefinedVector(order); var v = new UserDefinedVector(order);
for (var i = 0; i < order; i++) for (var i = 0; i < order; i++)
{ {

4
src/UnitTests/LinearAlgebraTests/Double/MatrixStructureTheory.cs

@ -76,7 +76,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
protected override Matrix<double> CreateDenseRandom(int rows, int columns, int seed) protected override Matrix<double> CreateDenseRandom(int rows, int columns, int seed)
{ {
var dist = new Normal {RandomSource = new MersenneTwister(seed)}; var dist = new Normal(new MersenneTwister(seed));
return new DenseMatrix(rows, columns, dist.Samples().Take(rows*columns).ToArray()); return new DenseMatrix(rows, columns, dist.Samples().Take(rows*columns).ToArray());
} }
@ -92,7 +92,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
protected override Vector<double> CreateVectorRandom(int size, int seed) protected override Vector<double> CreateVectorRandom(int size, int seed)
{ {
var dist = new Normal {RandomSource = new MersenneTwister(seed)}; var dist = new Normal(new MersenneTwister(seed));
return new DenseVector(dist.Samples().Take(size).ToArray()); return new DenseVector(dist.Samples().Take(size).ToArray());
} }
} }

30
src/UnitTests/LinearAlgebraTests/Single/MatrixLoader.cs

@ -115,10 +115,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
public static Matrix GenerateRandomDenseMatrix(int row, int col) public static Matrix GenerateRandomDenseMatrix(int row, int col)
{ {
// Fill a matrix with standard random numbers. // Fill a matrix with standard random numbers.
var normal = new Normal var normal = new Normal(new MersenneTwister(1));
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new DenseMatrix(row, col); var matrixA = new DenseMatrix(row, col);
for (var i = 0; i < row; i++) for (var i = 0; i < row; i++)
{ {
@ -139,10 +136,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
public static Matrix<float> GenerateRandomPositiveDefiniteDenseMatrix(int order) public static Matrix<float> GenerateRandomPositiveDefiniteDenseMatrix(int order)
{ {
// Fill a matrix with standard random numbers. // Fill a matrix with standard random numbers.
var normal = new Normal var normal = new Normal(new MersenneTwister(1));
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new DenseMatrix(order); var matrixA = new DenseMatrix(order);
for (var i = 0; i < order; i++) for (var i = 0; i < order; i++)
{ {
@ -164,10 +158,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
public static Vector GenerateRandomDenseVector(int order) public static Vector GenerateRandomDenseVector(int order)
{ {
// Fill a matrix with standard random numbers. // Fill a matrix with standard random numbers.
var normal = new Normal var normal = new Normal(new MersenneTwister(1));
{
RandomSource = new MersenneTwister(1)
};
var v = new DenseVector(order); var v = new DenseVector(order);
for (var i = 0; i < order; i++) for (var i = 0; i < order; i++)
{ {
@ -186,10 +177,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
public static Matrix GenerateRandomUserDefinedMatrix(int row, int col) public static Matrix GenerateRandomUserDefinedMatrix(int row, int col)
{ {
// Fill a matrix with standard random numbers. // Fill a matrix with standard random numbers.
var normal = new Normal var normal = new Normal(new MersenneTwister(1));
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new UserDefinedMatrix(row, col); var matrixA = new UserDefinedMatrix(row, col);
for (var i = 0; i < row; i++) for (var i = 0; i < row; i++)
{ {
@ -210,10 +198,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
public static Matrix<float> GenerateRandomPositiveDefiniteUserDefinedMatrix(int order) public static Matrix<float> GenerateRandomPositiveDefiniteUserDefinedMatrix(int order)
{ {
// Fill a matrix with standard random numbers. // Fill a matrix with standard random numbers.
var normal = new Normal var normal = new Normal(new MersenneTwister(1));
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new UserDefinedMatrix(order); var matrixA = new UserDefinedMatrix(order);
for (var i = 0; i < order; i++) for (var i = 0; i < order; i++)
{ {
@ -235,10 +220,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
public static Vector GenerateRandomUserDefinedVector(int order) public static Vector GenerateRandomUserDefinedVector(int order)
{ {
// Fill a matrix with standard random numbers. // Fill a matrix with standard random numbers.
var normal = new Normal var normal = new Normal(new MersenneTwister(1));
{
RandomSource = new MersenneTwister(1)
};
var v = new UserDefinedVector(order); var v = new UserDefinedVector(order);
for (var i = 0; i < order; i++) for (var i = 0; i < order; i++)
{ {

4
src/UnitTests/LinearAlgebraTests/Single/MatrixStructureTheory.cs

@ -76,7 +76,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
protected override Matrix<float> CreateDenseRandom(int rows, int columns, int seed) protected override Matrix<float> CreateDenseRandom(int rows, int columns, int seed)
{ {
var dist = new Normal {RandomSource = new MersenneTwister(seed)}; var dist = new Normal(new MersenneTwister(seed));
return new DenseMatrix(rows, columns, dist.Samples().Select(d => (float) d).Take(rows*columns).ToArray()); return new DenseMatrix(rows, columns, dist.Samples().Select(d => (float) d).Take(rows*columns).ToArray());
} }
@ -92,7 +92,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
protected override Vector<float> CreateVectorRandom(int size, int seed) protected override Vector<float> CreateVectorRandom(int size, int seed)
{ {
var dist = new Normal {RandomSource = new MersenneTwister(seed)}; var dist = new Normal(new MersenneTwister(seed));
return new DenseVector(dist.Samples().Select(d => (float) d).Take(size).ToArray()); return new DenseVector(dist.Samples().Select(d => (float) d).Take(size).ToArray());
} }
} }

27
src/UnitTests/StatisticsTests/MCMCTests/RejectionSamplerTests.cs

@ -48,11 +48,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests.McmcTests
[Test] [Test]
public void RejectTest() public void RejectTest()
{ {
var uniform = new ContinuousUniform(0.0, 1.0) var uniform = new ContinuousUniform(0.0, 1.0, new MersenneTwister());
{
RandomSource = new MersenneTwister()
};
var rs = new RejectionSampler<double>(x => Math.Pow(x, 1.7)*Math.Pow(1.0 - x, 5.3), x => 0.021, uniform.Sample); var rs = new RejectionSampler<double>(x => Math.Pow(x, 1.7)*Math.Pow(1.0 - x, 5.3), x => 0.021, uniform.Sample);
Assert.IsNotNull(rs.RandomSource); Assert.IsNotNull(rs.RandomSource);
@ -66,10 +62,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests.McmcTests
[Test] [Test]
public void SampleTest() public void SampleTest()
{ {
var uniform = new ContinuousUniform(0.0, 1.0) var uniform = new ContinuousUniform(0.0, 1.0, new MersenneTwister());
{
RandomSource = new MersenneTwister()
};
var rs = new RejectionSampler<double>(x => Math.Pow(x, 1.7)*Math.Pow(1.0 - x, 5.3), x => 0.021, uniform.Sample) var rs = new RejectionSampler<double>(x => Math.Pow(x, 1.7)*Math.Pow(1.0 - x, 5.3), x => 0.021, uniform.Sample)
{ {
@ -85,10 +78,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests.McmcTests
[Test] [Test]
public void SampleArrayTest() public void SampleArrayTest()
{ {
var uniform = new ContinuousUniform(0.0, 1.0) var uniform = new ContinuousUniform(0.0, 1.0, new MersenneTwister());
{
RandomSource = new MersenneTwister()
};
var rs = new RejectionSampler<double>(x => Math.Pow(x, 1.7)*Math.Pow(1.0 - x, 5.3), x => 0.021, uniform.Sample) var rs = new RejectionSampler<double>(x => Math.Pow(x, 1.7)*Math.Pow(1.0 - x, 5.3), x => 0.021, uniform.Sample)
{ {
@ -104,11 +94,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests.McmcTests
[Test] [Test]
public void NoUpperBound() public void NoUpperBound()
{ {
var uniform = new ContinuousUniform(0.0, 1.0) var uniform = new ContinuousUniform(0.0, 1.0, new MersenneTwister());
{
RandomSource = new MersenneTwister()
};
var rs = new RejectionSampler<double>(x => Math.Pow(x, 1.7)*Math.Pow(1.0 - x, 5.3), x => Double.NegativeInfinity, uniform.Sample); var rs = new RejectionSampler<double>(x => Math.Pow(x, 1.7)*Math.Pow(1.0 - x, 5.3), x => Double.NegativeInfinity, uniform.Sample);
Assert.Throws<ArgumentOutOfRangeException>(() => rs.Sample()); Assert.Throws<ArgumentOutOfRangeException>(() => rs.Sample());
} }
@ -119,10 +105,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests.McmcTests
[Test] [Test]
public void NullRandomNumberGenerator() public void NullRandomNumberGenerator()
{ {
var uniform = new ContinuousUniform(0.0, 1.0) var uniform = new ContinuousUniform(0.0, 1.0, new MersenneTwister());
{
RandomSource = new MersenneTwister()
};
var rs = new RejectionSampler<double>(x => Math.Pow(x, 1.7)*Math.Pow(1.0 - x, 5.3), x => Double.NegativeInfinity, uniform.Sample); var rs = new RejectionSampler<double>(x => Math.Pow(x, 1.7)*Math.Pow(1.0 - x, 5.3), x => Double.NegativeInfinity, uniform.Sample);
Assert.Throws<ArgumentNullException>(() => rs.RandomSource = null); Assert.Throws<ArgumentNullException>(() => rs.RandomSource = null);
} }

7
src/UnitTests/StatisticsTests/StatisticsTests.cs

@ -28,6 +28,8 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
// </copyright> // </copyright>
using MathNet.Numerics.Random;
namespace MathNet.Numerics.UnitTests.StatisticsTests namespace MathNet.Numerics.UnitTests.StatisticsTests
{ {
using System; using System;
@ -557,10 +559,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests
public void StabilityMeanVariance() public void StabilityMeanVariance()
{ {
// Test around 10^9, potential stability issues // Test around 10^9, potential stability issues
var gaussian = new Distributions.Normal(1e+9, 2) var gaussian = new Distributions.Normal(1e+9, 2, new MersenneTwister(100));
{
RandomSource = new Numerics.Random.MersenneTwister(100)
};
AssertHelpers.AlmostEqual(1e+9, Statistics.Mean(gaussian.Samples().Take(10000)), 11); AssertHelpers.AlmostEqual(1e+9, Statistics.Mean(gaussian.Samples().Take(10000)), 11);
AssertHelpers.AlmostEqual(4d, Statistics.Variance(gaussian.Samples().Take(10000)), 1); AssertHelpers.AlmostEqual(4d, Statistics.Variance(gaussian.Samples().Take(10000)), 1);

Loading…
Cancel
Save