diff --git a/src/Numerics/Distributions/Bernoulli.cs b/src/Numerics/Distributions/Bernoulli.cs
index a46a385d..bc124510 100644
--- a/src/Numerics/Distributions/Bernoulli.cs
+++ b/src/Numerics/Distributions/Bernoulli.cs
@@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
-// Copyright (c) 2009-2013 Math.NET
+// Copyright (c) 2009-2014 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@@ -79,16 +79,6 @@ namespace MathNet.Numerics.Distributions
return "Bernoulli(p = " + _p + ")";
}
- ///
- /// Checks whether the parameters of the distribution are valid.
- ///
- /// The probability (p) of generating one. Range: 0 ≤ p ≤ 1.
- /// true when the parameters are valid, false otherwise.
- static bool IsValidParameterSet(double p)
- {
- return p >= 0.0 && p <= 1.0;
- }
-
///
/// Sets the parameters of the distribution after checking their validity.
///
@@ -96,9 +86,9 @@ namespace MathNet.Numerics.Distributions
/// When the parameters are out of range.
void SetParameters(double p)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(p))
+ if (!(p >= 0.0 && p <= 1.0))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_p = p;
@@ -294,11 +284,7 @@ namespace MathNet.Numerics.Distributions
/// A sample from the Bernoulli distribution.
public static int Sample(System.Random rnd, double p)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(p))
- {
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
- }
-
+ if (!(p >= 0.0 && p <= 1.0)) throw new ArgumentException(Resources.InvalidDistributionParameters);
return SampleUnchecked(rnd, p);
}
@@ -310,11 +296,7 @@ namespace MathNet.Numerics.Distributions
/// a sequence of samples from the distribution.
public static IEnumerable Samples(System.Random rnd, double p)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(p))
- {
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
- }
-
+ if (!(p >= 0.0 && p <= 1.0)) throw new ArgumentException(Resources.InvalidDistributionParameters);
while (true)
{
yield return SampleUnchecked(rnd, p);
@@ -328,7 +310,8 @@ namespace MathNet.Numerics.Distributions
/// A sample from the Bernoulli distribution.
public static int Sample(double p)
{
- return Sample(SystemRandomSource.Default, p);
+ if (!(p >= 0.0 && p <= 1.0)) throw new ArgumentException(Resources.InvalidDistributionParameters);
+ return SampleUnchecked(SystemRandomSource.Default, p);
}
///
@@ -338,7 +321,12 @@ namespace MathNet.Numerics.Distributions
/// a sequence of samples from the distribution.
public static IEnumerable Samples(double p)
{
- return Samples(SystemRandomSource.Default, p);
+ if (!(p >= 0.0 && p <= 1.0)) throw new ArgumentException(Resources.InvalidDistributionParameters);
+ SystemRandomSource rnd = SystemRandomSource.Default;
+ while (true)
+ {
+ yield return SampleUnchecked(rnd, p);
+ }
}
}
diff --git a/src/Numerics/Distributions/Binomial.cs b/src/Numerics/Distributions/Binomial.cs
index 1926a6cf..a3fa2330 100644
--- a/src/Numerics/Distributions/Binomial.cs
+++ b/src/Numerics/Distributions/Binomial.cs
@@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
-// Copyright (c) 2009-2013 Math.NET
+// Copyright (c) 2009-2014 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@@ -86,17 +86,6 @@ namespace MathNet.Numerics.Distributions
return "Binomial(p = " + _p + ", n = " + _trials + ")";
}
- ///
- /// Checks whether the parameters of the distribution are valid.
- ///
- /// The success probability (p) in each trial. Range: 0 ≤ p ≤ 1.
- /// The number of trials (n). Range: n ≥ 0.
- /// false is not in the interval [0.0,1.0] or is negative, true otherwise.
- static bool IsValidParameterSet(double p, int n)
- {
- return p >= 0.0 && p <= 1.0 && n >= 0;
- }
-
///
/// Sets the parameters of the distribution after checking their validity.
///
@@ -106,9 +95,9 @@ namespace MathNet.Numerics.Distributions
/// If is negative.
void SetParameters(double p, int n)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(p, n))
+ if (!(p >= 0.0 && p <= 1.0 && n >= 0))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_p = p;
@@ -220,7 +209,7 @@ namespace MathNet.Numerics.Distributions
if (_p == 1.0) return _trials;
if (_p == 0.0) return 0;
- return (int) Math.Floor((_trials + 1)*_p);
+ return (int)Math.Floor((_trials + 1)*_p);
}
}
@@ -229,7 +218,7 @@ namespace MathNet.Numerics.Distributions
///
public int Median
{
- get { return (int) Math.Floor(_p*_trials); }
+ get { return (int)Math.Floor(_p*_trials); }
}
///
@@ -277,7 +266,7 @@ namespace MathNet.Numerics.Distributions
if (x > _trials) return 1.0;
var cdf = 0.0;
- for (var i = 0; i <= (int) Math.Floor(x); i++)
+ for (var i = 0; i <= (int)Math.Floor(x); i++)
{
cdf += Combinatorics.Combinations(_trials, i)*Math.Pow(_p, i)*Math.Pow(1.0 - _p, _trials - i);
}
@@ -333,11 +322,7 @@ namespace MathNet.Numerics.Distributions
/// The number of successes in trials.
public static int Sample(System.Random rnd, double p, int n)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(p, n))
- {
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
- }
-
+ if (!(p >= 0.0 && p <= 1.0 && n >= 0)) throw new ArgumentException(Resources.InvalidDistributionParameters);
return SampleUnchecked(rnd, p, n);
}
@@ -350,11 +335,7 @@ namespace MathNet.Numerics.Distributions
/// a sequence of successes in trials.
public static IEnumerable Samples(System.Random rnd, double p, int n)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(p, n))
- {
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
- }
-
+ if (!(p >= 0.0 && p <= 1.0 && n >= 0)) throw new ArgumentException(Resources.InvalidDistributionParameters);
while (true)
{
yield return SampleUnchecked(rnd, p, n);
@@ -370,7 +351,8 @@ namespace MathNet.Numerics.Distributions
/// The number of successes in trials.
public static int Sample(double p, int n)
{
- return Sample(SystemRandomSource.Default, p, n);
+ if (!(p >= 0.0 && p <= 1.0 && n >= 0)) throw new ArgumentException(Resources.InvalidDistributionParameters);
+ return SampleUnchecked(SystemRandomSource.Default, p, n);
}
///
@@ -382,7 +364,12 @@ namespace MathNet.Numerics.Distributions
/// a sequence of successes in trials.
public static IEnumerable Samples(double p, int n)
{
- return Samples(SystemRandomSource.Default, p, n);
+ if (!(p >= 0.0 && p <= 1.0 && n >= 0)) throw new ArgumentException(Resources.InvalidDistributionParameters);
+ SystemRandomSource rnd = SystemRandomSource.Default;
+ while (true)
+ {
+ yield return SampleUnchecked(rnd, p, n);
+ }
}
}
}
diff --git a/src/Numerics/Distributions/ConwayMaxwellPoisson.cs b/src/Numerics/Distributions/ConwayMaxwellPoisson.cs
index d03a05d2..b1e8f468 100644
--- a/src/Numerics/Distributions/ConwayMaxwellPoisson.cs
+++ b/src/Numerics/Distributions/ConwayMaxwellPoisson.cs
@@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
-// Copyright (c) 2009-2013 Math.NET
+// Copyright (c) 2009-2014 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@@ -107,17 +107,6 @@ namespace MathNet.Numerics.Distributions
return "ConwayMaxwellPoisson(λ = " + _lambda + ", ν = " + _nu + ")";
}
- ///
- /// Checks whether the parameters of the distribution are valid.
- ///
- /// The lambda (λ) parameter. Range: λ > 0.
- /// The rate of decay (ν) parameter. Range: ν ≥ 0.
- /// true when the parameters are valid, false otherwise.
- static bool IsValidParameterSet(double lambda, double nu)
- {
- return lambda > 0.0 && nu >= 0.0;
- }
-
///
/// Sets the parameters of the distribution after checking their validity.
///
@@ -126,9 +115,9 @@ namespace MathNet.Numerics.Distributions
/// When the parameters are out of range.
void SetParameters(double lambda, double nu)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(lambda, nu))
+ if (!(lambda > 0.0 && nu >= 0.0))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_lambda = lambda;
@@ -493,11 +482,7 @@ namespace MathNet.Numerics.Distributions
/// The rate of decay (ν) parameter. Range: ν ≥ 0.
public static int Sample(System.Random rnd, double lambda, double nu)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(lambda, nu))
- {
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
- }
-
+ if (!(lambda > 0.0 && nu >= 0.0)) throw new ArgumentException(Resources.InvalidDistributionParameters);
var z = Normalization(lambda, nu);
return SampleUnchecked(rnd, lambda, nu, z);
}
@@ -510,11 +495,7 @@ namespace MathNet.Numerics.Distributions
/// The rate of decay (ν) parameter. Range: ν ≥ 0.
public static IEnumerable Samples(System.Random rnd, double lambda, double nu)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(lambda, nu))
- {
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
- }
-
+ if (!(lambda > 0.0 && nu >= 0.0)) throw new ArgumentException(Resources.InvalidDistributionParameters);
var z = Normalization(lambda, nu);
while (true)
{
@@ -529,7 +510,9 @@ namespace MathNet.Numerics.Distributions
/// The rate of decay (ν) parameter. Range: ν ≥ 0.
public static int Sample(double lambda, double nu)
{
- return Sample(SystemRandomSource.Default, lambda, nu);
+ if (!(lambda > 0.0 && nu >= 0.0)) throw new ArgumentException(Resources.InvalidDistributionParameters);
+ var z = Normalization(lambda, nu);
+ return SampleUnchecked(SystemRandomSource.Default, lambda, nu, z);
}
///
@@ -539,7 +522,13 @@ namespace MathNet.Numerics.Distributions
/// The rate of decay (ν) parameter. Range: ν ≥ 0.
public static IEnumerable Samples(double lambda, double nu)
{
- return Samples(SystemRandomSource.Default, lambda, nu);
+ if (!(lambda > 0.0 && nu >= 0.0)) throw new ArgumentException(Resources.InvalidDistributionParameters);
+ var z = Normalization(lambda, nu);
+ SystemRandomSource rnd = SystemRandomSource.Default;
+ while (true)
+ {
+ yield return SampleUnchecked(rnd, lambda, nu, z);
+ }
}
}
}
diff --git a/src/Numerics/Distributions/DiscreteUniform.cs b/src/Numerics/Distributions/DiscreteUniform.cs
index 2667fe2a..7ae65eff 100644
--- a/src/Numerics/Distributions/DiscreteUniform.cs
+++ b/src/Numerics/Distributions/DiscreteUniform.cs
@@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
-// Copyright (c) 2009-2013 Math.NET
+// Copyright (c) 2009-2014 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@@ -82,17 +82,6 @@ namespace MathNet.Numerics.Distributions
return "DiscreteUniform(Lower = " + _lower + ", Upper = " + _upper + ")";
}
- ///
- /// Checks whether the parameters of the distribution are valid.
- ///
- /// Lower bound. Range: lower ≤ upper.
- /// Upper bound. Range: lower ≤ upper.
- /// true when the parameters are valid, false otherwise.
- static bool IsValidParameterSet(int lower, int upper)
- {
- return lower <= upper;
- }
-
///
/// Sets the parameters of the distribution after checking their validity.
///
@@ -101,9 +90,9 @@ namespace MathNet.Numerics.Distributions
/// When the parameters are out of range.
void SetParameters(int lower, int upper)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(lower, upper))
+ if (!(lower <= upper))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_lower = lower;
@@ -198,7 +187,7 @@ namespace MathNet.Numerics.Distributions
///
public int Mode
{
- get { return (int) Math.Floor((_lower + _upper)/2.0); }
+ get { return (int)Math.Floor((_lower + _upper)/2.0); }
}
///
@@ -206,7 +195,7 @@ namespace MathNet.Numerics.Distributions
///
public int Median
{
- get { return (int) Math.Floor((_lower + _upper)/2.0); }
+ get { return (int)Math.Floor((_lower + _upper)/2.0); }
}
///
@@ -301,11 +290,7 @@ namespace MathNet.Numerics.Distributions
/// A sample from the discrete uniform distribution.
public static int Sample(System.Random rnd, int lower, int upper)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(lower, upper))
- {
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
- }
-
+ if (!(lower <= upper)) throw new ArgumentException(Resources.InvalidDistributionParameters);
return SampleUnchecked(rnd, lower, upper);
}
@@ -318,11 +303,7 @@ namespace MathNet.Numerics.Distributions
/// a sequence of samples from the discrete uniform distribution.
public static IEnumerable Samples(System.Random rnd, int lower, int upper)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(lower, upper))
- {
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
- }
-
+ if (!(lower <= upper)) throw new ArgumentException(Resources.InvalidDistributionParameters);
while (true)
{
yield return SampleUnchecked(rnd, lower, upper);
@@ -337,7 +318,8 @@ namespace MathNet.Numerics.Distributions
/// A sample from the discrete uniform distribution.
public static int Sample(int lower, int upper)
{
- return Sample(SystemRandomSource.Default, lower, upper);
+ if (!(lower <= upper)) throw new ArgumentException(Resources.InvalidDistributionParameters);
+ return SampleUnchecked(SystemRandomSource.Default, lower, upper);
}
///
@@ -348,7 +330,12 @@ namespace MathNet.Numerics.Distributions
/// a sequence of samples from the discrete uniform distribution.
public static IEnumerable Samples(int lower, int upper)
{
- return Samples(SystemRandomSource.Default, lower, upper);
+ if (!(lower <= upper)) throw new ArgumentException(Resources.InvalidDistributionParameters);
+ SystemRandomSource rnd = SystemRandomSource.Default;
+ while (true)
+ {
+ yield return SampleUnchecked(rnd, lower, upper);
+ }
}
}
}
diff --git a/src/Numerics/Distributions/Geometric.cs b/src/Numerics/Distributions/Geometric.cs
index 200d1ff4..0d65d6d8 100644
--- a/src/Numerics/Distributions/Geometric.cs
+++ b/src/Numerics/Distributions/Geometric.cs
@@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
-// Copyright (c) 2009-2013 Math.NET
+// Copyright (c) 2009-2014 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@@ -77,16 +77,6 @@ namespace MathNet.Numerics.Distributions
return "Geometric(p = " + _p + ")";
}
- ///
- /// Checks whether the parameters of the distribution are valid.
- ///
- /// The probability (p) of generating one. Range: 0 ≤ p ≤ 1.
- /// true when the parameters are valid, false otherwise.
- static bool IsValidParameterSet(double p)
- {
- return p >= 0.0 && p <= 1.0;
- }
-
///
/// Sets the parameters of the distribution after checking their validity.
///
@@ -94,9 +84,9 @@ namespace MathNet.Numerics.Distributions
/// When the parameters are out of range.
void SetParameters(double p)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(p))
+ if (!(p >= 0.0 && p <= 1.0))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_p = p;
@@ -174,7 +164,7 @@ namespace MathNet.Numerics.Distributions
///
public int Median
{
- get { return (int) Math.Ceiling(-Constants.Ln2/Math.Log(1 - _p)); }
+ get { return (int)Math.Ceiling(-Constants.Ln2/Math.Log(1 - _p)); }
}
///
@@ -272,11 +262,7 @@ namespace MathNet.Numerics.Distributions
/// The probability (p) of generating one. Range: 0 ≤ p ≤ 1.
public static int Sample(System.Random rnd, double p)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(p))
- {
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
- }
-
+ if (!(p >= 0.0 && p <= 1.0)) throw new ArgumentException(Resources.InvalidDistributionParameters);
return SampleUnchecked(rnd, p);
}
@@ -287,11 +273,7 @@ namespace MathNet.Numerics.Distributions
/// The probability (p) of generating one. Range: 0 ≤ p ≤ 1.
public static IEnumerable Samples(System.Random rnd, double p)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(p))
- {
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
- }
-
+ if (!(p >= 0.0 && p <= 1.0)) throw new ArgumentException(Resources.InvalidDistributionParameters);
while (true)
{
yield return SampleUnchecked(rnd, p);
@@ -304,7 +286,8 @@ namespace MathNet.Numerics.Distributions
/// The probability (p) of generating one. Range: 0 ≤ p ≤ 1.
public static int Sample(double p)
{
- return Sample(SystemRandomSource.Default, p);
+ if (!(p >= 0.0 && p <= 1.0)) throw new ArgumentException(Resources.InvalidDistributionParameters);
+ return SampleUnchecked(SystemRandomSource.Default, p);
}
///
@@ -313,7 +296,12 @@ namespace MathNet.Numerics.Distributions
/// The probability (p) of generating one. Range: 0 ≤ p ≤ 1.
public static IEnumerable Samples(double p)
{
- return Samples(SystemRandomSource.Default, p);
+ if (!(p >= 0.0 && p <= 1.0)) throw new ArgumentException(Resources.InvalidDistributionParameters);
+ SystemRandomSource rnd = SystemRandomSource.Default;
+ while (true)
+ {
+ yield return SampleUnchecked(rnd, p);
+ }
}
}
}
diff --git a/src/Numerics/Distributions/Hypergeometric.cs b/src/Numerics/Distributions/Hypergeometric.cs
index dbb1f345..cc7532f1 100644
--- a/src/Numerics/Distributions/Hypergeometric.cs
+++ b/src/Numerics/Distributions/Hypergeometric.cs
@@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
-// Copyright (c) 2009-2013 Math.NET
+// Copyright (c) 2009-2014 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@@ -86,18 +86,6 @@ namespace MathNet.Numerics.Distributions
return "Hypergeometric(N = " + _population + ", M = " + _success + ", n = " + _draws + ")";
}
- ///
- /// Checks whether the parameters of the distribution are valid.
- ///
- /// The size of the population (N).
- /// The number successes within the population (K, M).
- /// The number of draws without replacement (n).
- /// true when the parameters are valid, false otherwise.
- static bool IsValidParameterSet(int population, int success, int draws)
- {
- return population >= 0 && success >= 0 && draws >= 0 && (success <= population && draws <= population);
- }
-
///
/// Sets the parameters of the distribution after checking their validity.
///
@@ -107,9 +95,9 @@ namespace MathNet.Numerics.Distributions
/// When the parameters are out of range.
void SetParameters(int population, int success, int draws)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(population, success, draws))
+ if (!(population >= 0 && success >= 0 && draws >= 0 && success <= population && draws <= population))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_population = population;
@@ -188,7 +176,7 @@ namespace MathNet.Numerics.Distributions
///
public double Mean
{
- get { return (double) _success*_draws/_population; }
+ get { return (double)_success*_draws/_population; }
}
///
@@ -291,7 +279,7 @@ namespace MathNet.Numerics.Distributions
return 1.0;
}
- var k = (int) Math.Floor(x);
+ var k = (int)Math.Floor(x);
var denominatorLn = SpecialFunctions.BinomialLn(_population, _draws);
var sum = 0.0;
for (var i = 0; i <= k; i++)
@@ -315,7 +303,7 @@ namespace MathNet.Numerics.Distributions
do
{
- var p = (double) success/population;
+ var p = (double)success/population;
var r = rnd.NextDouble();
if (r < p)
{
@@ -360,9 +348,9 @@ namespace MathNet.Numerics.Distributions
/// The number of draws without replacement (n).
public static int Sample(System.Random rnd, int population, int success, int draws)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(population, success, draws))
+ if (!(population >= 0 && success >= 0 && draws >= 0 && success <= population && draws <= population))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
return SampleUnchecked(rnd, population, success, draws);
@@ -377,9 +365,9 @@ namespace MathNet.Numerics.Distributions
/// The number of draws without replacement (n).
public static IEnumerable Samples(System.Random rnd, int population, int success, int draws)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(population, success, draws))
+ if (!(population >= 0 && success >= 0 && draws >= 0 && success <= population && draws <= population))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
while (true)
@@ -396,7 +384,12 @@ namespace MathNet.Numerics.Distributions
/// The number of draws without replacement (n).
public static int Sample(int population, int success, int draws)
{
- return Sample(SystemRandomSource.Default, population, success, draws);
+ if (!(population >= 0 && success >= 0 && draws >= 0 && success <= population && draws <= population))
+ {
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
+ }
+
+ return SampleUnchecked(SystemRandomSource.Default, population, success, draws);
}
///
@@ -407,7 +400,16 @@ namespace MathNet.Numerics.Distributions
/// The number of draws without replacement (n).
public static IEnumerable Samples(int population, int success, int draws)
{
- return Samples(SystemRandomSource.Default, population, success, draws);
+ if (!(population >= 0 && success >= 0 && draws >= 0 && success <= population && draws <= population))
+ {
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
+ }
+
+ SystemRandomSource rnd = SystemRandomSource.Default;
+ while (true)
+ {
+ yield return SampleUnchecked(rnd, population, success, draws);
+ }
}
}
}
diff --git a/src/Numerics/Distributions/IDiscreteDistribution.cs b/src/Numerics/Distributions/IDiscreteDistribution.cs
index 0bc3d499..cb2f3201 100644
--- a/src/Numerics/Distributions/IDiscreteDistribution.cs
+++ b/src/Numerics/Distributions/IDiscreteDistribution.cs
@@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
-// Copyright (c) 2009-2013 Math.NET
+// Copyright (c) 2009-2014 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
diff --git a/src/Numerics/Distributions/NegativeBinomial.cs b/src/Numerics/Distributions/NegativeBinomial.cs
index 3b57fe0b..43a148a1 100644
--- a/src/Numerics/Distributions/NegativeBinomial.cs
+++ b/src/Numerics/Distributions/NegativeBinomial.cs
@@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
-// Copyright (c) 2009-2013 Math.NET
+// Copyright (c) 2009-2014 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@@ -83,17 +83,6 @@ namespace MathNet.Numerics.Distributions
return "NegativeBinomial(R = " + _trials + ", P = " + _p + ")";
}
- ///
- /// Checks whether the parameters of the distribution are valid.
- ///
- /// The number of failures (r) until the experiment stopped. Range: r ≥ 0.
- /// The probability (p) of a trial resulting in success. Range: 0 ≤ p ≤ 1.
- /// true when the parameters are valid, false otherwise.
- static bool IsValidParameterSet(double r, double p)
- {
- return r >= 0.0 && p >= 0.0 && p <= 1.0;
- }
-
///
/// Sets the parameters of the distribution after checking their validity.
///
@@ -102,9 +91,9 @@ namespace MathNet.Numerics.Distributions
/// When the parameters are out of range.
void SetParameters(double r, double p)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(r, p))
+ if (!(r >= 0.0 && p >= 0.0 && p <= 1.0))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_p = p;
@@ -137,6 +126,7 @@ namespace MathNet.Numerics.Distributions
get { return _random; }
set { _random = value ?? SystemRandomSource.Default; }
}
+
///
/// Gets the mean of the distribution.
///
@@ -182,7 +172,7 @@ namespace MathNet.Numerics.Distributions
///
public int Mode
{
- get { return _trials > 1.0 ? (int) Math.Floor((_trials - 1.0)*(1.0 - _p)/_p) : 0; }
+ get { return _trials > 1.0 ? (int)Math.Floor((_trials - 1.0)*(1.0 - _p)/_p) : 0; }
}
///
@@ -299,11 +289,7 @@ namespace MathNet.Numerics.Distributions
/// The probability (p) of a trial resulting in success. Range: 0 ≤ p ≤ 1.
public static int Sample(System.Random rnd, double r, double p)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(r, p))
- {
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
- }
-
+ if (!(r >= 0.0 && p >= 0.0 && p <= 1.0)) throw new ArgumentException(Resources.InvalidDistributionParameters);
return SampleUnchecked(rnd, r, p);
}
@@ -315,11 +301,7 @@ namespace MathNet.Numerics.Distributions
/// The probability (p) of a trial resulting in success. Range: 0 ≤ p ≤ 1.
public static IEnumerable Samples(System.Random rnd, double r, double p)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(r, p))
- {
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
- }
-
+ if (!(r >= 0.0 && p >= 0.0 && p <= 1.0)) throw new ArgumentException(Resources.InvalidDistributionParameters);
while (true)
{
yield return SampleUnchecked(rnd, r, p);
@@ -333,7 +315,8 @@ namespace MathNet.Numerics.Distributions
/// The probability (p) of a trial resulting in success. Range: 0 ≤ p ≤ 1.
public static int Sample(double r, double p)
{
- return Sample(SystemRandomSource.Default, r, p);
+ if (!(r >= 0.0 && p >= 0.0 && p <= 1.0)) throw new ArgumentException(Resources.InvalidDistributionParameters);
+ return SampleUnchecked(SystemRandomSource.Default, r, p);
}
///
@@ -343,7 +326,12 @@ namespace MathNet.Numerics.Distributions
/// The probability (p) of a trial resulting in success. Range: 0 ≤ p ≤ 1.
public static IEnumerable Samples(double r, double p)
{
- return Samples(SystemRandomSource.Default, r, p);
+ if (!(r >= 0.0 && p >= 0.0 && p <= 1.0)) throw new ArgumentException(Resources.InvalidDistributionParameters);
+ SystemRandomSource rnd = SystemRandomSource.Default;
+ while (true)
+ {
+ yield return SampleUnchecked(rnd, r, p);
+ }
}
}
}
diff --git a/src/Numerics/Distributions/Poisson.cs b/src/Numerics/Distributions/Poisson.cs
index 26d41cb7..ba261f2b 100644
--- a/src/Numerics/Distributions/Poisson.cs
+++ b/src/Numerics/Distributions/Poisson.cs
@@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
-// Copyright (c) 2009-2013 Math.NET
+// Copyright (c) 2009-2014 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@@ -38,7 +38,7 @@ namespace MathNet.Numerics.Distributions
///
/// Discrete Univariate Poisson distribution.
///
- ///
+ ///
/// Distribution is described at Wikipedia - Poisson distribution.
/// Knuth's method is used to generate Poisson distributed random variables.
/// f(x) = exp(-λ)*λ^x/x!;
@@ -83,16 +83,6 @@ namespace MathNet.Numerics.Distributions
return "Poisson(λ = " + _lambda + ")";
}
- ///
- /// Checks whether the parameters of the distribution are valid.
- ///
- /// The lambda (λ) parameter of the Poisson distribution. Range: λ > 0.
- /// true when the parameters are valid, false otherwise.
- static bool IsValidParameterSet(double lambda)
- {
- return lambda > 0.00;
- }
-
///
/// Sets the parameters of the distribution after checking their validity.
///
@@ -100,9 +90,9 @@ namespace MathNet.Numerics.Distributions
/// When the parameters are out of range.
void SetParameters(double lambda)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(lambda))
+ if (!(lambda > 0.0))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_lambda = lambda;
@@ -188,7 +178,7 @@ namespace MathNet.Numerics.Distributions
///
public int Mode
{
- get { return (int) Math.Floor(_lambda); }
+ get { return (int)Math.Floor(_lambda); }
}
///
@@ -197,7 +187,7 @@ namespace MathNet.Numerics.Distributions
/// Approximation, see Wikipedia Poisson distribution
public int Median
{
- get { return (int) Math.Floor(_lambda + (1.0/3.0) - (0.02/_lambda)); }
+ get { return (int)Math.Floor(_lambda + (1.0/3.0) - (0.02/_lambda)); }
}
///
@@ -279,7 +269,7 @@ namespace MathNet.Numerics.Distributions
{
var u = rnd.NextDouble();
var x = (alpha - Math.Log((1.0 - u)/u))/beta;
- var n = (int) Math.Floor(x + 0.5);
+ var n = (int)Math.Floor(x + 0.5);
if (n < 0)
{
continue;
@@ -326,11 +316,7 @@ namespace MathNet.Numerics.Distributions
/// A sample from the Poisson distribution.
public static int Sample(System.Random rnd, double lambda)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(lambda))
- {
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
- }
-
+ if (!(lambda > 0.0)) throw new ArgumentException(Resources.InvalidDistributionParameters);
return SampleUnchecked(rnd, lambda);
}
@@ -342,11 +328,7 @@ namespace MathNet.Numerics.Distributions
/// a sequence of samples from the distribution.
public static IEnumerable Samples(System.Random rnd, double lambda)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(lambda))
- {
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
- }
-
+ if (!(lambda > 0.0)) throw new ArgumentException(Resources.InvalidDistributionParameters);
while (true)
{
yield return SampleUnchecked(rnd, lambda);
@@ -360,7 +342,8 @@ namespace MathNet.Numerics.Distributions
/// A sample from the Poisson distribution.
public static int Sample(double lambda)
{
- return Sample(SystemRandomSource.Default, lambda);
+ if (!(lambda > 0.0)) throw new ArgumentException(Resources.InvalidDistributionParameters);
+ return SampleUnchecked(SystemRandomSource.Default, lambda);
}
///
@@ -370,7 +353,12 @@ namespace MathNet.Numerics.Distributions
/// a sequence of samples from the distribution.
public static IEnumerable Samples(double lambda)
{
- return Samples(SystemRandomSource.Default, lambda);
+ if (!(lambda > 0.0)) throw new ArgumentException(Resources.InvalidDistributionParameters);
+ SystemRandomSource rnd = SystemRandomSource.Default;
+ while (true)
+ {
+ yield return SampleUnchecked(rnd, lambda);
+ }
}
}
}
diff --git a/src/Numerics/Distributions/Zipf.cs b/src/Numerics/Distributions/Zipf.cs
index 531d402d..e37ea257 100644
--- a/src/Numerics/Distributions/Zipf.cs
+++ b/src/Numerics/Distributions/Zipf.cs
@@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
-// Copyright (c) 2009-2013 Math.NET
+// Copyright (c) 2009-2014 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@@ -89,17 +89,6 @@ namespace MathNet.Numerics.Distributions
return "Zipf(S = " + _s + ", N = " + _n + ")";
}
- ///
- /// Checks whether the parameters of the distribution are valid.
- ///
- /// The s parameter of the distribution.
- /// The n parameter of the distribution.
- /// true when the parameters are valid, false otherwise.
- static bool IsValidParameterSet(double s, int n)
- {
- return n > 0 && s > 0.0;
- }
-
///
/// Sets the parameters of the distribution after checking their validity.
///
@@ -108,9 +97,9 @@ namespace MathNet.Numerics.Distributions
/// When the parameters are out of range.
void SetParameters(double s, int n)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(s, n))
+ if (!(n > 0 && s > 0.0))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_s = s;
@@ -275,7 +264,7 @@ namespace MathNet.Numerics.Distributions
return 0.0;
}
- return SpecialFunctions.GeneralHarmonic((int) x, _s)/SpecialFunctions.GeneralHarmonic(_n, _s);
+ return SpecialFunctions.GeneralHarmonic((int)x, _s)/SpecialFunctions.GeneralHarmonic(_n, _s);
}
///
@@ -337,11 +326,7 @@ namespace MathNet.Numerics.Distributions
/// The n parameter of the distribution.
public static int Sample(System.Random rnd, double s, int n)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(s, n))
- {
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
- }
-
+ if (!(n > 0 && s > 0.0)) throw new ArgumentException(Resources.InvalidDistributionParameters);
return SampleUnchecked(rnd, s, n);
}
@@ -353,11 +338,7 @@ namespace MathNet.Numerics.Distributions
/// The n parameter of the distribution.
public static IEnumerable Samples(System.Random rnd, double s, int n)
{
- if (Control.CheckDistributionParameters && !IsValidParameterSet(s, n))
- {
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
- }
-
+ if (!(n > 0 && s > 0.0)) throw new ArgumentException(Resources.InvalidDistributionParameters);
while (true)
{
yield return SampleUnchecked(rnd, s, n);
@@ -371,7 +352,8 @@ namespace MathNet.Numerics.Distributions
/// The n parameter of the distribution.
public static int Sample(double s, int n)
{
- return Sample(SystemRandomSource.Default, s, n);
+ if (!(n > 0 && s > 0.0)) throw new ArgumentException(Resources.InvalidDistributionParameters);
+ return SampleUnchecked(SystemRandomSource.Default, s, n);
}
///
@@ -381,7 +363,12 @@ namespace MathNet.Numerics.Distributions
/// The n parameter of the distribution.
public static IEnumerable Samples(double s, int n)
{
- return Samples(SystemRandomSource.Default, s, n);
+ if (!(n > 0 && s > 0.0)) throw new ArgumentException(Resources.InvalidDistributionParameters);
+ SystemRandomSource rnd = SystemRandomSource.Default;
+ while (true)
+ {
+ yield return SampleUnchecked(rnd, s, n);
+ }
}
}
}
diff --git a/src/UnitTests/DistributionTests/Continuous/BetaTests.cs b/src/UnitTests/DistributionTests/Continuous/BetaTests.cs
index e914b7a8..630ac0a3 100644
--- a/src/UnitTests/DistributionTests/Continuous/BetaTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/BetaTests.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 Math.NET
+//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -39,15 +43,6 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestFixture, Category("Distributions")]
public class BetaTests
{
- ///
- /// Set-up parameters.
- ///
- [SetUp]
- public void SetUp()
- {
- Control.CheckDistributionParameters = true;
- }
-
///
/// Can create Beta distribution.
///
diff --git a/src/UnitTests/DistributionTests/Continuous/CauchyTests.cs b/src/UnitTests/DistributionTests/Continuous/CauchyTests.cs
index 5295c6d4..907c3c25 100644
--- a/src/UnitTests/DistributionTests/Continuous/CauchyTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/CauchyTests.cs
@@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
-// Copyright (c) 2009-2013 Math.NET
+// Copyright (c) 2009-2014 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@@ -41,15 +41,6 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestFixture, Category("Distributions")]
public class CauchyTests
{
- ///
- /// Set-up parameters.
- ///
- [SetUp]
- public void SetUp()
- {
- Control.CheckDistributionParameters = true;
- }
-
///
/// Can create Cauchy.
///
diff --git a/src/UnitTests/DistributionTests/Continuous/ChiSquareTests.cs b/src/UnitTests/DistributionTests/Continuous/ChiSquareTests.cs
index 0061c5d1..aa7a8ca3 100644
--- a/src/UnitTests/DistributionTests/Continuous/ChiSquareTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/ChiSquareTests.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 Math.NET
+//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -39,15 +43,6 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestFixture, Category("Distributions")]
public class ChiSquareTests
{
- ///
- /// Set-up parameters.
- ///
- [SetUp]
- public void SetUp()
- {
- Control.CheckDistributionParameters = true;
- }
-
///
/// Can create chi square.
///
diff --git a/src/UnitTests/DistributionTests/Continuous/ChiTests.cs b/src/UnitTests/DistributionTests/Continuous/ChiTests.cs
index 4f92cf65..1a240b4c 100644
--- a/src/UnitTests/DistributionTests/Continuous/ChiTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/ChiTests.cs
@@ -4,7 +4,7 @@
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
-// Copyright (c) 2009-2013 Math.NET
+// Copyright (c) 2009-2014 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@@ -41,15 +41,6 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestFixture, Category("Distributions")]
public class ChiTests
{
- ///
- /// Set-up parameters.
- ///
- [SetUp]
- public void SetUp()
- {
- Control.CheckDistributionParameters = true;
- }
-
///
/// Can create chi.
///
diff --git a/src/UnitTests/DistributionTests/Continuous/ContinuousUniformTests.cs b/src/UnitTests/DistributionTests/Continuous/ContinuousUniformTests.cs
index 465cc5be..f8513218 100644
--- a/src/UnitTests/DistributionTests/Continuous/ContinuousUniformTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/ContinuousUniformTests.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 Math.NET
+//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -39,15 +43,6 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestFixture, Category("Distributions")]
public class ContinuousUniformTests
{
- ///
- /// Set-up parameters.
- ///
- [SetUp]
- public void SetUp()
- {
- Control.CheckDistributionParameters = true;
- }
-
///
/// Can create continuous uniform.
///
diff --git a/src/UnitTests/DistributionTests/Continuous/ErlangTests.cs b/src/UnitTests/DistributionTests/Continuous/ErlangTests.cs
index 8e1d224e..bc72b55f 100644
--- a/src/UnitTests/DistributionTests/Continuous/ErlangTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/ErlangTests.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 Math.NET
+//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -37,15 +41,6 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestFixture, Category("Distributions")]
public class ErlangTests
{
- ///
- /// Set-up parameters.
- ///
- [SetUp]
- public void SetUp()
- {
- Control.CheckDistributionParameters = true;
- }
-
///
/// Can create Erlang.
///
diff --git a/src/UnitTests/DistributionTests/Continuous/ExponentialTests.cs b/src/UnitTests/DistributionTests/Continuous/ExponentialTests.cs
index d32edd3b..4d8ed138 100644
--- a/src/UnitTests/DistributionTests/Continuous/ExponentialTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/ExponentialTests.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 Math.NET
+//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -37,15 +41,6 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestFixture, Category("Distributions")]
public class ExponentialTests
{
- ///
- /// Set-up parameters.
- ///
- [SetUp]
- public void SetUp()
- {
- Control.CheckDistributionParameters = true;
- }
-
///
/// Can create exponential.
///
diff --git a/src/UnitTests/DistributionTests/Continuous/FisherSnedecorTests.cs b/src/UnitTests/DistributionTests/Continuous/FisherSnedecorTests.cs
index 5f39557d..e9c27f8d 100644
--- a/src/UnitTests/DistributionTests/Continuous/FisherSnedecorTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/FisherSnedecorTests.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 Math.NET
+//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -37,15 +41,6 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestFixture, Category("Distributions")]
public class FisherSnedecorTests
{
- ///
- /// Set-up parameters.
- ///
- [SetUp]
- public void SetUp()
- {
- Control.CheckDistributionParameters = true;
- }
-
///
/// Can create fisher snedecor.
///
diff --git a/src/UnitTests/DistributionTests/Continuous/GammaTests.cs b/src/UnitTests/DistributionTests/Continuous/GammaTests.cs
index b4b006f8..6efe0760 100644
--- a/src/UnitTests/DistributionTests/Continuous/GammaTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/GammaTests.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 Math.NET
+//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -39,15 +43,6 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestFixture, Category("Distributions")]
public class GammaTests
{
- ///
- /// Set-up parameters.
- ///
- [SetUp]
- public void SetUp()
- {
- Control.CheckDistributionParameters = true;
- }
-
///
/// Can create gamma.
///
diff --git a/src/UnitTests/DistributionTests/Continuous/InverseGammaTests.cs b/src/UnitTests/DistributionTests/Continuous/InverseGammaTests.cs
index 60603e18..8023e551 100644
--- a/src/UnitTests/DistributionTests/Continuous/InverseGammaTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/InverseGammaTests.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 Math.NET
+//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -37,15 +41,6 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestFixture, Category("Distributions")]
public class InverseGammaTests
{
- ///
- /// Set-up parameters.
- ///
- [SetUp]
- public void SetUp()
- {
- Control.CheckDistributionParameters = true;
- }
-
///
/// Can create inverse gamma.
///
diff --git a/src/UnitTests/DistributionTests/Continuous/LaplaceTests.cs b/src/UnitTests/DistributionTests/Continuous/LaplaceTests.cs
index 6221a3d2..491e851b 100644
--- a/src/UnitTests/DistributionTests/Continuous/LaplaceTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/LaplaceTests.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 Math.NET
+//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -37,15 +41,6 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestFixture, Category("Distributions")]
public class LaplaceTests
{
- ///
- /// Set-up parameters.
- ///
- [SetUp]
- public void SetUp()
- {
- Control.CheckDistributionParameters = true;
- }
-
///
/// Can create Laplace.
///
diff --git a/src/UnitTests/DistributionTests/Continuous/LogNormalTests.cs b/src/UnitTests/DistributionTests/Continuous/LogNormalTests.cs
index 5a1656e2..2abd854b 100644
--- a/src/UnitTests/DistributionTests/Continuous/LogNormalTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/LogNormalTests.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 Math.NET
+//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -39,15 +43,6 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestFixture, Category("Distributions")]
public class LogNormalTests
{
- ///
- /// Set-up parameters.
- ///
- [SetUp]
- public void SetUp()
- {
- Control.CheckDistributionParameters = true;
- }
-
///
/// Can create LogNormal.
///
diff --git a/src/UnitTests/DistributionTests/Continuous/NormalTests.cs b/src/UnitTests/DistributionTests/Continuous/NormalTests.cs
index bf163821..86d7e148 100644
--- a/src/UnitTests/DistributionTests/Continuous/NormalTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/NormalTests.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 Math.NET
+//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -39,15 +43,6 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestFixture, Category("Distributions")]
public class NormalTests
{
- ///
- /// Set-up parameters.
- ///
- [SetUp]
- public void SetUp()
- {
- Control.CheckDistributionParameters = true;
- }
-
///
/// Can create standard normal.
///
diff --git a/src/UnitTests/DistributionTests/Continuous/ParetoTests.cs b/src/UnitTests/DistributionTests/Continuous/ParetoTests.cs
index e8568e9f..bb046e36 100644
--- a/src/UnitTests/DistributionTests/Continuous/ParetoTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/ParetoTests.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 Math.NET
+//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -37,15 +41,6 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestFixture, Category("Distributions")]
public class ParetoTests
{
- ///
- /// Set-up parameters.
- ///
- [SetUp]
- public void SetUp()
- {
- Control.CheckDistributionParameters = true;
- }
-
///
/// Can create Pareto distribution.
///
diff --git a/src/UnitTests/DistributionTests/Continuous/RayleighTests.cs b/src/UnitTests/DistributionTests/Continuous/RayleighTests.cs
index f70cfae5..34870515 100644
--- a/src/UnitTests/DistributionTests/Continuous/RayleighTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/RayleighTests.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 Math.NET
+//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -37,15 +41,6 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestFixture, Category("Distributions")]
public class RayleighTests
{
- ///
- /// Set-up parameters.
- ///
- [SetUp]
- public void SetUp()
- {
- Control.CheckDistributionParameters = true;
- }
-
///
/// Can create Rayleigh
///
diff --git a/src/UnitTests/DistributionTests/Continuous/StableTests.cs b/src/UnitTests/DistributionTests/Continuous/StableTests.cs
index b77cb7da..1159f142 100644
--- a/src/UnitTests/DistributionTests/Continuous/StableTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/StableTests.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 Math.NET
+//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -37,15 +41,6 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestFixture, Category("Distributions")]
public class StableTests
{
- ///
- /// Set-up parameters.
- ///
- [SetUp]
- public void SetUp()
- {
- Control.CheckDistributionParameters = true;
- }
-
///
/// Can create stable.
///
diff --git a/src/UnitTests/DistributionTests/Continuous/StudentTTests.cs b/src/UnitTests/DistributionTests/Continuous/StudentTTests.cs
index 8fb54c40..6adb52bd 100644
--- a/src/UnitTests/DistributionTests/Continuous/StudentTTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/StudentTTests.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 Math.NET
+//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -39,15 +43,6 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestFixture, Category("Distributions")]
public class StudentTTests
{
- ///
- /// Set-up parameters.
- ///
- [SetUp]
- public void SetUp()
- {
- Control.CheckDistributionParameters = true;
- }
-
///
/// Can create standard StudentT.
///
diff --git a/src/UnitTests/DistributionTests/Continuous/WeibullTests.cs b/src/UnitTests/DistributionTests/Continuous/WeibullTests.cs
index 965e4f17..62cfa54b 100644
--- a/src/UnitTests/DistributionTests/Continuous/WeibullTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/WeibullTests.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 Math.NET
+//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -39,15 +43,6 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestFixture, Category("Distributions")]
public class WeibullTests
{
- ///
- /// Set-up parameters.
- ///
- [SetUp]
- public void SetUp()
- {
- Control.CheckDistributionParameters = true;
- }
-
///
/// Can create Weibull.
///
diff --git a/src/UnitTests/DistributionTests/Discrete/BernoulliTests.cs b/src/UnitTests/DistributionTests/Discrete/BernoulliTests.cs
index f8c90fef..d0194150 100644
--- a/src/UnitTests/DistributionTests/Discrete/BernoulliTests.cs
+++ b/src/UnitTests/DistributionTests/Discrete/BernoulliTests.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 Math.NET
+//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -37,15 +41,6 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[TestFixture, Category("Distributions")]
public class BernoulliTests
{
- ///
- /// Set-up parameters.
- ///
- [SetUp]
- public void SetUp()
- {
- Control.CheckDistributionParameters = true;
- }
-
///
/// Can create Bernoulli.
///
@@ -68,7 +63,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[TestCase(2.0)]
public void BernoulliCreateFailsWithBadParameters(double p)
{
- Assert.Throws(() => new Bernoulli(p));
+ Assert.That(() => new Bernoulli(p), Throws.ArgumentException);
}
///
@@ -106,7 +101,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
public void SetProbabilityOfOneFails(double p)
{
var b = new Bernoulli(0.3);
- Assert.Throws(() => b.P = p);
+ Assert.That(() => b.P = p, Throws.ArgumentException);
}
///
@@ -252,7 +247,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[Test]
public void FailSampleStatic()
{
- Assert.Throws(() => Bernoulli.Sample(new Random(0), -1.0));
+ Assert.That(() => Bernoulli.Sample(new Random(0), -1.0), Throws.ArgumentException);
}
///
@@ -261,7 +256,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[Test]
public void FailSampleSequenceStatic()
{
- Assert.Throws(() => Bernoulli.Samples(new Random(0), -1.0).First());
+ Assert.That(() => Bernoulli.Samples(new Random(0), -1.0).First(), Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Discrete/BinomialTests.cs b/src/UnitTests/DistributionTests/Discrete/BinomialTests.cs
index 99e203ec..917d164d 100644
--- a/src/UnitTests/DistributionTests/Discrete/BinomialTests.cs
+++ b/src/UnitTests/DistributionTests/Discrete/BinomialTests.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 Math.NET
+//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -37,15 +41,6 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[TestFixture, Category("Distributions")]
public class BinomialTests
{
- ///
- /// Set-up parameters.
- ///
- [SetUp]
- public void SetUp()
- {
- Control.CheckDistributionParameters = true;
- }
-
///
/// Can create binomial.
///
@@ -71,7 +66,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[TestCase(0.3, -2)]
public void BinomialCreateFailsWithBadParameters(double p, int n)
{
- Assert.Throws(() => new Binomial(p, n));
+ Assert.That(() => new Binomial(p, n), Throws.ArgumentException);
}
///
@@ -110,7 +105,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
public void SetProbabilityOfOneFails(double p)
{
var b = new Binomial(0.3, 1);
- Assert.Throws(() => b.P = p);
+ Assert.That(() => b.P = p, Throws.ArgumentException);
}
///
@@ -276,7 +271,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[Test]
public void FailSampleStatic()
{
- Assert.Throws(() => Binomial.Sample(new Random(0), -1.0, 5));
+ Assert.That(() => Binomial.Sample(new Random(0), -1.0, 5), Throws.ArgumentException);
}
///
@@ -285,7 +280,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[Test]
public void FailSampleSequenceStatic()
{
- Assert.Throws(() => Binomial.Samples(new Random(0), -1.0, 5).First());
+ Assert.That(() => Binomial.Samples(new Random(0), -1.0, 5).First(), Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Discrete/CategoricalTests.cs b/src/UnitTests/DistributionTests/Discrete/CategoricalTests.cs
index 34cb76b1..ca22f482 100644
--- a/src/UnitTests/DistributionTests/Discrete/CategoricalTests.cs
+++ b/src/UnitTests/DistributionTests/Discrete/CategoricalTests.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 Math.NET
+//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
diff --git a/src/UnitTests/DistributionTests/Discrete/ConwayMaxwellPoissonTests.cs b/src/UnitTests/DistributionTests/Discrete/ConwayMaxwellPoissonTests.cs
index e2115b3c..99742db3 100644
--- a/src/UnitTests/DistributionTests/Discrete/ConwayMaxwellPoissonTests.cs
+++ b/src/UnitTests/DistributionTests/Discrete/ConwayMaxwellPoissonTests.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 Math.NET
+//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -37,15 +41,6 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[TestFixture, Category("Distributions")]
public class ConwayMaxwellPoissonTests
{
- ///
- /// Set-up test parameters.
- ///
- [SetUp]
- public void SetUp()
- {
- Control.CheckDistributionParameters = true;
- }
-
///
/// Can create ConwayMaxwellPoisson.
///
@@ -69,7 +64,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[Test]
public void ConwayMaxwellPoissonCreateFailsWithBadParameters()
{
- Assert.Throws(() => new ConwayMaxwellPoisson(-1.0, -2.0));
+ Assert.That(() => new ConwayMaxwellPoisson(-1.0, -2.0), Throws.ArgumentException);
}
///
@@ -125,7 +120,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
public void SetLambdaFails(double lambda)
{
var d = new ConwayMaxwellPoisson(1.0, 2.0);
- Assert.Throws(() => d.Lambda = lambda);
+ Assert.That(() => d.Lambda = lambda, Throws.ArgumentException);
}
///
@@ -139,7 +134,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
public void SetNuFails(double nu)
{
var d = new ConwayMaxwellPoisson(1.0, 2.0);
- Assert.Throws(() => d.Nu = nu);
+ Assert.That(() => d.Nu = nu, Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Discrete/DiscreteUniformTests.cs b/src/UnitTests/DistributionTests/Discrete/DiscreteUniformTests.cs
index 6c176a00..0a5852da 100644
--- a/src/UnitTests/DistributionTests/Discrete/DiscreteUniformTests.cs
+++ b/src/UnitTests/DistributionTests/Discrete/DiscreteUniformTests.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 Math.NET
+//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -37,15 +41,6 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[TestFixture, Category("Distributions")]
public class DiscreteUniformTests
{
- ///
- /// Set-up tests parameters.
- ///
- [SetUp]
- public void SetUp()
- {
- Control.CheckDistributionParameters = true;
- }
-
///
/// Can create discrete uniform.
///
@@ -71,7 +66,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[TestCase(6, 5)]
public void DiscreteUniformCreateFailsWithBadParameters(int l, int u)
{
- Assert.Throws(() => new DiscreteUniform(l, u));
+ Assert.That(() => new DiscreteUniform(l, u), Throws.ArgumentException);
}
///
@@ -123,7 +118,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
public void SetLowerBoundFails(int p)
{
var b = new DiscreteUniform(0, 10);
- Assert.Throws(() => b.LowerBound = p);
+ Assert.That(() => b.LowerBound = p, Throws.ArgumentException);
}
///
@@ -135,7 +130,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
public void SetUpperBoundFails(int p)
{
var b = new DiscreteUniform(0, 10);
- Assert.Throws(() => b.UpperBound = p);
+ Assert.That(() => b.UpperBound = p, Throws.ArgumentException);
}
///
@@ -298,7 +293,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[Test]
public void FailSampleStatic()
{
- Assert.Throws(() => DiscreteUniform.Sample(new Random(0), 20, 10));
+ Assert.That(() => DiscreteUniform.Sample(new Random(0), 20, 10), Throws.ArgumentException);
}
///
@@ -307,7 +302,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[Test]
public void FailSampleSequenceStatic()
{
- Assert.Throws(() => DiscreteUniform.Samples(new Random(0), 20, 10).First());
+ Assert.That(() => DiscreteUniform.Samples(new Random(0), 20, 10).First(), Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Discrete/GeometricTests.cs b/src/UnitTests/DistributionTests/Discrete/GeometricTests.cs
index c37443ba..abf869e5 100644
--- a/src/UnitTests/DistributionTests/Discrete/GeometricTests.cs
+++ b/src/UnitTests/DistributionTests/Discrete/GeometricTests.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 Math.NET
+//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -37,15 +41,6 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[TestFixture, Category("Distributions")]
public class GeometricTests
{
- ///
- /// Set-up parameters.
- ///
- [SetUp]
- public void SetUp()
- {
- Control.CheckDistributionParameters = true;
- }
-
///
/// Can create Geometric.
///
@@ -68,7 +63,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[TestCase(2.0)]
public void GeometricCreateFailsWithBadParameters(double p)
{
- Assert.Throws(() => new Geometric(p));
+ Assert.That(() => new Geometric(p), Throws.ArgumentException);
}
///
@@ -106,7 +101,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
public void SetProbabilityOfOneFails(double p)
{
var d = new Geometric(0.3);
- Assert.Throws(() => d.P = p);
+ Assert.That(() => d.P = p, Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Discrete/HypergeometricTests.cs b/src/UnitTests/DistributionTests/Discrete/HypergeometricTests.cs
index d3aa158d..a7bd0d4a 100644
--- a/src/UnitTests/DistributionTests/Discrete/HypergeometricTests.cs
+++ b/src/UnitTests/DistributionTests/Discrete/HypergeometricTests.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 Math.NET
+//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -37,15 +41,6 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[TestFixture, Category("Distributions")]
public class HypergeometricTests
{
- ///
- /// Set-up parameters.
- ///
- [SetUp]
- public void SetUp()
- {
- Control.CheckDistributionParameters = true;
- }
-
///
/// Can create Hypergeometric.
///
@@ -78,7 +73,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[TestCase(0, 1, 1)]
public void HypergeometricCreateFailsWithBadParameters(int population, int success, int n)
{
- Assert.Throws(() => new Hypergeometric(population, success, n));
+ Assert.That(() => new Hypergeometric(population, success, n), Throws.ArgumentException);
}
///
@@ -115,7 +110,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
public void SetPopulationFails(int population)
{
var d = new Hypergeometric(10, 1, 1);
- Assert.Throws(() => d.Population = population);
+ Assert.That(() => d.Population = population, Throws.ArgumentException);
}
///
@@ -143,7 +138,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
public void SetSuccessFails(int success)
{
var d = new Hypergeometric(10, 1, 1);
- Assert.Throws(() => d.Success = success);
+ Assert.That(() => d.Success = success, Throws.ArgumentException);
}
///
@@ -171,7 +166,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
public void SetDrawsFails(int draws)
{
var d = new Hypergeometric(10, 1, 1);
- Assert.Throws(() => d.Draws = draws);
+ Assert.That(() => d.Draws = draws, Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Discrete/NegativeBinomialTests.cs b/src/UnitTests/DistributionTests/Discrete/NegativeBinomialTests.cs
index 14134e72..3490c4da 100644
--- a/src/UnitTests/DistributionTests/Discrete/NegativeBinomialTests.cs
+++ b/src/UnitTests/DistributionTests/Discrete/NegativeBinomialTests.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 Math.NET
+//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -37,15 +41,6 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[TestFixture, Category("Distributions")]
public class NegativeBinomialTests
{
- ///
- /// Set-up parameters.
- ///
- [SetUp]
- public void SetUp()
- {
- Control.CheckDistributionParameters = true;
- }
-
///
/// Can create Negative Binomial.
///
@@ -76,7 +71,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[TestCase(Double.NaN, Double.NaN)]
public void NegativeBinomialCreateFailsWithBadParameters(double r, double p)
{
- Assert.Throws(() => new NegativeBinomial(r, p));
+ Assert.That(() => new NegativeBinomial(r, p), Throws.ArgumentException);
}
///
@@ -114,7 +109,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
public void SetRFails(double r)
{
var d = new NegativeBinomial(1.0, 0.5);
- Assert.Throws(() => d.R = r);
+ Assert.That(() => d.R = r, Throws.ArgumentException);
}
///
@@ -142,7 +137,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
public void SetProbabilityOfOneFails(double p)
{
var d = new NegativeBinomial(1.0, 0.5);
- Assert.Throws(() => d.P = p);
+ Assert.That(() => d.P = p, Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Discrete/PoissonTests.cs b/src/UnitTests/DistributionTests/Discrete/PoissonTests.cs
index 91f1edff..86e64332 100644
--- a/src/UnitTests/DistributionTests/Discrete/PoissonTests.cs
+++ b/src/UnitTests/DistributionTests/Discrete/PoissonTests.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 Math.NET
+//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -37,15 +41,6 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[TestFixture, Category("Distributions")]
public class PoissonTests
{
- ///
- /// Set-up parameters.
- ///
- [SetUp]
- public void SetUp()
- {
- Control.CheckDistributionParameters = true;
- }
-
///
/// Can create Poisson.
///
@@ -68,7 +63,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[TestCase(0.0)]
public void PoissonCreateFailsWithBadParameters(double lambda)
{
- Assert.Throws(() => new Poisson(lambda));
+ Assert.That(() => new Poisson(lambda), Throws.ArgumentException);
}
///
@@ -106,7 +101,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
public void SetProbabilityOfOneFails(double lambda)
{
var d = new Poisson(0.3);
- Assert.Throws(() => d.Lambda = lambda);
+ Assert.That(() => d.Lambda = lambda, Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Discrete/ZipfTests.cs b/src/UnitTests/DistributionTests/Discrete/ZipfTests.cs
index 2a2b3ac6..0e28eeaf 100644
--- a/src/UnitTests/DistributionTests/Discrete/ZipfTests.cs
+++ b/src/UnitTests/DistributionTests/Discrete/ZipfTests.cs
@@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
-// Copyright (c) 2009-2010 Math.NET
+//
+// Copyright (c) 2009-2014 Math.NET
+//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -37,15 +41,6 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[TestFixture, Category("Distributions")]
public class ZipfTests
{
- ///
- /// Set-up parameters.
- ///
- [SetUp]
- public void SetUp()
- {
- Control.CheckDistributionParameters = true;
- }
-
///
/// Can create zipf.
///
@@ -70,7 +65,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[TestCase(0.0, 0)]
public void ZipfCreateFailsWithBadParameters(double s, int n)
{
- Assert.Throws(() => new Zipf(s, n));
+ Assert.That(() => new Zipf(s, n), Throws.ArgumentException);
}
///
@@ -108,7 +103,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
public void SetSFails(double s)
{
var d = new Zipf(1.0, 5);
- Assert.Throws(() => d.S = s);
+ Assert.That(() => d.S = s, Throws.ArgumentException);
}
///
@@ -135,7 +130,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
public void SetNFails(int n)
{
var d = new Zipf(1.0, 5);
- Assert.Throws(() => d.N = n);
+ Assert.That(() => d.N = n, Throws.ArgumentException);
}
///