Browse Source

Random: use thread-safe mersenne twister instead of System.Random as default fallback

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

3
src/FSharp/Random.fs

@ -33,6 +33,9 @@ namespace MathNet.Numerics.Random
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module Random =
/// Returns the default mersenne twister, thread-safe and also thread-locally shared
let shared = MersenneTwister.Default :> System.Random
/// Creates a default .Net system pRNG with a custom seed based on uinque GUIDs
let system () = new System.Random(RandomSeed.Guid())
let systemSeed seed = new System.Random(seed)

7
src/Numerics/Distributions/Bernoulli.cs

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

7
src/Numerics/Distributions/Beta.cs

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

7
src/Numerics/Distributions/Binomial.cs

@ -31,6 +31,7 @@
using System;
using System.Collections.Generic;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Random;
namespace MathNet.Numerics.Distributions
{
@ -61,7 +62,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="n"/> is negative.</exception>
public Binomial(double p, int n)
{
_random = new System.Random(Random.RandomSeed.Guid());
_random = MersenneTwister.Default;
SetParameters(p, n);
}
@ -75,7 +76,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="n"/> is negative.</exception>
public Binomial(double p, int n, System.Random randomSource)
{
_random = randomSource ?? new System.Random(Random.RandomSeed.Guid());
_random = randomSource ?? MersenneTwister.Default;
SetParameters(p, n);
}
@ -141,7 +142,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? new System.Random(Random.RandomSeed.Guid()); }
set { _random = value ?? MersenneTwister.Default; }
}
/// <summary>

9
src/Numerics/Distributions/Categorical.cs

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

7
src/Numerics/Distributions/Cauchy.cs

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

7
src/Numerics/Distributions/Chi.cs

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

7
src/Numerics/Distributions/ChiSquared.cs

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

7
src/Numerics/Distributions/ContinuousUniform.cs

@ -31,6 +31,7 @@
using System;
using System.Collections.Generic;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Random;
namespace MathNet.Numerics.Distributions
{
@ -66,7 +67,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentException">If the upper bound is smaller than the lower bound.</exception>
public ContinuousUniform(double lower, double upper)
{
_random = new System.Random(Random.RandomSeed.Guid());
_random = MersenneTwister.Default;
SetParameters(lower, upper);
}
@ -79,7 +80,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentException">If the upper bound is smaller than the lower bound.</exception>
public ContinuousUniform(double lower, double upper, System.Random randomSource)
{
_random = randomSource ?? new System.Random(Random.RandomSeed.Guid());
_random = randomSource ?? MersenneTwister.Default;
SetParameters(lower, upper);
}
@ -133,7 +134,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? new System.Random(Random.RandomSeed.Guid()); }
set { _random = value ?? MersenneTwister.Default; }
}
/// <summary>

7
src/Numerics/Distributions/ConwayMaxwellPoisson.cs

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

11
src/Numerics/Distributions/Dirichlet.cs

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

7
src/Numerics/Distributions/DiscreteUniform.cs

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

7
src/Numerics/Distributions/Erlang.cs

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

7
src/Numerics/Distributions/Exponential.cs

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

7
src/Numerics/Distributions/FisherSnedecor.cs

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

7
src/Numerics/Distributions/Gamma.cs

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

7
src/Numerics/Distributions/Geometric.cs

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

7
src/Numerics/Distributions/Hypergeometric.cs

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

7
src/Numerics/Distributions/InverseGamma.cs

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

7
src/Numerics/Distributions/InverseWishart.cs

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

7
src/Numerics/Distributions/Laplace.cs

@ -31,6 +31,7 @@
using System;
using System.Collections.Generic;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Random;
namespace MathNet.Numerics.Distributions
{
@ -69,7 +70,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentException">If <paramref name="scale"/> is negative.</exception>
public Laplace(double location, double scale)
{
_random = new System.Random(Random.RandomSeed.Guid());
_random = MersenneTwister.Default;
SetParameters(location, scale);
}
@ -82,7 +83,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentException">If <paramref name="scale"/> is negative.</exception>
public Laplace(double location, double scale, System.Random randomSource)
{
_random = randomSource ?? new System.Random(Random.RandomSeed.Guid());
_random = randomSource ?? MersenneTwister.Default;
SetParameters(location, scale);
}
@ -136,7 +137,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? new System.Random(Random.RandomSeed.Guid()); }
set { _random = value ?? MersenneTwister.Default; }
}
/// <summary>

7
src/Numerics/Distributions/LogNormal.cs

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

7
src/Numerics/Distributions/MatrixNormal.cs

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

9
src/Numerics/Distributions/Multinomial.cs

@ -34,6 +34,7 @@ using System.Linq;
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Double;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Random;
using MathNet.Numerics.Statistics;
namespace MathNet.Numerics.Distributions
@ -74,7 +75,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="n"/> is negative.</exception>
public Multinomial(double[] p, int n)
{
_random = new System.Random(Random.RandomSeed.Guid());
_random = MersenneTwister.Default;
SetParameters(p, n);
}
@ -89,7 +90,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="n"/> is negative.</exception>
public Multinomial(double[] p, int n, System.Random randomSource)
{
_random = randomSource ?? new System.Random(Random.RandomSeed.Guid());
_random = randomSource ?? MersenneTwister.Default;
SetParameters(p, n);
}
@ -118,7 +119,7 @@ namespace MathNet.Numerics.Distributions
}
SetParameters(p, n);
RandomSource = new System.Random(Random.RandomSeed.Guid());
RandomSource = MersenneTwister.Default;
}
/// <summary>
@ -201,7 +202,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? new System.Random(Random.RandomSeed.Guid()); }
set { _random = value ?? MersenneTwister.Default; }
}
/// <summary>

7
src/Numerics/Distributions/NegativeBinomial.cs

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

7
src/Numerics/Distributions/Normal.cs

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

7
src/Numerics/Distributions/NormalGamma.cs

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

7
src/Numerics/Distributions/Pareto.cs

@ -31,6 +31,7 @@
using System;
using System.Collections.Generic;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Random;
namespace MathNet.Numerics.Distributions
{
@ -61,7 +62,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentException">If <paramref name="scale"/> or <paramref name="shape"/> are negative.</exception>
public Pareto(double scale, double shape)
{
_random = new System.Random(Random.RandomSeed.Guid());
_random = MersenneTwister.Default;
SetParameters(scale, shape);
}
@ -74,7 +75,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentException">If <paramref name="scale"/> or <paramref name="shape"/> are negative.</exception>
public Pareto(double scale, double shape, System.Random randomSource)
{
_random = randomSource ?? new System.Random(Random.RandomSeed.Guid());
_random = randomSource ?? MersenneTwister.Default;
SetParameters(scale, shape);
}
@ -128,7 +129,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? new System.Random(Random.RandomSeed.Guid()); }
set { _random = value ?? MersenneTwister.Default; }
}
/// <summary>

7
src/Numerics/Distributions/Poisson.cs

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

7
src/Numerics/Distributions/Rayleigh.cs

@ -31,6 +31,7 @@
using System;
using System.Collections.Generic;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Random;
namespace MathNet.Numerics.Distributions
{
@ -60,7 +61,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentException">If <paramref name="scale"/> is negative.</exception>
public Rayleigh(double scale)
{
_random = new System.Random(Random.RandomSeed.Guid());
_random = MersenneTwister.Default;
SetParameters(scale);
}
@ -72,7 +73,7 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentException">If <paramref name="scale"/> is negative.</exception>
public Rayleigh(double scale, System.Random randomSource)
{
_random = randomSource ?? new System.Random(Random.RandomSeed.Guid());
_random = randomSource ?? MersenneTwister.Default;
SetParameters(scale);
}
@ -115,7 +116,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? new System.Random(Random.RandomSeed.Guid()); }
set { _random = value ?? MersenneTwister.Default; }
}
/// <summary>

7
src/Numerics/Distributions/Stable.cs

@ -31,6 +31,7 @@
using System;
using System.Collections.Generic;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Random;
namespace MathNet.Numerics.Distributions
{
@ -65,7 +66,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="location">The location (μ) of the distribution.</param>
public Stable(double alpha, double beta, double scale, double location)
{
_random = new System.Random(Random.RandomSeed.Guid());
_random = MersenneTwister.Default;
SetParameters(alpha, beta, scale, location);
}
@ -79,7 +80,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public Stable(double alpha, double beta, double scale, double location, System.Random randomSource)
{
_random = randomSource ?? new System.Random(Random.RandomSeed.Guid());
_random = randomSource ?? MersenneTwister.Default;
SetParameters(alpha, beta, scale, location);
}
@ -168,7 +169,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? new System.Random(Random.RandomSeed.Guid()); }
set { _random = value ?? MersenneTwister.Default; }
}
/// <summary>

7
src/Numerics/Distributions/StudentT.cs

@ -31,6 +31,7 @@
using System;
using System.Collections.Generic;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Random;
namespace MathNet.Numerics.Distributions
{
@ -83,7 +84,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="freedom">The degrees of freedom (ν) for the distribution. Range: ν > 0.</param>
public StudentT(double location, double scale, double freedom)
{
_random = new System.Random(Random.RandomSeed.Guid());
_random = MersenneTwister.Default;
SetParameters(location, scale, freedom);
}
@ -98,7 +99,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public StudentT(double location, double scale, double freedom, System.Random randomSource)
{
_random = randomSource ?? new System.Random(Random.RandomSeed.Guid());
_random = randomSource ?? MersenneTwister.Default;
SetParameters(location, scale, freedom);
}
@ -175,7 +176,7 @@ namespace MathNet.Numerics.Distributions
public System.Random RandomSource
{
get { return _random; }
set { _random = value ?? new System.Random(Random.RandomSeed.Guid()); }
set { _random = value ?? MersenneTwister.Default; }
}
/// <summary>

7
src/Numerics/Distributions/Weibull.cs

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

5
src/Numerics/Distributions/Wishart.cs

@ -33,6 +33,7 @@ using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Double;
using MathNet.Numerics.LinearAlgebra.Factorization;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Random;
namespace MathNet.Numerics.Distributions
{
@ -74,7 +75,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="scale">The scale matrix (V) for the Wishart distribution.</param>
public Wishart(double degreesOfFreedom, Matrix<double> scale)
{
_random = new System.Random(Random.RandomSeed.Guid());
_random = MersenneTwister.Default;
SetParameters(degreesOfFreedom, scale);
}
@ -86,7 +87,7 @@ namespace MathNet.Numerics.Distributions
/// <param name="randomSource">The random number generator which is used to draw random samples.</param>
public Wishart(double degreesOfFreedom, Matrix<double> scale, System.Random randomSource)
{
_random = randomSource ?? new System.Random(Random.RandomSeed.Guid());
_random = randomSource ?? MersenneTwister.Default;
SetParameters(degreesOfFreedom, scale);
}

7
src/Numerics/Distributions/Zipf.cs

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

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

@ -31,6 +31,7 @@
using System;
using System.Linq;
using MathNet.Numerics.Distributions;
using MathNet.Numerics.Random;
namespace MathNet.Numerics.Statistics.Mcmc
{
@ -84,7 +85,7 @@ namespace MathNet.Numerics.Statistics.Mcmc
/// <param name="burnInterval">The number of iterations in between returning samples.</param>
/// <exception cref="ArgumentOutOfRangeException">When the number of burnInterval iteration is negative.</exception>
public HybridMC(double[] x0, DensityLn<double[]> pdfLnP, int frogLeapSteps, double stepSize, int burnInterval = 0)
: this(x0, pdfLnP, frogLeapSteps, stepSize, burnInterval, new double[x0.Count()], new System.Random(Random.RandomSeed.Guid()), Grad)
: this(x0, pdfLnP, frogLeapSteps, stepSize, burnInterval, new double[x0.Count()], MersenneTwister.Default, Grad)
{
for (int i = 0; i < _length; i++)
{
@ -108,7 +109,7 @@ namespace MathNet.Numerics.Statistics.Mcmc
/// the components of the momentum.</param>
/// <exception cref="ArgumentOutOfRangeException">When the number of burnInterval iteration is negative.</exception>
public HybridMC(double[] x0, DensityLn<double[]> pdfLnP, int frogLeapSteps, double stepSize, int burnInterval, double[] pSdv)
: this(x0, pdfLnP, frogLeapSteps, stepSize, burnInterval, pSdv, new System.Random(Random.RandomSeed.Guid()))
: this(x0, pdfLnP, frogLeapSteps, stepSize, burnInterval, pSdv, MersenneTwister.Default)
{
}

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

@ -29,6 +29,7 @@
// </copyright>
using System;
using MathNet.Numerics.Random;
namespace MathNet.Numerics.Statistics.Mcmc
{
@ -106,7 +107,7 @@ namespace MathNet.Numerics.Statistics.Mcmc
{
Accepts = 0;
Samples = 0;
RandomSource = new System.Random(Random.RandomSeed.Guid());
RandomSource = MersenneTwister.Default;
}
/// <summary>

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

@ -30,6 +30,7 @@
using System;
using MathNet.Numerics.Distributions;
using MathNet.Numerics.Random;
namespace MathNet.Numerics.Statistics.Mcmc
{
@ -82,7 +83,7 @@ namespace MathNet.Numerics.Statistics.Mcmc
/// the momentum.</param>
/// <exception cref="ArgumentOutOfRangeException">When the number of burnInterval iteration is negative.</exception>
public UnivariateHybridMC(double x0, DensityLn<double> pdfLnP, int frogLeapSteps, double stepSize, int burnInterval = 0, double pSdv = 1)
: this(x0, pdfLnP, frogLeapSteps, stepSize, burnInterval, pSdv, new System.Random(Random.RandomSeed.Guid()))
: this(x0, pdfLnP, frogLeapSteps, stepSize, burnInterval, pSdv, MersenneTwister.Default)
{
}

Loading…
Cancel
Save