diff --git a/src/Numerics/Distributions/Beta.cs b/src/Numerics/Distributions/Beta.cs
index e99d6240..dbf79e5b 100644
--- a/src/Numerics/Distributions/Beta.cs
+++ b/src/Numerics/Distributions/Beta.cs
@@ -98,7 +98,7 @@ namespace MathNet.Numerics.Distributions
{
if (a < 0.0 || b < 0.0 || Double.IsNaN(a) || Double.IsNaN(b))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_shapeA = a;
@@ -385,7 +385,7 @@ namespace MathNet.Numerics.Distributions
///
public static double PDF(double a, double b, double x)
{
- if (a < 0.0 || b < 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (a < 0.0 || b < 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
if (x < 0.0 || x > 1.0) return 0.0;
@@ -432,7 +432,7 @@ namespace MathNet.Numerics.Distributions
///
public static double PDFLn(double a, double b, double x)
{
- if (a < 0.0 || b < 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (a < 0.0 || b < 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
if (x < 0.0 || x > 1.0) return Double.NegativeInfinity;
@@ -477,7 +477,7 @@ namespace MathNet.Numerics.Distributions
///
public static double CDF(double a, double b, double x)
{
- if (a < 0.0 || b < 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (a < 0.0 || b < 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
if (x < 0.0) return 0.0;
if (x >= 1.0) return 1.0;
@@ -526,7 +526,7 @@ namespace MathNet.Numerics.Distributions
/// WARNING: currently not an explicit implementation, hence slow and unreliable.
public static double InvCDF(double a, double b, double p)
{
- if (a < 0.0 || b < 0.0 || p < 0.0 || p > 1.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (a < 0.0 || b < 0.0 || p < 0.0 || p > 1.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return Brent.FindRoot(x => SpecialFunctions.BetaRegularized(a, b, x) - p, 0.0, 1.0, accuracy: 1e-8);
}
@@ -540,7 +540,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public static double Sample(System.Random rnd, double a, double b)
{
- if (a < 0.0 || b < 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (a < 0.0 || b < 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return SampleUnchecked(rnd, a, b);
}
@@ -554,7 +554,7 @@ namespace MathNet.Numerics.Distributions
/// a sequence of samples from the distribution.
public static IEnumerable Samples(System.Random rnd, double a, double b)
{
- if (a < 0.0 || b < 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (a < 0.0 || b < 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
while (true)
{
diff --git a/src/Numerics/Distributions/Categorical.cs b/src/Numerics/Distributions/Categorical.cs
index 7c837c6f..44335c5b 100644
--- a/src/Numerics/Distributions/Categorical.cs
+++ b/src/Numerics/Distributions/Categorical.cs
@@ -169,7 +169,7 @@ namespace MathNet.Numerics.Distributions
{
if (Control.CheckDistributionParameters && !IsValidProbabilityMass(p))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
// Extract unnormalized cumulative distribution
@@ -376,7 +376,7 @@ namespace MathNet.Numerics.Distributions
{
if (Control.CheckDistributionParameters && !IsValidCumulativeDistribution(cdfUnnormalized))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
if (probability < 0.0 || probability > 1.0 || Double.IsNaN(probability))
@@ -464,7 +464,7 @@ namespace MathNet.Numerics.Distributions
{
if (Control.CheckDistributionParameters && !IsValidCumulativeDistribution(cdfUnnormalized))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
return SampleUnchecked(rnd, cdfUnnormalized);
@@ -480,7 +480,7 @@ namespace MathNet.Numerics.Distributions
{
if (Control.CheckDistributionParameters && !IsValidProbabilityMass(pmfUnnormalized))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
var cdf = ProbabilityMassToCumulativeDistribution(pmfUnnormalized);
@@ -497,7 +497,7 @@ namespace MathNet.Numerics.Distributions
{
if (Control.CheckDistributionParameters && !IsValidCumulativeDistribution(cdfUnnormalized))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
while (true)
@@ -516,7 +516,7 @@ namespace MathNet.Numerics.Distributions
{
if (Control.CheckDistributionParameters && !IsValidProbabilityMass(pmfUnnormalized))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
var cdf = ProbabilityMassToCumulativeDistribution(pmfUnnormalized);
diff --git a/src/Numerics/Distributions/Cauchy.cs b/src/Numerics/Distributions/Cauchy.cs
index 52727cf0..ea09afd3 100644
--- a/src/Numerics/Distributions/Cauchy.cs
+++ b/src/Numerics/Distributions/Cauchy.cs
@@ -96,7 +96,7 @@ namespace MathNet.Numerics.Distributions
{
if (scale <= 0.0 || Double.IsNaN(location) || Double.IsNaN(scale))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_location = location;
diff --git a/src/Numerics/Distributions/Chi.cs b/src/Numerics/Distributions/Chi.cs
index 7446ece1..f9f4bfca 100644
--- a/src/Numerics/Distributions/Chi.cs
+++ b/src/Numerics/Distributions/Chi.cs
@@ -87,7 +87,7 @@ namespace MathNet.Numerics.Distributions
{
if (freedom <= 0.0 || Double.IsNaN(freedom))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_freedom = freedom;
diff --git a/src/Numerics/Distributions/ChiSquared.cs b/src/Numerics/Distributions/ChiSquared.cs
index 8b3f7665..d994f919 100644
--- a/src/Numerics/Distributions/ChiSquared.cs
+++ b/src/Numerics/Distributions/ChiSquared.cs
@@ -85,7 +85,7 @@ namespace MathNet.Numerics.Distributions
{
if (freedom <= 0.0 || Double.IsNaN(freedom))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_freedom = freedom;
@@ -269,7 +269,7 @@ namespace MathNet.Numerics.Distributions
///
public static double PDF(double freedom, double x)
{
- if (freedom <= 0.0) throw new ArgumentOutOfRangeException("freedom", Resources.InvalidDistributionParameters);
+ if (freedom <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return (Math.Pow(x, (freedom/2.0) - 1.0)*Math.Exp(-x/2.0))/(Math.Pow(2.0, freedom/2.0)*SpecialFunctions.Gamma(freedom/2.0));
}
@@ -283,7 +283,7 @@ namespace MathNet.Numerics.Distributions
///
public static double PDFLn(double freedom, double x)
{
- if (freedom <= 0.0) throw new ArgumentOutOfRangeException("freedom", Resources.InvalidDistributionParameters);
+ if (freedom <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return (-x/2.0) + (((freedom/2.0) - 1.0)*Math.Log(x)) - ((freedom/2.0)*Math.Log(2)) - SpecialFunctions.GammaLn(freedom/2.0);
}
@@ -297,7 +297,7 @@ namespace MathNet.Numerics.Distributions
///
public static double CDF(double freedom, double x)
{
- if (freedom <= 0.0) throw new ArgumentOutOfRangeException("freedom", Resources.InvalidDistributionParameters);
+ if (freedom <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return SpecialFunctions.GammaLowerIncomplete(freedom/2.0, x/2.0)/SpecialFunctions.Gamma(freedom/2.0);
}
@@ -310,7 +310,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public static double Sample(System.Random rnd, double freedom)
{
- if (freedom <= 0.0) throw new ArgumentOutOfRangeException("freedom", Resources.InvalidDistributionParameters);
+ if (freedom <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return SampleUnchecked(rnd, freedom);
}
@@ -323,7 +323,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public static IEnumerable Samples(System.Random rnd, double freedom)
{
- if (freedom <= 0.0) throw new ArgumentOutOfRangeException("freedom", Resources.InvalidDistributionParameters);
+ if (freedom <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
while (true)
{
diff --git a/src/Numerics/Distributions/ContinuousUniform.cs b/src/Numerics/Distributions/ContinuousUniform.cs
index 9102f6f5..f333d242 100644
--- a/src/Numerics/Distributions/ContinuousUniform.cs
+++ b/src/Numerics/Distributions/ContinuousUniform.cs
@@ -98,7 +98,7 @@ namespace MathNet.Numerics.Distributions
{
if (upper < lower || Double.IsNaN(upper) || Double.IsNaN(lower))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_lower = lower;
@@ -283,7 +283,7 @@ namespace MathNet.Numerics.Distributions
///
public static double PDF(double lower, double upper, double x)
{
- if (upper < lower) throw new ArgumentOutOfRangeException("upper", Resources.InvalidDistributionParameters);
+ if (upper < lower) throw new ArgumentException(Resources.InvalidDistributionParameters);
return x < lower || x > upper ? 0.0 : 1.0/(upper - lower);
}
@@ -298,7 +298,7 @@ namespace MathNet.Numerics.Distributions
///
public static double PDFLn(double lower, double upper, double x)
{
- if (upper < lower) throw new ArgumentOutOfRangeException("upper", Resources.InvalidDistributionParameters);
+ if (upper < lower) throw new ArgumentException(Resources.InvalidDistributionParameters);
return x < lower || x > upper ? Double.NegativeInfinity : -Math.Log(upper - lower);
}
@@ -313,7 +313,7 @@ namespace MathNet.Numerics.Distributions
///
public static double CDF(double lower, double upper, double x)
{
- if (upper < lower) throw new ArgumentOutOfRangeException("upper", Resources.InvalidDistributionParameters);
+ if (upper < lower) throw new ArgumentException(Resources.InvalidDistributionParameters);
return x <= lower ? 0.0 : x >= upper ? 1.0 : (x - lower)/(upper - lower);
}
@@ -329,7 +329,7 @@ namespace MathNet.Numerics.Distributions
///
public static double InvCDF(double lower, double upper, double p)
{
- if (upper < lower) throw new ArgumentOutOfRangeException("upper", Resources.InvalidDistributionParameters);
+ if (upper < lower) throw new ArgumentException(Resources.InvalidDistributionParameters);
return p <= 0.0 ? lower : p >= 1.0 ? upper : lower*(1.0 - p) + upper*p;
}
@@ -343,7 +343,7 @@ namespace MathNet.Numerics.Distributions
/// a uniformly distributed sample.
public static double Sample(System.Random rnd, double lower, double upper)
{
- if (upper < lower) throw new ArgumentOutOfRangeException("upper", Resources.InvalidDistributionParameters);
+ if (upper < lower) throw new ArgumentException(Resources.InvalidDistributionParameters);
return lower + rnd.NextDouble()*(upper - lower);
}
@@ -357,7 +357,7 @@ namespace MathNet.Numerics.Distributions
/// a sequence of uniformly distributed samples.
public static IEnumerable Samples(System.Random rnd, double lower, double upper)
{
- if (upper < lower) throw new ArgumentOutOfRangeException("upper", Resources.InvalidDistributionParameters);
+ if (upper < lower) throw new ArgumentException(Resources.InvalidDistributionParameters);
while (true)
{
diff --git a/src/Numerics/Distributions/Dirichlet.cs b/src/Numerics/Distributions/Dirichlet.cs
index fd48cd94..420713a5 100644
--- a/src/Numerics/Distributions/Dirichlet.cs
+++ b/src/Numerics/Distributions/Dirichlet.cs
@@ -154,7 +154,7 @@ namespace MathNet.Numerics.Distributions
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(alpha))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_alpha = (double[]) alpha.Clone();
@@ -326,7 +326,7 @@ namespace MathNet.Numerics.Distributions
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(alpha))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
var n = alpha.Length;
diff --git a/src/Numerics/Distributions/Erlang.cs b/src/Numerics/Distributions/Erlang.cs
index 08a73223..2dc2381b 100644
--- a/src/Numerics/Distributions/Erlang.cs
+++ b/src/Numerics/Distributions/Erlang.cs
@@ -114,7 +114,7 @@ namespace MathNet.Numerics.Distributions
{
if (shape < 0.0 || rate < 0.0 || Double.IsNaN(shape) || Double.IsNaN(rate))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_shape = shape;
@@ -438,7 +438,7 @@ namespace MathNet.Numerics.Distributions
///
public static double PDF(double shape, double rate, double x)
{
- if (shape < 0.0 || rate < 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (shape < 0.0 || rate < 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
if (Double.IsPositiveInfinity(rate)) return x == shape ? Double.PositiveInfinity : 0.0;
if (shape == 0.0 && rate == 0.0) return 0.0;
@@ -457,7 +457,7 @@ namespace MathNet.Numerics.Distributions
///
public static double PDFLn(double shape, double rate, double x)
{
- if (shape < 0.0 || rate < 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (shape < 0.0 || rate < 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
if (Double.IsPositiveInfinity(rate)) return x == shape ? Double.PositiveInfinity : Double.NegativeInfinity;
if (shape == 0.0 && rate == 0.0) return Double.NegativeInfinity;
@@ -476,7 +476,7 @@ namespace MathNet.Numerics.Distributions
///
public static double CDF(double shape, double rate, double x)
{
- if (shape < 0.0 || rate < 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (shape < 0.0 || rate < 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
if (Double.IsPositiveInfinity(rate)) return x >= shape ? 1.0 : 0.0;
if (shape == 0.0 && rate == 0.0) return 0.0;
@@ -493,7 +493,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public static double Sample(System.Random rnd, double shape, double rate)
{
- if (shape < 0.0 || rate < 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (shape < 0.0 || rate < 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return SampleUnchecked(rnd, shape, rate);
}
@@ -507,7 +507,7 @@ namespace MathNet.Numerics.Distributions
/// a sequence of samples from the distribution.
public static IEnumerable Samples(System.Random rnd, double shape, double rate)
{
- if (shape < 0.0 || rate < 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (shape < 0.0 || rate < 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
while (true)
{
diff --git a/src/Numerics/Distributions/Exponential.cs b/src/Numerics/Distributions/Exponential.cs
index ea560659..56c81872 100644
--- a/src/Numerics/Distributions/Exponential.cs
+++ b/src/Numerics/Distributions/Exponential.cs
@@ -85,7 +85,7 @@ namespace MathNet.Numerics.Distributions
{
if (rate < 0.0 || Double.IsNaN(rate))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_rate = rate;
diff --git a/src/Numerics/Distributions/FisherSnedecor.cs b/src/Numerics/Distributions/FisherSnedecor.cs
index 8b4d2c1b..b990133f 100644
--- a/src/Numerics/Distributions/FisherSnedecor.cs
+++ b/src/Numerics/Distributions/FisherSnedecor.cs
@@ -90,7 +90,7 @@ namespace MathNet.Numerics.Distributions
{
if (d1 <= 0.0 || d2 <= 0.0 || Double.IsNaN(d1) || Double.IsNaN(d2))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_freedom1 = d1;
@@ -317,7 +317,7 @@ namespace MathNet.Numerics.Distributions
///
public static double PDF(double d1, double d2, double x)
{
- if (d1 <= 0.0 || d2 <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (d1 <= 0.0 || d2 <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return Math.Sqrt(Math.Pow(d1*x, d1)*Math.Pow(d2, d2)/Math.Pow((d1*x) + d2, d1 + d2))/(x*SpecialFunctions.Beta(d1/2.0, d2/2.0));
}
@@ -345,7 +345,7 @@ namespace MathNet.Numerics.Distributions
///
public static double CDF(double d1, double d2, double x)
{
- if (d1 <= 0.0 || d2 <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (d1 <= 0.0 || d2 <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return SpecialFunctions.BetaRegularized(d1/2.0, d2/2.0, d1*x/(d1*x + d2));
}
@@ -362,7 +362,7 @@ namespace MathNet.Numerics.Distributions
/// WARNING: currently not an explicit implementation, hence slow and unreliable.
public static double InvCDF(double d1, double d2, double p)
{
- if (d1 <= 0.0 || d2 <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (d1 <= 0.0 || d2 <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return Brent.FindRoot(
x => SpecialFunctions.BetaRegularized(d1/2.0, d2/2.0, d1*x/(d1*x + d2)) - p,
@@ -378,7 +378,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public static double Sample(System.Random rnd, double d1, double d2)
{
- if (d1 <= 0.0 || d2 <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (d1 <= 0.0 || d2 <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return SampleUnchecked(rnd, d1, d2);
}
@@ -392,7 +392,7 @@ namespace MathNet.Numerics.Distributions
/// a sequence of samples from the distribution.
public static IEnumerable Samples(System.Random rnd, double d1, double d2)
{
- if (d1 <= 0.0 || d2 <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (d1 <= 0.0 || d2 <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
while (true)
{
diff --git a/src/Numerics/Distributions/Gamma.cs b/src/Numerics/Distributions/Gamma.cs
index 2e61206f..a01a244c 100644
--- a/src/Numerics/Distributions/Gamma.cs
+++ b/src/Numerics/Distributions/Gamma.cs
@@ -123,7 +123,7 @@ namespace MathNet.Numerics.Distributions
{
if (shape < 0.0 || rate < 0.0 || Double.IsNaN(shape) || Double.IsNaN(rate))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_shape = shape;
@@ -454,7 +454,7 @@ namespace MathNet.Numerics.Distributions
///
public static double PDF(double shape, double rate, double x)
{
- if (shape < 0.0 || rate < 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (shape < 0.0 || rate < 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
if (Double.IsPositiveInfinity(rate)) return x == shape ? Double.PositiveInfinity : 0.0;
if (shape == 0.0 && rate == 0.0) return 0.0;
@@ -473,7 +473,7 @@ namespace MathNet.Numerics.Distributions
///
public static double PDFLn(double shape, double rate, double x)
{
- if (shape < 0.0 || rate < 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (shape < 0.0 || rate < 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
if (Double.IsPositiveInfinity(rate)) return x == shape ? Double.PositiveInfinity : Double.NegativeInfinity;
if (shape == 0.0 && rate == 0.0) return Double.NegativeInfinity;
@@ -492,7 +492,7 @@ namespace MathNet.Numerics.Distributions
///
public static double CDF(double shape, double rate, double x)
{
- if (shape < 0.0 || rate < 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (shape < 0.0 || rate < 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
if (Double.IsPositiveInfinity(rate)) return x >= shape ? 1.0 : 0.0;
if (shape == 0.0 && rate == 0.0) return 0.0;
@@ -511,7 +511,7 @@ namespace MathNet.Numerics.Distributions
///
public static double InvCDF(double shape, double rate, double p)
{
- if (shape < 0.0 || rate < 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (shape < 0.0 || rate < 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return SpecialFunctions.GammaLowerRegularizedInv(shape, p)/rate;
}
@@ -525,7 +525,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public static double Sample(System.Random rnd, double shape, double rate)
{
- if (shape < 0.0 || rate < 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (shape < 0.0 || rate < 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return SampleUnchecked(rnd, shape, rate);
}
@@ -539,7 +539,7 @@ namespace MathNet.Numerics.Distributions
/// a sequence of samples from the distribution.
public static IEnumerable Samples(System.Random rnd, double shape, double rate)
{
- if (shape < 0.0 || rate < 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (shape < 0.0 || rate < 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
while (true)
{
diff --git a/src/Numerics/Distributions/InverseGamma.cs b/src/Numerics/Distributions/InverseGamma.cs
index a3a26f5a..3fe36547 100644
--- a/src/Numerics/Distributions/InverseGamma.cs
+++ b/src/Numerics/Distributions/InverseGamma.cs
@@ -91,7 +91,7 @@ namespace MathNet.Numerics.Distributions
{
if (shape <= 0.0 || scale <= 0.0 || Double.IsNaN(shape) || Double.IsNaN(scale))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_shape = shape;
@@ -283,7 +283,7 @@ namespace MathNet.Numerics.Distributions
///
public static double PDF(double shape, double scale, double x)
{
- if (shape <= 0.0 || scale <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (shape <= 0.0 || scale <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return x < 0.0 ? 0.0 : Math.Pow(scale, shape)*Math.Pow(x, -shape - 1.0)*Math.Exp(-scale/x)/SpecialFunctions.Gamma(shape);
}
@@ -311,7 +311,7 @@ namespace MathNet.Numerics.Distributions
///
public static double CDF(double shape, double scale, double x)
{
- if (shape <= 0.0 || scale <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (shape <= 0.0 || scale <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return SpecialFunctions.GammaUpperRegularized(shape, scale/x);
}
@@ -325,7 +325,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public static double Sample(System.Random rnd, double shape, double scale)
{
- if (shape <= 0.0 || scale <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (shape <= 0.0 || scale <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return 1.0/Gamma.Sample(rnd, shape, scale);
}
@@ -339,7 +339,7 @@ namespace MathNet.Numerics.Distributions
/// a sequence of samples from the distribution.
public static IEnumerable Samples(System.Random rnd, double shape, double scale)
{
- if (shape <= 0.0 || scale <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (shape <= 0.0 || scale <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return Gamma.Samples(rnd, shape, scale).Select(z => 1.0/z);
}
diff --git a/src/Numerics/Distributions/InverseWishart.cs b/src/Numerics/Distributions/InverseWishart.cs
index 5e9142f5..de039e88 100644
--- a/src/Numerics/Distributions/InverseWishart.cs
+++ b/src/Numerics/Distributions/InverseWishart.cs
@@ -120,7 +120,7 @@ namespace MathNet.Numerics.Distributions
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(degreesOfFreedom, scale))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_freedom = degreesOfFreedom;
@@ -247,7 +247,7 @@ namespace MathNet.Numerics.Distributions
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(degreesOfFreedom, scale))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
var r = Wishart.Sample(rnd, degreesOfFreedom, scale.Inverse());
diff --git a/src/Numerics/Distributions/Laplace.cs b/src/Numerics/Distributions/Laplace.cs
index 6666067f..fd8c6327 100644
--- a/src/Numerics/Distributions/Laplace.cs
+++ b/src/Numerics/Distributions/Laplace.cs
@@ -101,7 +101,7 @@ namespace MathNet.Numerics.Distributions
{
if (scale <= 0.0 || Double.IsNaN(location) || Double.IsNaN(scale))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_location = location;
@@ -284,7 +284,7 @@ namespace MathNet.Numerics.Distributions
///
public static double PDF(double location, double scale, double x)
{
- if (scale <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (scale <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return Math.Exp(-Math.Abs(x - location)/scale)/(2.0*scale);
}
@@ -299,7 +299,7 @@ namespace MathNet.Numerics.Distributions
///
public static double PDFLn(double location, double scale, double x)
{
- if (scale <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (scale <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return -Math.Abs(x - location)/scale - Math.Log(2.0*scale);
}
@@ -314,7 +314,7 @@ namespace MathNet.Numerics.Distributions
///
public static double CDF(double location, double scale, double x)
{
- if (scale <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (scale <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return 0.5*(1.0 + (Math.Sign(x - location)*(1.0 - Math.Exp(-Math.Abs(x - location)/scale))));
}
@@ -328,7 +328,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public static double Sample(System.Random rnd, double location, double scale)
{
- if (scale <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (scale <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return SampleUnchecked(rnd, location, scale);
}
@@ -342,7 +342,7 @@ namespace MathNet.Numerics.Distributions
/// a sequence of samples from the distribution.
public static IEnumerable Samples(System.Random rnd, double location, double scale)
{
- if (scale <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (scale <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
while (true)
{
diff --git a/src/Numerics/Distributions/LogNormal.cs b/src/Numerics/Distributions/LogNormal.cs
index 27624e11..e418d593 100644
--- a/src/Numerics/Distributions/LogNormal.cs
+++ b/src/Numerics/Distributions/LogNormal.cs
@@ -133,7 +133,7 @@ namespace MathNet.Numerics.Distributions
{
if (sigma < 0.0 || Double.IsNaN(mu) || Double.IsNaN(sigma))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_mu = mu;
@@ -339,7 +339,7 @@ namespace MathNet.Numerics.Distributions
/// MATLAB: lognpdf
public static double PDF(double mu, double sigma, double x)
{
- if (sigma < 0.0) throw new ArgumentOutOfRangeException("sigma", Resources.InvalidDistributionParameters);
+ if (sigma < 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
if (x < 0.0)
{
@@ -360,7 +360,7 @@ namespace MathNet.Numerics.Distributions
///
public static double PDFLn(double mu, double sigma, double x)
{
- if (sigma < 0.0) throw new ArgumentOutOfRangeException("sigma", Resources.InvalidDistributionParameters);
+ if (sigma < 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
if (x < 0.0)
{
@@ -382,7 +382,7 @@ namespace MathNet.Numerics.Distributions
/// MATLAB: logncdf
public static double CDF(double mu, double sigma, double x)
{
- if (sigma < 0.0) throw new ArgumentOutOfRangeException("sigma", Resources.InvalidDistributionParameters);
+ if (sigma < 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return x < 0.0 ? 0.0
: 0.5*(1.0 + SpecialFunctions.Erf((Math.Log(x) - mu)/(sigma*Constants.Sqrt2)));
@@ -400,7 +400,7 @@ namespace MathNet.Numerics.Distributions
/// MATLAB: logninv
public static double InvCDF(double mu, double sigma, double p)
{
- if (sigma < 0.0) throw new ArgumentOutOfRangeException("sigma", Resources.InvalidDistributionParameters);
+ if (sigma < 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return p <= 0.0 ? 0.0 : p >= 1.0 ? double.PositiveInfinity
: Math.Exp(mu - sigma*Constants.Sqrt2*SpecialFunctions.ErfcInv(2.0*p));
diff --git a/src/Numerics/Distributions/MatrixNormal.cs b/src/Numerics/Distributions/MatrixNormal.cs
index bfaece86..d0875e1e 100644
--- a/src/Numerics/Distributions/MatrixNormal.cs
+++ b/src/Numerics/Distributions/MatrixNormal.cs
@@ -150,7 +150,7 @@ namespace MathNet.Numerics.Distributions
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(m, v, k))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_m = m;
@@ -242,7 +242,7 @@ namespace MathNet.Numerics.Distributions
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(m, v, k))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
var n = m.RowCount;
diff --git a/src/Numerics/Distributions/Multinomial.cs b/src/Numerics/Distributions/Multinomial.cs
index 606ae4da..c599e0da 100644
--- a/src/Numerics/Distributions/Multinomial.cs
+++ b/src/Numerics/Distributions/Multinomial.cs
@@ -168,7 +168,7 @@ namespace MathNet.Numerics.Distributions
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(p, n))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_p = (double[]) p.Clone();
@@ -342,7 +342,7 @@ namespace MathNet.Numerics.Distributions
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(p, n))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
// The cumulative density of p.
@@ -371,7 +371,7 @@ namespace MathNet.Numerics.Distributions
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(p, n))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
// The cumulative density of p.
diff --git a/src/Numerics/Distributions/Normal.cs b/src/Numerics/Distributions/Normal.cs
index 9e20fb7a..ca47d3bf 100644
--- a/src/Numerics/Distributions/Normal.cs
+++ b/src/Numerics/Distributions/Normal.cs
@@ -162,7 +162,7 @@ namespace MathNet.Numerics.Distributions
{
if (stddev < 0.0 || Double.IsNaN(mean) || Double.IsNaN(stddev))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_mean = mean;
@@ -373,7 +373,7 @@ namespace MathNet.Numerics.Distributions
/// MATLAB: normpdf
public static double PDF(double mean, double stddev, double x)
{
- if (stddev < 0.0) throw new ArgumentOutOfRangeException("stddev", Resources.InvalidDistributionParameters);
+ if (stddev < 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
var d = (x - mean)/stddev;
return Math.Exp(-0.5*d*d)/(Constants.Sqrt2Pi*stddev);
@@ -389,7 +389,7 @@ namespace MathNet.Numerics.Distributions
///
public static double PDFLn(double mean, double stddev, double x)
{
- if (stddev < 0.0) throw new ArgumentOutOfRangeException("stddev", Resources.InvalidDistributionParameters);
+ if (stddev < 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
var d = (x - mean)/stddev;
return (-0.5*d*d) - Math.Log(stddev) - Constants.LogSqrt2Pi;
@@ -406,7 +406,7 @@ namespace MathNet.Numerics.Distributions
/// MATLAB: normcdf
public static double CDF(double mean, double stddev, double x)
{
- if (stddev < 0.0) throw new ArgumentOutOfRangeException("stddev", Resources.InvalidDistributionParameters);
+ if (stddev < 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return 0.5*(1.0 + SpecialFunctions.Erf((x - mean)/(stddev*Constants.Sqrt2)));
}
@@ -423,7 +423,7 @@ namespace MathNet.Numerics.Distributions
/// MATLAB: norminv
public static double InvCDF(double mean, double stddev, double p)
{
- if (stddev < 0.0) throw new ArgumentOutOfRangeException("stddev", Resources.InvalidDistributionParameters);
+ if (stddev < 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return mean - (stddev*Constants.Sqrt2*SpecialFunctions.ErfcInv(2.0*p));
}
@@ -437,7 +437,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public static double Sample(System.Random rnd, double mean, double stddev)
{
- if (stddev < 0.0) throw new ArgumentOutOfRangeException("stddev", Resources.InvalidDistributionParameters);
+ if (stddev < 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return mean + (stddev*SampleStandardBoxMuller(rnd).Item1);
}
@@ -451,7 +451,7 @@ namespace MathNet.Numerics.Distributions
/// a sequence of samples from the distribution.
public static IEnumerable Samples(System.Random rnd, double mean, double stddev)
{
- if (stddev < 0.0) throw new ArgumentOutOfRangeException("stddev", Resources.InvalidDistributionParameters);
+ if (stddev < 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
while (true)
{
diff --git a/src/Numerics/Distributions/NormalGamma.cs b/src/Numerics/Distributions/NormalGamma.cs
index 213f744f..0f761a0c 100644
--- a/src/Numerics/Distributions/NormalGamma.cs
+++ b/src/Numerics/Distributions/NormalGamma.cs
@@ -167,7 +167,7 @@ namespace MathNet.Numerics.Distributions
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(meanLocation, meanScale, precShape, precInvScale))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_meanLocation = meanLocation;
@@ -375,7 +375,7 @@ namespace MathNet.Numerics.Distributions
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(meanLocation, meanScale, precisionShape, precisionInverseScale))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
var mp = new MeanPrecisionPair();
@@ -402,7 +402,7 @@ namespace MathNet.Numerics.Distributions
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(meanLocation, meanScale, precisionShape, precisionInvScale))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
while (true)
diff --git a/src/Numerics/Distributions/Pareto.cs b/src/Numerics/Distributions/Pareto.cs
index f0061eb5..ba962f8b 100644
--- a/src/Numerics/Distributions/Pareto.cs
+++ b/src/Numerics/Distributions/Pareto.cs
@@ -93,7 +93,7 @@ namespace MathNet.Numerics.Distributions
{
if (scale <= 0.0 || shape <= 0.0 || Double.IsNaN(scale) || Double.IsNaN(shape))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_scale = scale;
@@ -292,7 +292,7 @@ namespace MathNet.Numerics.Distributions
///
public static double PDF(double scale, double shape, double x)
{
- if (scale <= 0.0 || shape <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (scale <= 0.0 || shape <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return shape*Math.Pow(scale, shape)/Math.Pow(x, shape + 1.0);
}
@@ -307,7 +307,7 @@ namespace MathNet.Numerics.Distributions
///
public static double PDFLn(double scale, double shape, double x)
{
- if (scale <= 0.0 || shape <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (scale <= 0.0 || shape <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return Math.Log(shape) + shape*Math.Log(scale) - (shape + 1.0)*Math.Log(x);
}
@@ -322,7 +322,7 @@ namespace MathNet.Numerics.Distributions
///
public static double CDF(double scale, double shape, double x)
{
- if (scale <= 0.0 || shape <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (scale <= 0.0 || shape <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return 1.0 - Math.Pow(scale/x, shape);
}
@@ -338,7 +338,7 @@ namespace MathNet.Numerics.Distributions
///
public static double InvCDF(double scale, double shape, double p)
{
- if (scale <= 0.0 || shape <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (scale <= 0.0 || shape <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return scale*Math.Pow(1.0 - p, -1.0/shape);
}
@@ -352,7 +352,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public static double Sample(System.Random rnd, double scale, double shape)
{
- if (scale <= 0.0 || shape <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (scale <= 0.0 || shape <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return scale*Math.Pow(rnd.NextDouble(), -1.0/shape);
}
@@ -366,7 +366,7 @@ namespace MathNet.Numerics.Distributions
/// a sequence of samples from the distribution.
public static IEnumerable Samples(System.Random rnd, double scale, double shape)
{
- if (scale <= 0.0 || shape <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (scale <= 0.0 || shape <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
var power = -1.0 / shape;
while (true)
diff --git a/src/Numerics/Distributions/Rayleigh.cs b/src/Numerics/Distributions/Rayleigh.cs
index 6685996f..400dbc9d 100644
--- a/src/Numerics/Distributions/Rayleigh.cs
+++ b/src/Numerics/Distributions/Rayleigh.cs
@@ -90,7 +90,7 @@ namespace MathNet.Numerics.Distributions
{
if (scale <= 0.0 || Double.IsNaN(scale))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_scale = scale;
diff --git a/src/Numerics/Distributions/Stable.cs b/src/Numerics/Distributions/Stable.cs
index 8ab0f718..b7fe5567 100644
--- a/src/Numerics/Distributions/Stable.cs
+++ b/src/Numerics/Distributions/Stable.cs
@@ -101,7 +101,7 @@ namespace MathNet.Numerics.Distributions
if (alpha <= 0.0 || alpha > 2.0 || beta < -1.0 || beta > 1.0 || scale <= 0.0
|| Double.IsNaN(alpha) || Double.IsNaN(beta) || Double.IsNaN(scale) || Double.IsNaN(location))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_alpha = alpha;
@@ -388,7 +388,7 @@ namespace MathNet.Numerics.Distributions
public static double PDF(double alpha, double beta, double scale, double location, double x)
{
if (alpha <= 0.0 || alpha > 2.0 || beta < -1.0 || beta > 1.0 || scale <= 0.0)
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
if (alpha == 2d) return Normal.PDF(location, Constants.Sqrt2*scale, x);
if (alpha == 1d && beta == 0d) return Cauchy.PDF(location, scale, x);
@@ -414,7 +414,7 @@ namespace MathNet.Numerics.Distributions
public static double PDFLn(double alpha, double beta, double scale, double location, double x)
{
if (alpha <= 0.0 || alpha > 2.0 || beta < -1.0 || beta > 1.0 || scale <= 0.0)
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
if (alpha == 2d) return Normal.PDFLn(location, Constants.Sqrt2*scale, x);
if (alpha == 1d && beta == 0d) return Cauchy.PDFLn(location, scale, x);
@@ -440,7 +440,7 @@ namespace MathNet.Numerics.Distributions
public static double CDF(double alpha, double beta, double scale, double location, double x)
{
if (alpha <= 0.0 || alpha > 2.0 || beta < -1.0 || beta > 1.0 || scale <= 0.0)
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
if (alpha == 2d) return Normal.CDF(location, Constants.Sqrt2*scale, x);
if (alpha == 1d && beta == 0d) return Cauchy.CDF(location, scale, x);
@@ -465,7 +465,7 @@ namespace MathNet.Numerics.Distributions
public static double Sample(System.Random rnd, double alpha, double beta, double scale, double location)
{
if (alpha <= 0.0 || alpha > 2.0 || beta < -1.0 || beta > 1.0 || scale <= 0.0)
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
return SampleUnchecked(rnd, alpha, beta, scale, location);
}
@@ -482,7 +482,7 @@ namespace MathNet.Numerics.Distributions
public static IEnumerable Samples(System.Random rnd, double alpha, double beta, double scale, double location)
{
if (alpha <= 0.0 || alpha > 2.0 || beta < -1.0 || beta > 1.0 || scale <= 0.0)
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
while (true)
{
diff --git a/src/Numerics/Distributions/StudentT.cs b/src/Numerics/Distributions/StudentT.cs
index 73785dd9..92a26619 100644
--- a/src/Numerics/Distributions/StudentT.cs
+++ b/src/Numerics/Distributions/StudentT.cs
@@ -122,7 +122,7 @@ namespace MathNet.Numerics.Distributions
{
if (scale <= 0.0 || freedom <= 0.0 || Double.IsNaN(scale) || Double.IsNaN(location) || Double.IsNaN(freedom))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_location = location;
@@ -366,7 +366,7 @@ namespace MathNet.Numerics.Distributions
///
public static double PDF(double location, double scale, double freedom, double x)
{
- if (scale <= 0.0 || freedom <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (scale <= 0.0 || freedom <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
// TODO JVG we can probably do a better job for Cauchy special case
if (freedom >= 1e+8d) return Normal.PDF(location, scale, x);
@@ -389,7 +389,7 @@ namespace MathNet.Numerics.Distributions
///
public static double PDFLn(double location, double scale, double freedom, double x)
{
- if (scale <= 0.0 || freedom <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (scale <= 0.0 || freedom <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
// TODO JVG we can probably do a better job for Cauchy special case
if (freedom >= 1e+8d) return Normal.PDFLn(location, scale, x);
@@ -412,7 +412,7 @@ namespace MathNet.Numerics.Distributions
///
public static double CDF(double location, double scale, double freedom, double x)
{
- if (scale <= 0.0 || freedom <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (scale <= 0.0 || freedom <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
// TODO JVG we can probably do a better job for Cauchy special case
if (Double.IsPositiveInfinity(freedom)) return Normal.CDF(location, scale, x);
@@ -436,7 +436,7 @@ namespace MathNet.Numerics.Distributions
/// WARNING: currently not an explicit implementation, hence slow and unreliable.
public static double InvCDF(double location, double scale, double freedom, double p)
{
- if (scale <= 0.0 || freedom <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (scale <= 0.0 || freedom <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
// TODO JVG we can probably do a better job for Cauchy special case
if (Double.IsPositiveInfinity(freedom)) return Normal.InvCDF(location, scale, p);
@@ -462,7 +462,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public static double Sample(System.Random rnd, double location, double scale, double freedom)
{
- if (scale <= 0.0 || freedom <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (scale <= 0.0 || freedom <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return SampleUnchecked(rnd, location, scale, freedom);
}
@@ -477,7 +477,7 @@ namespace MathNet.Numerics.Distributions
/// a sequence of samples from the distribution.
public static IEnumerable Samples(System.Random rnd, double location, double scale, double freedom)
{
- if (scale <= 0.0 || freedom <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (scale <= 0.0 || freedom <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
while (true)
{
diff --git a/src/Numerics/Distributions/Triangular.cs b/src/Numerics/Distributions/Triangular.cs
index 011a8885..dcfd8061 100644
--- a/src/Numerics/Distributions/Triangular.cs
+++ b/src/Numerics/Distributions/Triangular.cs
@@ -98,7 +98,7 @@ namespace MathNet.Numerics.Distributions
{
if (upper < mode || mode < lower || Double.IsNaN(upper) || Double.IsNaN(lower) || Double.IsNaN(mode))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_lower = lower;
diff --git a/src/Numerics/Distributions/Weibull.cs b/src/Numerics/Distributions/Weibull.cs
index 89ce3908..88fa065b 100644
--- a/src/Numerics/Distributions/Weibull.cs
+++ b/src/Numerics/Distributions/Weibull.cs
@@ -101,7 +101,7 @@ namespace MathNet.Numerics.Distributions
{
if (shape <= 0.0 || scale <= 0.0 || Double.IsNaN(shape) || Double.IsNaN(scale))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_shape = shape;
@@ -320,7 +320,7 @@ namespace MathNet.Numerics.Distributions
///
public static double PDF(double shape, double scale, double x)
{
- if (shape <= 0.0 || scale <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (shape <= 0.0 || scale <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
if (x >= 0.0)
{
@@ -348,7 +348,7 @@ namespace MathNet.Numerics.Distributions
///
public static double PDFLn(double shape, double scale, double x)
{
- if (shape <= 0.0 || scale <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (shape <= 0.0 || scale <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
if (x >= 0.0)
{
@@ -376,7 +376,7 @@ namespace MathNet.Numerics.Distributions
///
public static double CDF(double shape, double scale, double x)
{
- if (shape <= 0.0 || scale <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (shape <= 0.0 || scale <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
if (x < 0.0) return 0.0;
@@ -392,7 +392,7 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public static double Sample(System.Random rnd, double shape, double scale)
{
- if (shape <= 0.0 || scale <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (shape <= 0.0 || scale <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
return SampleUnchecked(rnd, shape, scale);
}
@@ -406,7 +406,7 @@ namespace MathNet.Numerics.Distributions
/// a sequence of samples from the distribution.
public static IEnumerable Samples(System.Random rnd, double shape, double scale)
{
- if (shape <= 0.0 || scale <= 0.0) throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ if (shape <= 0.0 || scale <= 0.0) throw new ArgumentException(Resources.InvalidDistributionParameters);
while (true)
{
diff --git a/src/Numerics/Distributions/Wishart.cs b/src/Numerics/Distributions/Wishart.cs
index 9714262d..799f7690 100644
--- a/src/Numerics/Distributions/Wishart.cs
+++ b/src/Numerics/Distributions/Wishart.cs
@@ -96,7 +96,7 @@ namespace MathNet.Numerics.Distributions
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(degreesOfFreedom, scale))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
_degreesOfFreedom = degreesOfFreedom;
@@ -258,7 +258,7 @@ namespace MathNet.Numerics.Distributions
{
if (Control.CheckDistributionParameters && !IsValidParameterSet(degreesOfFreedom, scale))
{
- throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ throw new ArgumentException(Resources.InvalidDistributionParameters);
}
return DoSample(rnd, degreesOfFreedom, scale, scale.Cholesky());
diff --git a/src/Numerics/LinearAlgebra/Storage/MatrixStorage.cs b/src/Numerics/LinearAlgebra/Storage/MatrixStorage.cs
index 724d8e8c..d3d4fab9 100644
--- a/src/Numerics/LinearAlgebra/Storage/MatrixStorage.cs
+++ b/src/Numerics/LinearAlgebra/Storage/MatrixStorage.cs
@@ -48,12 +48,12 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
{
if (rowCount <= 0)
{
- throw new ArgumentOutOfRangeException(Resources.MatrixRowsMustBePositive);
+ throw new ArgumentOutOfRangeException("rowCount", Resources.MatrixRowsMustBePositive);
}
if (columnCount <= 0)
{
- throw new ArgumentOutOfRangeException(Resources.MatrixColumnsMustBePositive);
+ throw new ArgumentOutOfRangeException("columnCount", Resources.MatrixColumnsMustBePositive);
}
RowCount = rowCount;
diff --git a/src/Numerics/LinearAlgebra/Storage/SparseCompressedRowMatrixStorage.cs b/src/Numerics/LinearAlgebra/Storage/SparseCompressedRowMatrixStorage.cs
index 29474aef..6d45c9e7 100644
--- a/src/Numerics/LinearAlgebra/Storage/SparseCompressedRowMatrixStorage.cs
+++ b/src/Numerics/LinearAlgebra/Storage/SparseCompressedRowMatrixStorage.cs
@@ -750,7 +750,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
{
if (rows*columns != data.Count)
{
- throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixDimensions);
+ throw new ArgumentException(Resources.ArgumentMatrixDimensions);
}
var storage = new SparseCompressedRowMatrixStorage(rows, columns);
diff --git a/src/Numerics/LinearAlgebra/Storage/VectorStorage.cs b/src/Numerics/LinearAlgebra/Storage/VectorStorage.cs
index d096dc2c..b1bbccb3 100644
--- a/src/Numerics/LinearAlgebra/Storage/VectorStorage.cs
+++ b/src/Numerics/LinearAlgebra/Storage/VectorStorage.cs
@@ -47,7 +47,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
{
if (length <= 0)
{
- throw new ArgumentOutOfRangeException(Resources.ArgumentMustBePositive);
+ throw new ArgumentOutOfRangeException("length", Resources.ArgumentMustBePositive);
}
Length = length;
diff --git a/src/Numerics/Random/RandomSource.cs b/src/Numerics/Random/RandomSource.cs
index 3f614ac1..d0af5ee1 100644
--- a/src/Numerics/Random/RandomSource.cs
+++ b/src/Numerics/Random/RandomSource.cs
@@ -140,7 +140,7 @@ namespace MathNet.Numerics.Random
{
if (maxValue <= 0)
{
- throw new ArgumentOutOfRangeException(Resources.ArgumentMustBePositive);
+ throw new ArgumentException(Resources.ArgumentMustBePositive);
}
if (_threadSafe)
@@ -167,7 +167,7 @@ namespace MathNet.Numerics.Random
{
if (minValue > maxValue)
{
- throw new ArgumentOutOfRangeException(Resources.ArgumentMinValueGreaterThanMaxValue);
+ throw new ArgumentException(Resources.ArgumentMinValueGreaterThanMaxValue);
}
if (_threadSafe)
diff --git a/src/Numerics/SpecialFunctions/Logistic.cs b/src/Numerics/SpecialFunctions/Logistic.cs
index aae6ae6e..0149c818 100644
--- a/src/Numerics/SpecialFunctions/Logistic.cs
+++ b/src/Numerics/SpecialFunctions/Logistic.cs
@@ -65,7 +65,7 @@ namespace MathNet.Numerics
{
if (p < 0.0 || p > 1.0)
{
- throw new ArgumentOutOfRangeException(Resources.ArgumentBetween0And1);
+ throw new ArgumentOutOfRangeException("p", Resources.ArgumentBetween0And1);
}
return Math.Log(p / (1.0 - p));
diff --git a/src/Numerics/Statistics/Histogram.cs b/src/Numerics/Statistics/Histogram.cs
index 33bbb183..2bd44058 100644
--- a/src/Numerics/Statistics/Histogram.cs
+++ b/src/Numerics/Statistics/Histogram.cs
@@ -90,12 +90,12 @@ namespace MathNet.Numerics.Statistics
{
if (lowerBound > upperBound)
{
- throw new ArgumentOutOfRangeException(Resources.ArgumentLowerBoundLargerThanUpperBound);
+ throw new ArgumentException(Resources.ArgumentLowerBoundLargerThanUpperBound);
}
if (count < 0.0)
{
- throw new ArgumentOutOfRangeException(Resources.ArgumentMustBePositive);
+ throw new ArgumentOutOfRangeException("count", Resources.ArgumentMustBePositive);
}
LowerBound = lowerBound;
diff --git a/src/Numerics/Statistics/MCMC/HybridMCGeneric.cs b/src/Numerics/Statistics/MCMC/HybridMCGeneric.cs
index ef184ec8..e97f864f 100644
--- a/src/Numerics/Statistics/MCMC/HybridMCGeneric.cs
+++ b/src/Numerics/Statistics/MCMC/HybridMCGeneric.cs
@@ -283,7 +283,7 @@ namespace MathNet.Numerics.Statistics.Mcmc
{
if (value < 0)
{
- throw new ArgumentOutOfRangeException(Resources.ArgumentNotNegative);
+ throw new ArgumentOutOfRangeException("value", Resources.ArgumentNotNegative);
}
return value;
}
@@ -298,7 +298,7 @@ namespace MathNet.Numerics.Statistics.Mcmc
{
if (value <= 0)
{
- throw new ArgumentOutOfRangeException(Resources.ArgumentNotNegative);
+ throw new ArgumentOutOfRangeException("value", Resources.ArgumentNotNegative);
}
return value;
}
@@ -313,7 +313,7 @@ namespace MathNet.Numerics.Statistics.Mcmc
{
if (value <= 0)
{
- throw new ArgumentOutOfRangeException(Resources.ArgumentNotNegative);
+ throw new ArgumentOutOfRangeException("value", Resources.ArgumentNotNegative);
}
return value;
}
diff --git a/src/Numerics/Statistics/MCMC/MetropolisHastingsSampler.cs b/src/Numerics/Statistics/MCMC/MetropolisHastingsSampler.cs
index 3c848d70..a889019c 100644
--- a/src/Numerics/Statistics/MCMC/MetropolisHastingsSampler.cs
+++ b/src/Numerics/Statistics/MCMC/MetropolisHastingsSampler.cs
@@ -109,7 +109,7 @@ namespace MathNet.Numerics.Statistics.Mcmc
{
if (value < 0)
{
- throw new ArgumentOutOfRangeException(Resources.ArgumentNotNegative);
+ throw new ArgumentException(Resources.ArgumentNotNegative);
}
_burnInterval = value;
}
diff --git a/src/Numerics/Statistics/MCMC/MetropolisSampler.cs b/src/Numerics/Statistics/MCMC/MetropolisSampler.cs
index d42747e9..211ad5fd 100644
--- a/src/Numerics/Statistics/MCMC/MetropolisSampler.cs
+++ b/src/Numerics/Statistics/MCMC/MetropolisSampler.cs
@@ -100,7 +100,7 @@ namespace MathNet.Numerics.Statistics.Mcmc
{
if (value < 0)
{
- throw new ArgumentOutOfRangeException(Resources.ArgumentNotNegative);
+ throw new ArgumentException(Resources.ArgumentNotNegative);
}
_burnInterval = value;
}
diff --git a/src/Numerics/Statistics/MCMC/RejectionSampler.cs b/src/Numerics/Statistics/MCMC/RejectionSampler.cs
index 44ee3f09..66c4a362 100644
--- a/src/Numerics/Statistics/MCMC/RejectionSampler.cs
+++ b/src/Numerics/Statistics/MCMC/RejectionSampler.cs
@@ -91,7 +91,7 @@ namespace MathNet.Numerics.Statistics.Mcmc
if (q < p)
{
- throw new ArgumentOutOfRangeException(Resources.ProposalDistributionNoUpperBound);
+ throw new ArgumentException(Resources.ProposalDistributionNoUpperBound);
}
if (u < p)
{
diff --git a/src/Numerics/Statistics/MCMC/UnivariateSliceSampler.cs b/src/Numerics/Statistics/MCMC/UnivariateSliceSampler.cs
index 26176ae9..b488ebf8 100644
--- a/src/Numerics/Statistics/MCMC/UnivariateSliceSampler.cs
+++ b/src/Numerics/Statistics/MCMC/UnivariateSliceSampler.cs
@@ -112,7 +112,7 @@ namespace MathNet.Numerics.Statistics.Mcmc
{
if (value < 0)
{
- throw new ArgumentOutOfRangeException(Resources.ArgumentNotNegative);
+ throw new ArgumentException(Resources.ArgumentNotNegative);
}
_burnInterval = value;
}
@@ -128,7 +128,7 @@ namespace MathNet.Numerics.Statistics.Mcmc
{
if (value <= 0.0)
{
- throw new ArgumentOutOfRangeException(Resources.ArgumentPositive);
+ throw new ArgumentException(Resources.ArgumentPositive);
}
_scale = value;
}
diff --git a/src/UnitTests/DistributionTests/Continuous/BetaTests.cs b/src/UnitTests/DistributionTests/Continuous/BetaTests.cs
index 63f4fb70..e204cfdf 100644
--- a/src/UnitTests/DistributionTests/Continuous/BetaTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/BetaTests.cs
@@ -71,12 +71,12 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void BetaCreateFailsWithBadParameters()
{
- Assert.That(() => new Beta(Double.NaN, 1.0), Throws.TypeOf());
- Assert.That(() => new Beta(1.0, Double.NaN), Throws.TypeOf());
- Assert.That(() => new Beta(Double.NaN, Double.NaN), Throws.TypeOf());
- Assert.That(() => new Beta(1.0, -1.0), Throws.TypeOf());
- Assert.That(() => new Beta(-1.0, 1.0), Throws.TypeOf());
- Assert.That(() => new Beta(-1.0, -1.0), Throws.TypeOf());
+ Assert.That(() => new Beta(Double.NaN, 1.0), Throws.ArgumentException);
+ Assert.That(() => new Beta(1.0, Double.NaN), Throws.ArgumentException);
+ Assert.That(() => new Beta(Double.NaN, Double.NaN), Throws.ArgumentException);
+ Assert.That(() => new Beta(1.0, -1.0), Throws.ArgumentException);
+ Assert.That(() => new Beta(-1.0, 1.0), Throws.ArgumentException);
+ Assert.That(() => new Beta(-1.0, -1.0), Throws.ArgumentException);
}
///
@@ -114,7 +114,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetShapeAFailsWithNegativeA()
{
var n = new Beta(1.0, 1.0);
- Assert.That(() => n.A = -1.0, Throws.TypeOf());
+ Assert.That(() => n.A = -1.0, Throws.ArgumentException);
}
///
@@ -142,7 +142,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetShapeBFailsWithNegativeB()
{
var n = new Beta(1.0, 1.0);
- Assert.That(() => n.B = -1.0, Throws.TypeOf());
+ Assert.That(() => n.B = -1.0, Throws.ArgumentException);
}
///
@@ -288,7 +288,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void FailSampleStatic()
{
- Assert.That(() => Beta.Sample(new Random(0), 1.0, -1.0), Throws.TypeOf());
+ Assert.That(() => Beta.Sample(new Random(0), 1.0, -1.0), Throws.ArgumentException);
}
///
@@ -297,7 +297,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void FailSampleSequenceStatic()
{
- Assert.That(() => Beta.Samples(new Random(0), 1.0, -1.0).First(), Throws.TypeOf());
+ Assert.That(() => Beta.Samples(new Random(0), 1.0, -1.0).First(), Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Continuous/CauchyTests.cs b/src/UnitTests/DistributionTests/Continuous/CauchyTests.cs
index 198fab6c..8f070cc2 100644
--- a/src/UnitTests/DistributionTests/Continuous/CauchyTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/CauchyTests.cs
@@ -81,7 +81,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(1.0, 0.0)]
public void CauchyCreateFailsWithBadParameters(double location, double scale)
{
- Assert.That(() => new Cauchy(location, scale), Throws.TypeOf());
+ Assert.That(() => new Cauchy(location, scale), Throws.ArgumentException);
}
///
@@ -118,7 +118,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetBadLocationFail()
{
var n = new Cauchy();
- Assert.That(() => n.Location = Double.NaN, Throws.TypeOf());
+ Assert.That(() => n.Location = Double.NaN, Throws.ArgumentException);
}
///
@@ -143,7 +143,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetBadScaleFail()
{
var n = new Cauchy();
- Assert.That(() => n.Scale = -1.0, Throws.TypeOf());
+ Assert.That(() => n.Scale = -1.0, Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Continuous/ChiSquareTests.cs b/src/UnitTests/DistributionTests/Continuous/ChiSquareTests.cs
index e661d227..7b32c286 100644
--- a/src/UnitTests/DistributionTests/Continuous/ChiSquareTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/ChiSquareTests.cs
@@ -67,7 +67,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(Double.NaN)]
public void ChiSquareCreateFailsWithBadParameters(double dof)
{
- Assert.That(() => new ChiSquared(dof), Throws.TypeOf());
+ Assert.That(() => new ChiSquared(dof), Throws.ArgumentException);
}
///
@@ -106,7 +106,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetDofFailsWithNonPositiveDoF(double dof)
{
var n = new ChiSquared(1.0);
- Assert.That(() => n.DegreesOfFreedom = dof, Throws.TypeOf());
+ Assert.That(() => n.DegreesOfFreedom = dof, Throws.ArgumentException);
}
///
@@ -293,7 +293,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void FailSampleStatic()
{
- Assert.That(() => ChiSquared.Sample(new Random(0), -1.0), Throws.TypeOf());
+ Assert.That(() => ChiSquared.Sample(new Random(0), -1.0), Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Continuous/ChiTests.cs b/src/UnitTests/DistributionTests/Continuous/ChiTests.cs
index 31c0c38b..6324a5f8 100644
--- a/src/UnitTests/DistributionTests/Continuous/ChiTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/ChiTests.cs
@@ -65,7 +65,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(Double.NaN)]
public void ChiCreateFailsWithBadParameters(double dof)
{
- Assert.That(() => new Chi(dof), Throws.TypeOf());
+ Assert.That(() => new Chi(dof), Throws.ArgumentException);
}
///
@@ -104,7 +104,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetDofFailsWithNonPositiveDoF(double dof)
{
var n = new Chi(1.0);
- Assert.That(() => n.DegreesOfFreedom = dof, Throws.TypeOf());
+ Assert.That(() => n.DegreesOfFreedom = dof, Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Continuous/ContinuousUniformTests.cs b/src/UnitTests/DistributionTests/Continuous/ContinuousUniformTests.cs
index 394fb48b..4cfad897 100644
--- a/src/UnitTests/DistributionTests/Continuous/ContinuousUniformTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/ContinuousUniformTests.cs
@@ -84,7 +84,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(1.0, 0.0)]
public void ContinuousUniformCreateFailsWithBadParameters(double lower, double upper)
{
- Assert.That(() => new ContinuousUniform(lower, upper), Throws.TypeOf());
+ Assert.That(() => new ContinuousUniform(lower, upper), Throws.ArgumentException);
}
///
@@ -121,7 +121,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetBadLowerFails()
{
var n = new ContinuousUniform();
- Assert.That(() => n.LowerBound = 3.0, Throws.TypeOf());
+ Assert.That(() => n.LowerBound = 3.0, Throws.ArgumentException);
}
///
@@ -146,7 +146,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetBadUpperFails()
{
var n = new ContinuousUniform();
- Assert.That(() => n.UpperBound = -1.0, Throws.TypeOf());
+ Assert.That(() => n.UpperBound = -1.0, Throws.ArgumentException);
}
///
@@ -336,7 +336,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void FailSampleStatic()
{
- Assert.That(() => ContinuousUniform.Sample(new Random(0), 0.0, -1.0), Throws.TypeOf());
+ Assert.That(() => ContinuousUniform.Sample(new Random(0), 0.0, -1.0), Throws.ArgumentException);
}
///
@@ -345,7 +345,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void FailSampleSequenceStatic()
{
- Assert.That(() => ContinuousUniform.Samples(new Random(0), 0.0, -1.0).First(), Throws.TypeOf());
+ Assert.That(() => ContinuousUniform.Samples(new Random(0), 0.0, -1.0).First(), Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Continuous/ErlangTests.cs b/src/UnitTests/DistributionTests/Continuous/ErlangTests.cs
index 08f6f71f..b0db58ce 100644
--- a/src/UnitTests/DistributionTests/Continuous/ErlangTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/ErlangTests.cs
@@ -71,7 +71,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(-1, Double.NaN)]
public void ErlangCreateFailsWithBadParameters(int shape, double invScale)
{
- Assert.That(() => new Erlang(shape, invScale), Throws.TypeOf());
+ Assert.That(() => new Erlang(shape, invScale), Throws.ArgumentException);
}
///
@@ -143,7 +143,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetShapeFailsWithNegativeShape()
{
var n = new Erlang(1, 1.0);
- Assert.That(() => n.Shape = -1, Throws.TypeOf());
+ Assert.That(() => n.Shape = -1, Throws.ArgumentException);
}
///
@@ -171,7 +171,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetScaleFailsWithNegativeScale()
{
var n = new Erlang(1, 1.0);
- Assert.That(() => n.Scale = -1.0, Throws.TypeOf());
+ Assert.That(() => n.Scale = -1.0, Throws.ArgumentException);
}
///
@@ -199,7 +199,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetInvScaleFailsWithNegativeInvScale()
{
var n = new Erlang(1, 1.0);
- Assert.That(() => n.Rate = -1.0, Throws.TypeOf());
+ Assert.That(() => n.Rate = -1.0, Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Continuous/ExponentialTests.cs b/src/UnitTests/DistributionTests/Continuous/ExponentialTests.cs
index e32ed0c8..a2ca8f55 100644
--- a/src/UnitTests/DistributionTests/Continuous/ExponentialTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/ExponentialTests.cs
@@ -65,7 +65,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(-10.0)]
public void ExponentialCreateFailsWithBadParameters(double lambda)
{
- Assert.That(() => new Exponential(lambda), Throws.TypeOf());
+ Assert.That(() => new Exponential(lambda), Throws.ArgumentException);
}
///
@@ -103,7 +103,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetLambdaFailsWithNegativeLambda()
{
var n = new Exponential(1.0);
- Assert.That(() => n.Rate = -1.0, Throws.TypeOf());
+ Assert.That(() => n.Rate = -1.0, Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Continuous/FisherSnedecorTests.cs b/src/UnitTests/DistributionTests/Continuous/FisherSnedecorTests.cs
index 902cc969..32444971 100644
--- a/src/UnitTests/DistributionTests/Continuous/FisherSnedecorTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/FisherSnedecorTests.cs
@@ -88,7 +88,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(-10.0, -10.0)]
public void FisherSnedecorCreateFailsWithBadParameters(double d1, double d2)
{
- Assert.That(() => new FisherSnedecor(d1, d2), Throws.TypeOf());
+ Assert.That(() => new FisherSnedecor(d1, d2), Throws.ArgumentException);
}
///
@@ -124,7 +124,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetDegreesOfFreedom1FailsWithNegativeDegreeOfFreedom()
{
var n = new FisherSnedecor(1.0, 2.0);
- Assert.That(() => n.DegreesOfFreedom1 = -1.0, Throws.TypeOf());
+ Assert.That(() => n.DegreesOfFreedom1 = -1.0, Throws.ArgumentException);
}
///
@@ -150,7 +150,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetDegreesOfFreedom2FailsWithNegativeDegreeOfFreedom()
{
var n = new FisherSnedecor(1.0, 2.0);
- Assert.That(() => n.DegreesOfFreedom2 = -1.0, Throws.TypeOf());
+ Assert.That(() => n.DegreesOfFreedom2 = -1.0, Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Continuous/GammaTests.cs b/src/UnitTests/DistributionTests/Continuous/GammaTests.cs
index 19beaea3..4565bc17 100644
--- a/src/UnitTests/DistributionTests/Continuous/GammaTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/GammaTests.cs
@@ -73,7 +73,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(-1.0, Double.NaN)]
public void GammaCreateFailsWithBadParameters(double shape, double invScale)
{
- Assert.That(() => new Gamma(shape, invScale), Throws.TypeOf());
+ Assert.That(() => new Gamma(shape, invScale), Throws.ArgumentException);
}
///
@@ -147,7 +147,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetShapeFailsWithNegativeShape()
{
var n = new Gamma(1.0, 1.0);
- Assert.That(() => n.Shape = -1.0, Throws.TypeOf());
+ Assert.That(() => n.Shape = -1.0, Throws.ArgumentException);
}
///
@@ -175,7 +175,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetScaleFailsWithNegativeScale()
{
var n = new Gamma(1.0, 1.0);
- Assert.That(() => n.Scale = -1.0, Throws.TypeOf());
+ Assert.That(() => n.Scale = -1.0, Throws.ArgumentException);
}
///
@@ -203,7 +203,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetInvScaleFailsWithNegativeInvScale()
{
var n = new Gamma(1.0, 1.0);
- Assert.That(() => n.Rate = -1.0, Throws.TypeOf());
+ Assert.That(() => n.Rate = -1.0, Throws.ArgumentException);
}
///
@@ -433,7 +433,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void FailSampleStatic()
{
- Assert.That(() => Normal.Sample(new Random(0), 1.0, -1.0), Throws.TypeOf());
+ Assert.That(() => Normal.Sample(new Random(0), 1.0, -1.0), Throws.ArgumentException);
}
///
@@ -442,7 +442,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void FailSampleSequenceStatic()
{
- Assert.That(() => Normal.Samples(new Random(0), 1.0, -1.0).First(), Throws.TypeOf());
+ Assert.That(() => Normal.Samples(new Random(0), 1.0, -1.0).First(), Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Continuous/InverseGammaTests.cs b/src/UnitTests/DistributionTests/Continuous/InverseGammaTests.cs
index 0936c359..beac231b 100644
--- a/src/UnitTests/DistributionTests/Continuous/InverseGammaTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/InverseGammaTests.cs
@@ -73,7 +73,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(1.0, Double.NaN)]
public void InverseGammaCreateFailsWithBadParameters(double a, double b)
{
- Assert.That(() => new InverseGamma(a, b), Throws.TypeOf());
+ Assert.That(() => new InverseGamma(a, b), Throws.ArgumentException);
}
///
@@ -112,7 +112,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetAFailsWithNonPositiveA(double a)
{
var n = new InverseGamma(1.0, 1.0);
- Assert.That(() => n.Shape = a, Throws.TypeOf());
+ Assert.That(() => n.Shape = a, Throws.ArgumentException);
}
///
@@ -141,7 +141,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetBFailsWithNonPositiveB(double b)
{
var n = new InverseGamma(1.0, 1.0);
- Assert.That(() => n.Scale = b, Throws.TypeOf());
+ Assert.That(() => n.Scale = b, Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Continuous/LaplaceTests.cs b/src/UnitTests/DistributionTests/Continuous/LaplaceTests.cs
index 15fdd5e8..23ffba3b 100644
--- a/src/UnitTests/DistributionTests/Continuous/LaplaceTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/LaplaceTests.cs
@@ -105,7 +105,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetLocationFailsWithNegativeLocation()
{
var n = new Laplace();
- Assert.That(() => n.Location = Double.NaN, Throws.TypeOf());
+ Assert.That(() => n.Location = Double.NaN, Throws.ArgumentException);
}
///
@@ -136,7 +136,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetScaleFailsWithNegativeScale(double scale)
{
var n = new Laplace();
- Assert.That(() => n.Scale = scale, Throws.TypeOf());
+ Assert.That(() => n.Scale = scale, Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Continuous/LogNormalTests.cs b/src/UnitTests/DistributionTests/Continuous/LogNormalTests.cs
index 168341b9..57f5c98d 100644
--- a/src/UnitTests/DistributionTests/Continuous/LogNormalTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/LogNormalTests.cs
@@ -72,7 +72,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(1.0, -1.0)]
public void LogNormalCreateFailsWithBadParameters(double mu, double sigma)
{
- Assert.That(() => new LogNormal(mu, sigma), Throws.TypeOf());
+ Assert.That(() => new LogNormal(mu, sigma), Throws.ArgumentException);
}
///
@@ -110,7 +110,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetSigmaFailsWithNegativeSigma()
{
var n = new LogNormal(1.0, 2.0);
- Assert.That(() => n.Sigma = -1.0, Throws.TypeOf());
+ Assert.That(() => n.Sigma = -1.0, Throws.ArgumentException);
}
///
@@ -443,7 +443,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void FailSampleStatic()
{
- Assert.That(() => { var d = LogNormal.Sample(new Random(0), 0.0, -1.0); }, Throws.TypeOf());
+ Assert.That(() => { var d = LogNormal.Sample(new Random(0), 0.0, -1.0); }, Throws.ArgumentException);
}
///
@@ -452,7 +452,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void FailSampleSequenceStatic()
{
- Assert.That(() => { var ied = LogNormal.Samples(new Random(0), 0.0, -1.0).First(); }, Throws.TypeOf());
+ Assert.That(() => { var ied = LogNormal.Samples(new Random(0), 0.0, -1.0).First(); }, Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Continuous/NormalTests.cs b/src/UnitTests/DistributionTests/Continuous/NormalTests.cs
index a9bd6972..2b2b4e20 100644
--- a/src/UnitTests/DistributionTests/Continuous/NormalTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/NormalTests.cs
@@ -83,7 +83,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(1.0, -1.0)]
public void NormalCreateFailsWithBadParameters(double mean, double sdev)
{
- Assert.That(() => new Normal(mean, sdev), Throws.TypeOf());
+ Assert.That(() => new Normal(mean, sdev), Throws.ArgumentException);
}
///
@@ -175,7 +175,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetPrecisionFailsWithNegativePrecision()
{
var n = new Normal();
- Assert.That(() => n.Precision = -1.0, Throws.TypeOf());
+ Assert.That(() => n.Precision = -1.0, Throws.ArgumentException);
}
///
@@ -205,7 +205,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetVarianceFailsWithNegativeVariance()
{
var n = new Normal();
- Assert.That(() => n.Variance = -1.0, Throws.TypeOf());
+ Assert.That(() => n.Variance = -1.0, Throws.ArgumentException);
}
///
@@ -235,7 +235,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetStdDevFailsWithNegativeStdDev()
{
var n = new Normal();
- Assert.That(() => n.StdDev = -1.0, Throws.TypeOf());
+ Assert.That(() => n.StdDev = -1.0, Throws.ArgumentException);
}
///
@@ -416,7 +416,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void FailSampleStatic()
{
- Assert.That(() => { var d = Normal.Sample(new Random(0), 0.0, -1.0); }, Throws.TypeOf());
+ Assert.That(() => { var d = Normal.Sample(new Random(0), 0.0, -1.0); }, Throws.ArgumentException);
}
///
@@ -425,7 +425,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void FailSampleSequenceStatic()
{
- Assert.That(() => { var ied = Normal.Samples(new Random(0), 0.0, -1.0).First(); }, Throws.TypeOf());
+ Assert.That(() => { var ied = Normal.Samples(new Random(0), 0.0, -1.0).First(); }, Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Continuous/ParetoTests.cs b/src/UnitTests/DistributionTests/Continuous/ParetoTests.cs
index 99df604b..b4973bf9 100644
--- a/src/UnitTests/DistributionTests/Continuous/ParetoTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/ParetoTests.cs
@@ -73,7 +73,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(1.0, 0.0)]
public void ParetoCreateFailsWithBadParameters(double scale, double shape)
{
- Assert.That(() => { var n = new Pareto(scale, shape); }, Throws.TypeOf());
+ Assert.That(() => { var n = new Pareto(scale, shape); }, Throws.ArgumentException);
}
///
@@ -109,7 +109,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetScaleFailsWithNegativeScale()
{
var n = new Pareto(1.0, 1.0);
- Assert.That(() => n.Scale = -1.0, Throws.TypeOf());
+ Assert.That(() => n.Scale = -1.0, Throws.ArgumentException);
}
///
@@ -135,7 +135,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetShapeFailsWithNegativeShape()
{
var n = new Pareto(1.0, 1.0);
- Assert.That(() => n.Shape = -1.0, Throws.TypeOf());
+ Assert.That(() => n.Shape = -1.0, Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Continuous/RayleighTests.cs b/src/UnitTests/DistributionTests/Continuous/RayleighTests.cs
index 9064e2ea..24d4c624 100644
--- a/src/UnitTests/DistributionTests/Continuous/RayleighTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/RayleighTests.cs
@@ -65,7 +65,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(0.0)]
public void RayleighCreateFailsWithBadParameters(double scale)
{
- Assert.That(() => new Rayleigh(scale), Throws.TypeOf());
+ Assert.That(() => new Rayleigh(scale), Throws.ArgumentException);
}
///
@@ -106,7 +106,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetScaleFailsWithNegativeScale(double scale)
{
var n = new Rayleigh(1.0);
- Assert.That(() => n.Scale = scale, Throws.TypeOf());
+ Assert.That(() => n.Scale = scale, Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Continuous/StableTests.cs b/src/UnitTests/DistributionTests/Continuous/StableTests.cs
index 1e0da246..d9543db9 100644
--- a/src/UnitTests/DistributionTests/Continuous/StableTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/StableTests.cs
@@ -89,7 +89,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(2.1, 1.0, 1.0, 1.0)]
public void StableCreateFailsWithBadParameters(double alpha, double beta, double location, double scale)
{
- Assert.That(() => new Stable(alpha, beta, location, scale), Throws.TypeOf());
+ Assert.That(() => new Stable(alpha, beta, location, scale), Throws.ArgumentException);
}
///
@@ -130,7 +130,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetAlphaFail(double alpha)
{
var n = new Stable(1.0, 1.0, 1.0, 1.0);
- Assert.That(() => n.Alpha = alpha, Throws.TypeOf());
+ Assert.That(() => n.Alpha = alpha, Throws.ArgumentException);
}
///
@@ -163,7 +163,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetBetaFail(double beta)
{
var n = new Stable(1.0, 1.0, 1.0, 1.0);
- Assert.That(() => n.Beta = beta, Throws.TypeOf());
+ Assert.That(() => n.Beta = beta, Throws.ArgumentException);
}
///
@@ -191,7 +191,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetScaleFail(double scale)
{
var n = new Stable(1.0, 1.0, 1.0, 1.0);
- Assert.That(() => n.Scale = scale, Throws.TypeOf());
+ Assert.That(() => n.Scale = scale, Throws.ArgumentException);
}
///
@@ -221,7 +221,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetLocationFail()
{
var n = new Stable(1.0, 1.0, 1.0, 1.0);
- Assert.That(() => n.Location = Double.NaN, Throws.TypeOf());
+ Assert.That(() => n.Location = Double.NaN, Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Continuous/StudentTTests.cs b/src/UnitTests/DistributionTests/Continuous/StudentTTests.cs
index 2dcad435..7773244e 100644
--- a/src/UnitTests/DistributionTests/Continuous/StudentTTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/StudentTTests.cs
@@ -85,7 +85,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(0.0, 10.0, -1.0)]
public void StudentTCreateFailsWithBadParameters(double location, double scale, double dof)
{
- Assert.That(() => new StudentT(location, scale, dof), Throws.TypeOf());
+ Assert.That(() => new StudentT(location, scale, dof), Throws.ArgumentException);
}
///
@@ -144,7 +144,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetScaleFailsWithNonPositiveScale(double scale)
{
var n = new StudentT();
- Assert.That(() => n.Scale = scale, Throws.TypeOf());
+ Assert.That(() => n.Scale = scale, Throws.ArgumentException);
}
///
@@ -173,7 +173,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetDofFailsWithNonPositiveDoF(double dof)
{
var n = new StudentT();
- Assert.That(() => n.DegreesOfFreedom = dof, Throws.TypeOf());
+ Assert.That(() => n.DegreesOfFreedom = dof, Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Continuous/WeibullTests.cs b/src/UnitTests/DistributionTests/Continuous/WeibullTests.cs
index 04034f0a..f7364947 100644
--- a/src/UnitTests/DistributionTests/Continuous/WeibullTests.cs
+++ b/src/UnitTests/DistributionTests/Continuous/WeibullTests.cs
@@ -75,7 +75,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[TestCase(1.0, 0.0)]
public void WeibullCreateFailsWithBadParameters(double shape, double scale)
{
- Assert.That(() => new Weibull(shape, scale), Throws.TypeOf());
+ Assert.That(() => new Weibull(shape, scale), Throws.ArgumentException);
}
///
@@ -114,7 +114,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetShapeFailsWithNegativeShape(double shape)
{
var n = new Weibull(1.0, 1.0);
- Assert.That(() => n.Shape = shape, Throws.TypeOf());
+ Assert.That(() => n.Shape = shape, Throws.ArgumentException);
}
///
@@ -143,7 +143,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
public void SetScaleFailsWithNegativeScale(double scale)
{
var n = new Weibull(1.0, 1.0);
- Assert.That(() => n.Scale = scale, Throws.TypeOf());
+ Assert.That(() => n.Scale = scale, Throws.ArgumentException);
}
///
@@ -337,7 +337,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void FailSampleStatic()
{
- Assert.That(() => Normal.Sample(new Random(0), 1.0, -1.0), Throws.TypeOf());
+ Assert.That(() => Normal.Sample(new Random(0), 1.0, -1.0), Throws.ArgumentException);
}
///
@@ -346,7 +346,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Continuous
[Test]
public void FailSampleSequenceStatic()
{
- Assert.That(() => Normal.Samples(new Random(0), 1.0, -1.0).First(), Throws.TypeOf());
+ Assert.That(() => Normal.Samples(new Random(0), 1.0, -1.0).First(), Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Discrete/CategoricalTests.cs b/src/UnitTests/DistributionTests/Discrete/CategoricalTests.cs
index 493e4b18..a72f5d4a 100644
--- a/src/UnitTests/DistributionTests/Discrete/CategoricalTests.cs
+++ b/src/UnitTests/DistributionTests/Discrete/CategoricalTests.cs
@@ -115,7 +115,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[Test]
public void CategoricalCreateFailsWithNegativeRatios()
{
- Assert.That(() => new Categorical(_badP), Throws.TypeOf());
+ Assert.That(() => new Categorical(_badP), Throws.ArgumentException);
}
///
@@ -124,7 +124,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[Test]
public void CategoricalCreateFailsWithAllZeroRatios()
{
- Assert.That(() => new Categorical(_badP2), Throws.TypeOf());
+ Assert.That(() => new Categorical(_badP2), Throws.ArgumentException);
}
///
@@ -156,7 +156,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
public void SetProbabilityFails()
{
var b = new Categorical(_largeP);
- Assert.That(() => b.P = _badP, Throws.TypeOf());
+ Assert.That(() => b.P = _badP, Throws.ArgumentException);
}
///
@@ -174,7 +174,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[Test]
public void FailSampleStatic()
{
- Assert.That(() => Categorical.SampleWithProbabilityMass(new Random(0), _badP), Throws.TypeOf());
+ Assert.That(() => Categorical.SampleWithProbabilityMass(new Random(0), _badP), Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Multivariate/DirichletTests.cs b/src/UnitTests/DistributionTests/Multivariate/DirichletTests.cs
index 8b6e1d97..98ba5196 100644
--- a/src/UnitTests/DistributionTests/Multivariate/DirichletTests.cs
+++ b/src/UnitTests/DistributionTests/Multivariate/DirichletTests.cs
@@ -88,8 +88,8 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
[Test]
public void FailCreateDirichlet()
{
- Assert.That(() => new Dirichlet(0.0, 5), Throws.TypeOf());
- Assert.That(() => new Dirichlet(-0.1, 5), Throws.TypeOf());
+ Assert.That(() => new Dirichlet(0.0, 5), Throws.ArgumentException);
+ Assert.That(() => new Dirichlet(-0.1, 5), Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Multivariate/InverseWishartTests.cs b/src/UnitTests/DistributionTests/Multivariate/InverseWishartTests.cs
index ce5d3b45..b728c74a 100644
--- a/src/UnitTests/DistributionTests/Multivariate/InverseWishartTests.cs
+++ b/src/UnitTests/DistributionTests/Multivariate/InverseWishartTests.cs
@@ -83,7 +83,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
var matrix = Matrix.Build.RandomPositiveDefinite(order, 1);
matrix[0, 0] = 0.0;
- Assert.That(() => new InverseWishart(nu, matrix), Throws.TypeOf());
+ Assert.That(() => new InverseWishart(nu, matrix), Throws.ArgumentException);
}
///
@@ -96,7 +96,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
public void FailNuCreateInverseWishart(double nu, int order)
{
var matrix = Matrix.Build.RandomPositiveDefinite(order, 1);
- Assert.That(() => new InverseWishart(nu, matrix), Throws.TypeOf());
+ Assert.That(() => new InverseWishart(nu, matrix), Throws.ArgumentException);
}
///
@@ -312,7 +312,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
[Test]
public void FailSampleStatic()
{
- Assert.That(() => InverseWishart.Sample(new System.Random(0), -1.0, Matrix.Build.RandomPositiveDefinite(2, 1)), Throws.TypeOf());
+ Assert.That(() => InverseWishart.Sample(new System.Random(0), -1.0, Matrix.Build.RandomPositiveDefinite(2, 1)), Throws.ArgumentException);
}
}
}
diff --git a/src/UnitTests/DistributionTests/Multivariate/MatrixNormalTests.cs b/src/UnitTests/DistributionTests/Multivariate/MatrixNormalTests.cs
index 0588a9b1..57802d8d 100644
--- a/src/UnitTests/DistributionTests/Multivariate/MatrixNormalTests.cs
+++ b/src/UnitTests/DistributionTests/Multivariate/MatrixNormalTests.cs
@@ -101,7 +101,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
var matrixV = Matrix.Build.Random(rowsOfV, columnsOfV, 1);
var matrixK = Matrix.Build.Random(rowsOfK, columnsOfK, 1);
- Assert.That(() => new MatrixNormal(matrixM, matrixV, matrixK), Throws.TypeOf());
+ Assert.That(() => new MatrixNormal(matrixM, matrixV, matrixK), Throws.ArgumentException);
}
///
@@ -343,7 +343,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
[TestCase(5, 2, 5, 5, 2, 3)]
public void FailSampleStatic(int rowsOfM, int columnsOfM, int rowsOfV, int columnsOfV, int rowsOfK, int columnsOfK)
{
- Assert.That(() => MatrixNormal.Sample(new System.Random(0), Matrix.Build.Random(rowsOfM, columnsOfM, 1), Matrix.Build.Random(rowsOfV, columnsOfV, 1), Matrix.Build.Random(rowsOfK, columnsOfK, 1)), Throws.TypeOf());
+ Assert.That(() => MatrixNormal.Sample(new System.Random(0), Matrix.Build.Random(rowsOfM, columnsOfM, 1), Matrix.Build.Random(rowsOfV, columnsOfV, 1), Matrix.Build.Random(rowsOfK, columnsOfK, 1)), Throws.ArgumentException);
}
}
}
diff --git a/src/UnitTests/DistributionTests/Multivariate/MultinomialTests.cs b/src/UnitTests/DistributionTests/Multivariate/MultinomialTests.cs
index 79b93d8d..6faa2645 100644
--- a/src/UnitTests/DistributionTests/Multivariate/MultinomialTests.cs
+++ b/src/UnitTests/DistributionTests/Multivariate/MultinomialTests.cs
@@ -113,7 +113,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
[Test]
public void MultinomialCreateFailsWithNegativeRatios()
{
- Assert.That(() => new Multinomial(_badP, 4), Throws.TypeOf());
+ Assert.That(() => new Multinomial(_badP, 4), Throws.ArgumentException);
}
///
@@ -122,7 +122,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
[Test]
public void MultinomialCreateFailsWithAllZeroRatios()
{
- Assert.That(() => new Multinomial(_badP2, 4), Throws.TypeOf());
+ Assert.That(() => new Multinomial(_badP2, 4), Throws.ArgumentException);
}
///
@@ -236,7 +236,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
public void SetProbabilityFails()
{
var b = new Multinomial(_largeP, 4);
- Assert.That(() => b.P = _badP, Throws.TypeOf());
+ Assert.That(() => b.P = _badP, Throws.ArgumentException);
}
///
@@ -254,7 +254,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
[Test]
public void FailSampleStatic()
{
- Assert.That(() => Multinomial.Sample(new Random(0), _badP, 4), Throws.TypeOf());
+ Assert.That(() => Multinomial.Sample(new Random(0), _badP, 4), Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Multivariate/NormalGammaTests.cs b/src/UnitTests/DistributionTests/Multivariate/NormalGammaTests.cs
index 49b1818c..7bf821d7 100644
--- a/src/UnitTests/DistributionTests/Multivariate/NormalGammaTests.cs
+++ b/src/UnitTests/DistributionTests/Multivariate/NormalGammaTests.cs
@@ -77,9 +77,9 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
[Test]
public void NormalGammaConstructorFailsWithInvalidParams()
{
- Assert.That(() => new NormalGamma(1.0, -1.3, 2.0, 2.0), Throws.TypeOf());
- Assert.That(() => new NormalGamma(1.0, 1.0, -1.0, 1.0), Throws.TypeOf());
- Assert.That(() => new NormalGamma(1.0, 1.0, 1.0, -1.0), Throws.TypeOf());
+ Assert.That(() => new NormalGamma(1.0, -1.3, 2.0, 2.0), Throws.ArgumentException);
+ Assert.That(() => new NormalGamma(1.0, 1.0, -1.0, 1.0), Throws.ArgumentException);
+ Assert.That(() => new NormalGamma(1.0, 1.0, 1.0, -1.0), Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/DistributionTests/Multivariate/WishartTests.cs b/src/UnitTests/DistributionTests/Multivariate/WishartTests.cs
index a41ae0f6..45c36262 100644
--- a/src/UnitTests/DistributionTests/Multivariate/WishartTests.cs
+++ b/src/UnitTests/DistributionTests/Multivariate/WishartTests.cs
@@ -85,7 +85,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
var matrix = Matrix.Build.RandomPositiveDefinite(order, 1);
matrix[0, 0] = 0.0;
- Assert.That(() => new Wishart(nu, matrix), Throws.TypeOf());
+ Assert.That(() => new Wishart(nu, matrix), Throws.ArgumentException);
}
///
@@ -98,7 +98,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
public void FailNuCreateWishart(double nu, int order)
{
var matrix = Matrix.Build.RandomPositiveDefinite(order, 1);
- Assert.That(() => new InverseWishart(nu, matrix), Throws.TypeOf());
+ Assert.That(() => new InverseWishart(nu, matrix), Throws.ArgumentException);
}
///
@@ -304,7 +304,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
[Test]
public void FailSampleStatic()
{
- Assert.That(() => Wishart.Sample(new System.Random(0), -1.0, Matrix.Build.RandomPositiveDefinite(2, 1)), Throws.TypeOf());
+ Assert.That(() => Wishart.Sample(new System.Random(0), -1.0, Matrix.Build.RandomPositiveDefinite(2, 1)), Throws.ArgumentException);
}
}
}
diff --git a/src/UnitTests/StatisticsTests/HistogramTests.cs b/src/UnitTests/StatisticsTests/HistogramTests.cs
index d2c48273..3420d3ee 100644
--- a/src/UnitTests/StatisticsTests/HistogramTests.cs
+++ b/src/UnitTests/StatisticsTests/HistogramTests.cs
@@ -70,7 +70,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests
[Test]
public void EmptyBucketWithBadBoundsFails()
{
- Assert.That(() => new Bucket(1.0, 0.5), Throws.TypeOf());
+ Assert.That(() => new Bucket(1.0, 0.5), Throws.ArgumentException);
}
///
@@ -79,7 +79,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests
[Test]
public void EmptyBucketWithBadCountFails()
{
- Assert.That(() => new Bucket(1.0, 0.5, -1.0), Throws.TypeOf());
+ Assert.That(() => new Bucket(1.0, 0.5, -1.0), Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/StatisticsTests/MCMCTests/RejectionSamplerTests.cs b/src/UnitTests/StatisticsTests/MCMCTests/RejectionSamplerTests.cs
index 13569a37..dcde74ba 100644
--- a/src/UnitTests/StatisticsTests/MCMCTests/RejectionSamplerTests.cs
+++ b/src/UnitTests/StatisticsTests/MCMCTests/RejectionSamplerTests.cs
@@ -96,7 +96,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests.McmcTests
{
var uniform = new ContinuousUniform(0.0, 1.0, new SystemRandomSource(1));
var rs = new RejectionSampler(x => Math.Pow(x, 1.7)*Math.Pow(1.0 - x, 5.3), x => Double.NegativeInfinity, uniform.Sample);
- Assert.That(() => rs.Sample(), Throws.TypeOf());
+ Assert.That(() => rs.Sample(), Throws.ArgumentException);
}
///
diff --git a/src/UnitTests/StatisticsTests/MCMCTests/UnivariateSliceSamplerTests.cs b/src/UnitTests/StatisticsTests/MCMCTests/UnivariateSliceSamplerTests.cs
index 01fc4471..0530b152 100644
--- a/src/UnitTests/StatisticsTests/MCMCTests/UnivariateSliceSamplerTests.cs
+++ b/src/UnitTests/StatisticsTests/MCMCTests/UnivariateSliceSamplerTests.cs
@@ -88,7 +88,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests.McmcTests
[Test]
public void InvalidScale()
{
- Assert.That(() => new UnivariateSliceSampler(0.1, x => -0.5*x*x, 5, -1.0), Throws.TypeOf());
+ Assert.That(() => new UnivariateSliceSampler(0.1, x => -0.5*x*x, 5, -1.0), Throws.ArgumentException);
}
///
@@ -97,7 +97,7 @@ namespace MathNet.Numerics.UnitTests.StatisticsTests.McmcTests
[Test]
public void InvalidBurn()
{
- Assert.That(() => new UnivariateSliceSampler(0.1, x => -0.5*x*x, -5, 1.0), Throws.TypeOf());
+ Assert.That(() => new UnivariateSliceSampler(0.1, x => -0.5*x*x, -5, 1.0), Throws.ArgumentException);
}
}
}