Browse Source

Throw ArgumentException instead of ArgumentOutOfRangeException where it was used without parameter arg

pull/203/head
Christoph Ruegg 13 years ago
parent
commit
b51bd337f0
  1. 14
      src/Numerics/Distributions/Beta.cs
  2. 12
      src/Numerics/Distributions/Categorical.cs
  3. 2
      src/Numerics/Distributions/Cauchy.cs
  4. 2
      src/Numerics/Distributions/Chi.cs
  5. 12
      src/Numerics/Distributions/ChiSquared.cs
  6. 14
      src/Numerics/Distributions/ContinuousUniform.cs
  7. 4
      src/Numerics/Distributions/Dirichlet.cs
  8. 12
      src/Numerics/Distributions/Erlang.cs
  9. 2
      src/Numerics/Distributions/Exponential.cs
  10. 12
      src/Numerics/Distributions/FisherSnedecor.cs
  11. 14
      src/Numerics/Distributions/Gamma.cs
  12. 10
      src/Numerics/Distributions/InverseGamma.cs
  13. 4
      src/Numerics/Distributions/InverseWishart.cs
  14. 12
      src/Numerics/Distributions/Laplace.cs
  15. 10
      src/Numerics/Distributions/LogNormal.cs
  16. 4
      src/Numerics/Distributions/MatrixNormal.cs
  17. 6
      src/Numerics/Distributions/Multinomial.cs
  18. 14
      src/Numerics/Distributions/Normal.cs
  19. 6
      src/Numerics/Distributions/NormalGamma.cs
  20. 14
      src/Numerics/Distributions/Pareto.cs
  21. 2
      src/Numerics/Distributions/Rayleigh.cs
  22. 12
      src/Numerics/Distributions/Stable.cs
  23. 14
      src/Numerics/Distributions/StudentT.cs
  24. 2
      src/Numerics/Distributions/Triangular.cs
  25. 12
      src/Numerics/Distributions/Weibull.cs
  26. 4
      src/Numerics/Distributions/Wishart.cs
  27. 4
      src/Numerics/LinearAlgebra/Storage/MatrixStorage.cs
  28. 2
      src/Numerics/LinearAlgebra/Storage/SparseCompressedRowMatrixStorage.cs
  29. 2
      src/Numerics/LinearAlgebra/Storage/VectorStorage.cs
  30. 4
      src/Numerics/Random/RandomSource.cs
  31. 2
      src/Numerics/SpecialFunctions/Logistic.cs
  32. 4
      src/Numerics/Statistics/Histogram.cs
  33. 6
      src/Numerics/Statistics/MCMC/HybridMCGeneric.cs
  34. 2
      src/Numerics/Statistics/MCMC/MetropolisHastingsSampler.cs
  35. 2
      src/Numerics/Statistics/MCMC/MetropolisSampler.cs
  36. 2
      src/Numerics/Statistics/MCMC/RejectionSampler.cs
  37. 4
      src/Numerics/Statistics/MCMC/UnivariateSliceSampler.cs
  38. 20
      src/UnitTests/DistributionTests/Continuous/BetaTests.cs
  39. 6
      src/UnitTests/DistributionTests/Continuous/CauchyTests.cs
  40. 6
      src/UnitTests/DistributionTests/Continuous/ChiSquareTests.cs
  41. 4
      src/UnitTests/DistributionTests/Continuous/ChiTests.cs
  42. 10
      src/UnitTests/DistributionTests/Continuous/ContinuousUniformTests.cs
  43. 8
      src/UnitTests/DistributionTests/Continuous/ErlangTests.cs
  44. 4
      src/UnitTests/DistributionTests/Continuous/ExponentialTests.cs
  45. 6
      src/UnitTests/DistributionTests/Continuous/FisherSnedecorTests.cs
  46. 12
      src/UnitTests/DistributionTests/Continuous/GammaTests.cs
  47. 6
      src/UnitTests/DistributionTests/Continuous/InverseGammaTests.cs
  48. 4
      src/UnitTests/DistributionTests/Continuous/LaplaceTests.cs
  49. 8
      src/UnitTests/DistributionTests/Continuous/LogNormalTests.cs
  50. 12
      src/UnitTests/DistributionTests/Continuous/NormalTests.cs
  51. 6
      src/UnitTests/DistributionTests/Continuous/ParetoTests.cs
  52. 4
      src/UnitTests/DistributionTests/Continuous/RayleighTests.cs
  53. 10
      src/UnitTests/DistributionTests/Continuous/StableTests.cs
  54. 6
      src/UnitTests/DistributionTests/Continuous/StudentTTests.cs
  55. 10
      src/UnitTests/DistributionTests/Continuous/WeibullTests.cs
  56. 8
      src/UnitTests/DistributionTests/Discrete/CategoricalTests.cs
  57. 4
      src/UnitTests/DistributionTests/Multivariate/DirichletTests.cs
  58. 6
      src/UnitTests/DistributionTests/Multivariate/InverseWishartTests.cs
  59. 4
      src/UnitTests/DistributionTests/Multivariate/MatrixNormalTests.cs
  60. 8
      src/UnitTests/DistributionTests/Multivariate/MultinomialTests.cs
  61. 6
      src/UnitTests/DistributionTests/Multivariate/NormalGammaTests.cs
  62. 6
      src/UnitTests/DistributionTests/Multivariate/WishartTests.cs
  63. 4
      src/UnitTests/StatisticsTests/HistogramTests.cs
  64. 2
      src/UnitTests/StatisticsTests/MCMCTests/RejectionSamplerTests.cs
  65. 4
      src/UnitTests/StatisticsTests/MCMCTests/UnivariateSliceSamplerTests.cs

14
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
/// <seealso cref="Density"/>
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
/// <seealso cref="DensityLn"/>
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
/// <seealso cref="CumulativeDistribution"/>
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
/// <remarks>WARNING: currently not an explicit implementation, hence slow and unreliable.</remarks>
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
/// <returns>a sample from the distribution.</returns>
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
/// <returns>a sequence of samples from the distribution.</returns>
public static IEnumerable<double> 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)
{

12
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);

2
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;

2
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;

12
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
/// <seealso cref="Density"/>
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
/// <seealso cref="DensityLn"/>
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
/// <seealso cref="CumulativeDistribution"/>
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
/// <returns>a sample from the distribution. </returns>
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
/// <returns>a sample from the distribution. </returns>
public static IEnumerable<double> 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)
{

14
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
/// <seealso cref="Density"/>
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
/// <seealso cref="DensityLn"/>
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
/// <seealso cref="CumulativeDistribution"/>
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
/// <seealso cref="InverseCumulativeDistribution"/>
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
/// <returns>a uniformly distributed sample.</returns>
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
/// <returns>a sequence of uniformly distributed samples.</returns>
public static IEnumerable<double> 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)
{

4
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;

12
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
/// <seealso cref="Density"/>
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
/// <seealso cref="DensityLn"/>
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
/// <seealso cref="CumulativeDistribution"/>
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
/// <returns>a sample from the distribution.</returns>
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
/// <returns>a sequence of samples from the distribution.</returns>
public static IEnumerable<double> 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)
{

2
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;

12
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
/// <seealso cref="Density"/>
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
/// <seealso cref="CumulativeDistribution"/>
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
/// <remarks>WARNING: currently not an explicit implementation, hence slow and unreliable.</remarks>
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
/// <returns>a sample from the distribution.</returns>
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
/// <returns>a sequence of samples from the distribution.</returns>
public static IEnumerable<double> 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)
{

14
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
/// <seealso cref="Density"/>
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
/// <seealso cref="DensityLn"/>
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
/// <seealso cref="CumulativeDistribution"/>
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
/// <seealso cref="InverseCumulativeDistribution"/>
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
/// <returns>a sample from the distribution.</returns>
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
/// <returns>a sequence of samples from the distribution.</returns>
public static IEnumerable<double> 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)
{

10
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
/// <seealso cref="Density"/>
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
/// <seealso cref="CumulativeDistribution"/>
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
/// <returns>a sample from the distribution.</returns>
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
/// <returns>a sequence of samples from the distribution.</returns>
public static IEnumerable<double> 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);
}

4
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());

12
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
/// <seealso cref="Density"/>
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
/// <seealso cref="DensityLn"/>
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
/// <seealso cref="CumulativeDistribution"/>
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
/// <returns>a sample from the distribution.</returns>
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
/// <returns>a sequence of samples from the distribution.</returns>
public static IEnumerable<double> 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)
{

10
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
/// <remarks>MATLAB: lognpdf</remarks>
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
/// <seealso cref="DensityLn"/>
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
/// <remarks>MATLAB: logncdf</remarks>
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
/// <remarks>MATLAB: logninv</remarks>
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));

4
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;

6
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.

14
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
/// <remarks>MATLAB: normpdf</remarks>
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
/// <seealso cref="DensityLn"/>
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
/// <remarks>MATLAB: normcdf</remarks>
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
/// <remarks>MATLAB: norminv</remarks>
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
/// <returns>a sample from the distribution.</returns>
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
/// <returns>a sequence of samples from the distribution.</returns>
public static IEnumerable<double> 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)
{

6
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)

14
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
/// <seealso cref="Density"/>
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
/// <seealso cref="DensityLn"/>
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
/// <seealso cref="CumulativeDistribution"/>
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
/// <seealso cref="InverseCumulativeDistribution"/>
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
/// <returns>a sample from the distribution.</returns>
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
/// <returns>a sequence of samples from the distribution.</returns>
public static IEnumerable<double> 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)

2
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;

12
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<double> 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)
{

14
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
/// <seealso cref="Density"/>
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
/// <seealso cref="DensityLn"/>
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
/// <seealso cref="CumulativeDistribution"/>
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
/// <remarks>WARNING: currently not an explicit implementation, hence slow and unreliable.</remarks>
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
/// <returns>a sample from the distribution.</returns>
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
/// <returns>a sequence of samples from the distribution.</returns>
public static IEnumerable<double> 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)
{

2
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;

12
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
/// <seealso cref="Density"/>
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
/// <seealso cref="DensityLn"/>
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
/// <seealso cref="CumulativeDistribution"/>
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
/// <returns>a sample from the distribution.</returns>
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
/// <returns>a sequence of samples from the distribution.</returns>
public static IEnumerable<double> 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)
{

4
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());

4
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;

2
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<T>(rows, columns);

2
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;

4
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)

2
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));

4
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;

6
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;
}

2
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;
}

2
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;
}

2
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)
{

4
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;
}

20
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<ArgumentOutOfRangeException>());
Assert.That(() => new Beta(1.0, Double.NaN), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => new Beta(Double.NaN, Double.NaN), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => new Beta(1.0, -1.0), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => new Beta(-1.0, 1.0), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => new Beta(-1.0, -1.0), Throws.TypeOf<ArgumentOutOfRangeException>());
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);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.A = -1.0, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.B = -1.0, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => Beta.Sample(new Random(0), 1.0, -1.0), Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => Beta.Samples(new Random(0), 1.0, -1.0).First(), Throws.ArgumentException);
}
/// <summary>

6
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<ArgumentOutOfRangeException>());
Assert.That(() => new Cauchy(location, scale), Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.Location = Double.NaN, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.Scale = -1.0, Throws.ArgumentException);
}
/// <summary>

6
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<ArgumentOutOfRangeException>());
Assert.That(() => new ChiSquared(dof), Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.DegreesOfFreedom = dof, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => ChiSquared.Sample(new Random(0), -1.0), Throws.ArgumentException);
}
/// <summary>

4
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<ArgumentOutOfRangeException>());
Assert.That(() => new Chi(dof), Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.DegreesOfFreedom = dof, Throws.ArgumentException);
}
/// <summary>

10
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<ArgumentOutOfRangeException>());
Assert.That(() => new ContinuousUniform(lower, upper), Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.LowerBound = 3.0, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.UpperBound = -1.0, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => ContinuousUniform.Sample(new Random(0), 0.0, -1.0), Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => ContinuousUniform.Samples(new Random(0), 0.0, -1.0).First(), Throws.ArgumentException);
}
/// <summary>

8
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<ArgumentOutOfRangeException>());
Assert.That(() => new Erlang(shape, invScale), Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.Shape = -1, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.Scale = -1.0, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.Rate = -1.0, Throws.ArgumentException);
}
/// <summary>

4
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<ArgumentOutOfRangeException>());
Assert.That(() => new Exponential(lambda), Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.Rate = -1.0, Throws.ArgumentException);
}
/// <summary>

6
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<ArgumentOutOfRangeException>());
Assert.That(() => new FisherSnedecor(d1, d2), Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.DegreesOfFreedom1 = -1.0, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.DegreesOfFreedom2 = -1.0, Throws.ArgumentException);
}
/// <summary>

12
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<ArgumentOutOfRangeException>());
Assert.That(() => new Gamma(shape, invScale), Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.Shape = -1.0, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.Scale = -1.0, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.Rate = -1.0, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => Normal.Sample(new Random(0), 1.0, -1.0), Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => Normal.Samples(new Random(0), 1.0, -1.0).First(), Throws.ArgumentException);
}
/// <summary>

6
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<ArgumentOutOfRangeException>());
Assert.That(() => new InverseGamma(a, b), Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.Shape = a, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.Scale = b, Throws.ArgumentException);
}
/// <summary>

4
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<ArgumentOutOfRangeException>());
Assert.That(() => n.Location = Double.NaN, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.Scale = scale, Throws.ArgumentException);
}
/// <summary>

8
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<ArgumentOutOfRangeException>());
Assert.That(() => new LogNormal(mu, sigma), Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.Sigma = -1.0, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => { var d = LogNormal.Sample(new Random(0), 0.0, -1.0); }, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => { var ied = LogNormal.Samples(new Random(0), 0.0, -1.0).First(); }, Throws.ArgumentException);
}
/// <summary>

12
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<ArgumentOutOfRangeException>());
Assert.That(() => new Normal(mean, sdev), Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.Precision = -1.0, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.Variance = -1.0, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.StdDev = -1.0, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => { var d = Normal.Sample(new Random(0), 0.0, -1.0); }, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => { var ied = Normal.Samples(new Random(0), 0.0, -1.0).First(); }, Throws.ArgumentException);
}
/// <summary>

6
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<ArgumentOutOfRangeException>());
Assert.That(() => { var n = new Pareto(scale, shape); }, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.Scale = -1.0, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.Shape = -1.0, Throws.ArgumentException);
}
/// <summary>

4
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<ArgumentOutOfRangeException>());
Assert.That(() => new Rayleigh(scale), Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.Scale = scale, Throws.ArgumentException);
}
/// <summary>

10
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<ArgumentOutOfRangeException>());
Assert.That(() => new Stable(alpha, beta, location, scale), Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.Alpha = alpha, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.Beta = beta, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.Scale = scale, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.Location = Double.NaN, Throws.ArgumentException);
}
/// <summary>

6
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<ArgumentOutOfRangeException>());
Assert.That(() => new StudentT(location, scale, dof), Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.Scale = scale, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.DegreesOfFreedom = dof, Throws.ArgumentException);
}
/// <summary>

10
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<ArgumentOutOfRangeException>());
Assert.That(() => new Weibull(shape, scale), Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.Shape = shape, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => n.Scale = scale, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => Normal.Sample(new Random(0), 1.0, -1.0), Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => Normal.Samples(new Random(0), 1.0, -1.0).First(), Throws.ArgumentException);
}
/// <summary>

8
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<ArgumentOutOfRangeException>());
Assert.That(() => new Categorical(_badP), Throws.ArgumentException);
}
/// <summary>
@ -124,7 +124,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[Test]
public void CategoricalCreateFailsWithAllZeroRatios()
{
Assert.That(() => new Categorical(_badP2), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => new Categorical(_badP2), Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => b.P = _badP, Throws.ArgumentException);
}
/// <summary>
@ -174,7 +174,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Discrete
[Test]
public void FailSampleStatic()
{
Assert.That(() => Categorical.SampleWithProbabilityMass(new Random(0), _badP), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => Categorical.SampleWithProbabilityMass(new Random(0), _badP), Throws.ArgumentException);
}
/// <summary>

4
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<ArgumentOutOfRangeException>());
Assert.That(() => new Dirichlet(-0.1, 5), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => new Dirichlet(0.0, 5), Throws.ArgumentException);
Assert.That(() => new Dirichlet(-0.1, 5), Throws.ArgumentException);
}
/// <summary>

6
src/UnitTests/DistributionTests/Multivariate/InverseWishartTests.cs

@ -83,7 +83,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
var matrix = Matrix<double>.Build.RandomPositiveDefinite(order, 1);
matrix[0, 0] = 0.0;
Assert.That(() => new InverseWishart(nu, matrix), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => new InverseWishart(nu, matrix), Throws.ArgumentException);
}
/// <summary>
@ -96,7 +96,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
public void FailNuCreateInverseWishart(double nu, int order)
{
var matrix = Matrix<double>.Build.RandomPositiveDefinite(order, 1);
Assert.That(() => new InverseWishart(nu, matrix), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => new InverseWishart(nu, matrix), Throws.ArgumentException);
}
/// <summary>
@ -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<double>.Build.RandomPositiveDefinite(2, 1)), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => InverseWishart.Sample(new System.Random(0), -1.0, Matrix<double>.Build.RandomPositiveDefinite(2, 1)), Throws.ArgumentException);
}
}
}

4
src/UnitTests/DistributionTests/Multivariate/MatrixNormalTests.cs

@ -101,7 +101,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
var matrixV = Matrix<double>.Build.Random(rowsOfV, columnsOfV, 1);
var matrixK = Matrix<double>.Build.Random(rowsOfK, columnsOfK, 1);
Assert.That(() => new MatrixNormal(matrixM, matrixV, matrixK), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => new MatrixNormal(matrixM, matrixV, matrixK), Throws.ArgumentException);
}
/// <summary>
@ -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<double>.Build.Random(rowsOfM, columnsOfM, 1), Matrix<double>.Build.Random(rowsOfV, columnsOfV, 1), Matrix<double>.Build.Random(rowsOfK, columnsOfK, 1)), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => MatrixNormal.Sample(new System.Random(0), Matrix<double>.Build.Random(rowsOfM, columnsOfM, 1), Matrix<double>.Build.Random(rowsOfV, columnsOfV, 1), Matrix<double>.Build.Random(rowsOfK, columnsOfK, 1)), Throws.ArgumentException);
}
}
}

8
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<ArgumentOutOfRangeException>());
Assert.That(() => new Multinomial(_badP, 4), Throws.ArgumentException);
}
/// <summary>
@ -122,7 +122,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
[Test]
public void MultinomialCreateFailsWithAllZeroRatios()
{
Assert.That(() => new Multinomial(_badP2, 4), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => new Multinomial(_badP2, 4), Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => b.P = _badP, Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => Multinomial.Sample(new Random(0), _badP, 4), Throws.ArgumentException);
}
/// <summary>

6
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<ArgumentOutOfRangeException>());
Assert.That(() => new NormalGamma(1.0, 1.0, -1.0, 1.0), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => new NormalGamma(1.0, 1.0, 1.0, -1.0), Throws.TypeOf<ArgumentOutOfRangeException>());
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);
}
/// <summary>

6
src/UnitTests/DistributionTests/Multivariate/WishartTests.cs

@ -85,7 +85,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
var matrix = Matrix<double>.Build.RandomPositiveDefinite(order, 1);
matrix[0, 0] = 0.0;
Assert.That(() => new Wishart(nu, matrix), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => new Wishart(nu, matrix), Throws.ArgumentException);
}
/// <summary>
@ -98,7 +98,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests.Multivariate
public void FailNuCreateWishart(double nu, int order)
{
var matrix = Matrix<double>.Build.RandomPositiveDefinite(order, 1);
Assert.That(() => new InverseWishart(nu, matrix), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => new InverseWishart(nu, matrix), Throws.ArgumentException);
}
/// <summary>
@ -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<double>.Build.RandomPositiveDefinite(2, 1)), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => Wishart.Sample(new System.Random(0), -1.0, Matrix<double>.Build.RandomPositiveDefinite(2, 1)), Throws.ArgumentException);
}
}
}

4
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<ArgumentOutOfRangeException>());
Assert.That(() => new Bucket(1.0, 0.5), Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => new Bucket(1.0, 0.5, -1.0), Throws.ArgumentException);
}
/// <summary>

2
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<double>(x => Math.Pow(x, 1.7)*Math.Pow(1.0 - x, 5.3), x => Double.NegativeInfinity, uniform.Sample);
Assert.That(() => rs.Sample(), Throws.TypeOf<ArgumentOutOfRangeException>());
Assert.That(() => rs.Sample(), Throws.ArgumentException);
}
/// <summary>

4
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<ArgumentOutOfRangeException>());
Assert.That(() => new UnivariateSliceSampler(0.1, x => -0.5*x*x, 5, -1.0), Throws.ArgumentException);
}
/// <summary>
@ -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<ArgumentOutOfRangeException>());
Assert.That(() => new UnivariateSliceSampler(0.1, x => -0.5*x*x, -5, 1.0), Throws.ArgumentException);
}
}
}

Loading…
Cancel
Save