diff --git a/src/Managed.UnitTests/DistributionTests/Continuous/ContinuousUniformTests.cs b/src/Managed.UnitTests/DistributionTests/Continuous/ContinuousUniformTests.cs
new file mode 100644
index 00000000..daf8fbe0
--- /dev/null
+++ b/src/Managed.UnitTests/DistributionTests/Continuous/ContinuousUniformTests.cs
@@ -0,0 +1,339 @@
+//
+// Math.NET Numerics, part of the Math.NET Project
+// http://mathnet.opensourcedotnet.info
+//
+// Copyright (c) 2009 Math.NET
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace MathNet.Numerics.UnitTests.DistributionTests
+{
+ using System;
+ using System.Linq;
+ using MbUnit.Framework;
+ using MathNet.Numerics.Distributions;
+
+ [TestFixture]
+ public class ContinuousUniformTests
+ {
+ [SetUp]
+ public void SetUp()
+ {
+ Control.CheckDistributionParameters = true;
+ }
+
+ [Test, MultipleAsserts]
+ public void CanCreateContinuousUniform()
+ {
+ var n = new ContinuousUniform();
+ AssertEx.AreEqual(0.0, n.Lower);
+ AssertEx.AreEqual(1.0, n.Upper);
+ }
+
+ [Test, MultipleAsserts]
+ [Row(0.0, 0.0)]
+ [Row(0.0, 0.1)]
+ [Row(0.0, 1.0)]
+ [Row(0.0, 10.0)]
+ [Row(10.0, 11.0)]
+ [Row(-5.0, 100.0)]
+ [Row(0.0, Double.PositiveInfinity)]
+ public void CanCreateContinuousUniform(double lower, double upper)
+ {
+ var n = new ContinuousUniform(lower, upper);
+ AssertEx.AreEqual(lower, n.Lower);
+ AssertEx.AreEqual(upper, n.Upper);
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentOutOfRangeException))]
+ [Row(Double.NaN, 1.0)]
+ [Row(1.0, Double.NaN)]
+ [Row(Double.NaN, Double.NaN)]
+ [Row(1.0, 0.0)]
+ public void ContinuousUniformCreateFailsWithBadParameters(double lower, double upper)
+ {
+ var n = new ContinuousUniform(lower, upper);
+ }
+
+ [Test]
+ public void ValidateToString()
+ {
+ var n = new ContinuousUniform(1.0, 2.0);
+ AssertEx.AreEqual("ContinuousUniform(Lower = 1, Upper = 2)", n.ToString());
+ }
+
+ [Test]
+ public void CanGetRandomSource()
+ {
+ var n = new ContinuousUniform();
+ var rs = n.RandomSource;
+ Assert.IsNotNull(rs);
+ }
+
+ [Test]
+ public void CanSetRandomSource()
+ {
+ var n = new ContinuousUniform();
+ n.RandomSource = new Random();
+ }
+
+ [Test]
+ [Row(-10.0)]
+ [Row(-0.0)]
+ [Row(0.0)]
+ [Row(0.1)]
+ [Row(1.0)]
+ public void CanSetLower(double lower)
+ {
+ var n = new ContinuousUniform();
+ n.Lower = lower;
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentOutOfRangeException))]
+ public void SetLowerFail()
+ {
+ var n = new ContinuousUniform();
+ n.Lower = 3.0;
+ }
+
+ [Test]
+ [Row(1.0)]
+ [Row(2.0)]
+ [Row(12.0)]
+ public void CanSetUpper(double upper)
+ {
+ var n = new ContinuousUniform();
+ n.Upper = upper;
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentOutOfRangeException))]
+ public void SetUpperFail()
+ {
+ var n = new ContinuousUniform();
+ n.Upper = -1.0;
+ }
+
+ [Test]
+ [Row(-0.0, 2.0)]
+ [Row(0.0, 2.0)]
+ [Row(0.1, 4.0)]
+ [Row(1.0, 10.0)]
+ [Row(10.0, 11.0)]
+ [Row(0.0, Double.PositiveInfinity)]
+ public void ValidateEntropy(double lower, double upper)
+ {
+ var n = new ContinuousUniform(lower, upper);
+ AssertEx.AreEqual(Math.Log(upper - lower), n.Entropy);
+ }
+
+ [Test]
+ [Row(-0.0, 2.0)]
+ [Row(0.0, 2.0)]
+ [Row(0.1, 4.0)]
+ [Row(1.0, 10.0)]
+ [Row(10.0, 11.0)]
+ [Row(0.0, Double.PositiveInfinity)]
+ public void ValidateSkewness(double lower, double upper)
+ {
+ var n = new ContinuousUniform(lower, upper);
+ AssertEx.AreEqual(0.0, n.Skewness);
+ }
+
+ [Test]
+ [Row(-0.0, 2.0)]
+ [Row(0.0, 2.0)]
+ [Row(0.1, 4.0)]
+ [Row(1.0, 10.0)]
+ [Row(10.0, 11.0)]
+ [Row(0.0, Double.PositiveInfinity)]
+ public void ValidateMode(double lower, double upper)
+ {
+ var n = new ContinuousUniform(lower, upper);
+ AssertEx.AreEqual( (lower + upper) / 2.0 , n.Mode);
+ }
+
+ [Test]
+ [Row(-0.0, 2.0)]
+ [Row(0.0, 2.0)]
+ [Row(0.1, 4.0)]
+ [Row(1.0, 10.0)]
+ [Row(10.0, 11.0)]
+ [Row(0.0, Double.PositiveInfinity)]
+ public void ValidateMedian(double lower, double upper)
+ {
+ var n = new ContinuousUniform(lower, upper);
+ AssertEx.AreEqual((lower + upper) / 2.0, n.Median);
+ }
+
+ [Test]
+ [Row(-0.0, 2.0)]
+ [Row(0.0, 2.0)]
+ [Row(0.1, 4.0)]
+ [Row(1.0, 10.0)]
+ [Row(10.0, 11.0)]
+ [Row(0.0, Double.PositiveInfinity)]
+ public void ValidateMinimum(double lower, double upper)
+ {
+ var n = new ContinuousUniform(lower, upper);
+ AssertEx.AreEqual(lower, n.Minimum);
+ }
+
+ [Test]
+ [Row(-0.0, 2.0)]
+ [Row(0.0, 2.0)]
+ [Row(0.1, 4.0)]
+ [Row(1.0, 10.0)]
+ [Row(10.0, 11.0)]
+ [Row(0.0, Double.PositiveInfinity)]
+ public void ValidateMaximum(double lower, double upper)
+ {
+ var n = new ContinuousUniform(lower, upper);
+ AssertEx.AreEqual(upper, n.Maximum);
+ }
+
+ [Test]
+ [Row(0.0, 0.0)]
+ [Row(0.0, 0.1)]
+ [Row(0.0, 1.0)]
+ [Row(0.0, 10.0)]
+ [Row(-5.0, 100.0)]
+ [Row(0.0, Double.PositiveInfinity)]
+ public void ValidateDensity(double lower, double upper)
+ {
+ var n = new ContinuousUniform(lower, upper);
+ for (int i = 0; i < 11; i++)
+ {
+ double x = i - 5.0;
+ if(x >= lower && x <= upper)
+ {
+ AssertEx.AreEqual(1.0 / (upper - lower), n.Density(x));
+ }
+ else
+ {
+ AssertEx.AreEqual(0.0, n.Density(x));
+ }
+ }
+ }
+
+ [Test]
+ [Row(0.0, 0.0)]
+ [Row(0.0, 0.1)]
+ [Row(0.0, 1.0)]
+ [Row(0.0, 10.0)]
+ [Row(-5.0, 100.0)]
+ [Row(0.0, Double.PositiveInfinity)]
+ public void ValidateDensityLn(double lower, double upper)
+ {
+ var n = new ContinuousUniform(lower, upper);
+ for (int i = 0; i < 11; i++)
+ {
+ double x = i - 5.0;
+ if (x >= lower && x <= upper)
+ {
+ AssertEx.AreEqual(-Math.Log(upper - lower), n.DensityLn(x));
+ }
+ else
+ {
+ AssertEx.AreEqual(double.NegativeInfinity, n.DensityLn(x));
+ }
+ }
+ }
+
+ [Test]
+ public void CanSampleStatic()
+ {
+ var d = ContinuousUniform.Sample(new Random(), 0.0, 1.0);
+ }
+
+ [Test]
+ public void CanSampleSequenceStatic()
+ {
+ var ied = ContinuousUniform.Samples(new Random(), 0.0, 1.0);
+ var e = ied.GetEnumerator();
+ e.MoveNext();
+ var d = e.Current;
+ e.MoveNext();
+ var g = e.Current;
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentOutOfRangeException))]
+ public void FailSampleStatic()
+ {
+ var d = ContinuousUniform.Sample(new Random(), 0.0, -1.0);
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentOutOfRangeException))]
+ public void FailSampleSequenceStatic()
+ {
+ var ied = ContinuousUniform.Samples(new Random(), 0.0, -1.0).First();
+ }
+
+ [Test]
+ public void CanSample()
+ {
+ var n = new ContinuousUniform();
+ var d = n.Sample();
+ }
+
+ [Test]
+ public void CanSampleSequence()
+ {
+ var n = new ContinuousUniform();
+ var ied = n.Samples();
+ var e = ied.Take(5).ToArray();
+ }
+
+ [Test]
+ [Row(0.0, 0.0)]
+ [Row(0.0, 0.1)]
+ [Row(0.0, 1.0)]
+ [Row(0.0, 10.0)]
+ [Row(-5.0, 100.0)]
+ [Row(0.0, Double.PositiveInfinity)]
+ public void ValidateCumulativeDistribution(double lower, double upper)
+ {
+ var n = new ContinuousUniform(lower, upper);
+ for (int i = 0; i < 11; i++)
+ {
+ double x = i - 5.0;
+ if (x <= lower)
+ {
+ AssertEx.AreEqual(0.0, n.CumulativeDistribution(x));
+ }
+ else if (x >= upper)
+ {
+ AssertEx.AreEqual(1.0, n.CumulativeDistribution(x));
+ }
+ else
+ {
+ AssertEx.AreEqual((x - lower) / (upper - lower), n.CumulativeDistribution(x));
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Managed.UnitTests/DistributionTests/Continuous/NormalTests.cs b/src/Managed.UnitTests/DistributionTests/Continuous/NormalTests.cs
index 55e1d1a5..5ba4b03e 100644
--- a/src/Managed.UnitTests/DistributionTests/Continuous/NormalTests.cs
+++ b/src/Managed.UnitTests/DistributionTests/Continuous/NormalTests.cs
@@ -29,12 +29,19 @@
namespace MathNet.Numerics.UnitTests.DistributionTests
{
using System;
+ using System.Linq;
using MbUnit.Framework;
using MathNet.Numerics.Distributions;
[TestFixture]
public class NormalTests
{
+ [SetUp]
+ public void SetUp()
+ {
+ Control.CheckDistributionParameters = true;
+ }
+
[Test, MultipleAsserts]
public void CanCreateStandardNormal()
{
@@ -60,16 +67,13 @@ namespace MathNet.Numerics.UnitTests.DistributionTests
[Test]
[ExpectedException(typeof(ArgumentOutOfRangeException))]
- public void NormalCreateFailsWithMeanIsNaN()
- {
- var n = new Normal(Double.NaN, 1.0);
- }
-
- [Test]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- public void NormalCreateFailsWithStdDevIsNaN()
+ [Row(Double.NaN, 1.0)]
+ [Row(1.0, Double.NaN)]
+ [Row(Double.NaN, Double.NaN)]
+ [Row(1.0, -1.0)]
+ public void NormalCreateFailsWithBadParameters(double mean, double sdev)
{
- var n = new Normal(0.0, Double.NaN);
+ var n = new Normal(mean, sdev);
}
[Test, MultipleAsserts]
@@ -118,14 +122,14 @@ namespace MathNet.Numerics.UnitTests.DistributionTests
}
[Test]
- public void ToStringTest()
+ public void ValidateToString()
{
var n = new Normal(1.0, 2.0);
AssertEx.AreEqual("Normal(Mean = 1, StdDev = 2)", n.ToString());
}
[Test]
- public void CanGetRandomNumberGenerator()
+ public void CanGetRandomSource()
{
var n = new Normal();
var rs = n.RandomSource;
@@ -133,7 +137,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests
}
[Test]
- public void CanSetRandomNumberGenerator()
+ public void CanSetRandomSource()
{
var n = new Normal();
n.RandomSource = new Random();
@@ -341,6 +345,20 @@ namespace MathNet.Numerics.UnitTests.DistributionTests
var g = e.Current;
}
+ [Test]
+ [ExpectedException(typeof(ArgumentOutOfRangeException))]
+ public void FailSampleStatic()
+ {
+ var d = Normal.Sample(new Random(), 0.0, -1.0);
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentOutOfRangeException))]
+ public void FailSampleSequenceStatic()
+ {
+ var ied = Normal.Samples(new Random(), 0.0, -1.0).First();
+ }
+
[Test]
public void CanSample()
{
@@ -353,11 +371,7 @@ namespace MathNet.Numerics.UnitTests.DistributionTests
{
var n = new Normal();
var ied = n.Samples();
- var e = ied.GetEnumerator();
- e.MoveNext();
- var d = e.Current;
- e.MoveNext();
- var g = e.Current;
+ var e = ied.Take(5).ToArray();
}
[Test]
diff --git a/src/Managed.UnitTests/Managed.UnitTests.csproj b/src/Managed.UnitTests/Managed.UnitTests.csproj
index 05f7aba1..a626b3c6 100644
--- a/src/Managed.UnitTests/Managed.UnitTests.csproj
+++ b/src/Managed.UnitTests/Managed.UnitTests.csproj
@@ -60,6 +60,7 @@
+
diff --git a/src/Managed/Combinatorics.cs b/src/Managed/Combinatorics.cs
index 360935cb..1c9f52d6 100644
--- a/src/Managed/Combinatorics.cs
+++ b/src/Managed/Combinatorics.cs
@@ -1,4 +1,4 @@
-//
+//
// Math.NET Numerics, part of the Math.NET Project
// http://mathnet.opensourcedotnet.info
//
diff --git a/src/Managed/Complex.cs b/src/Managed/Complex.cs
index a24a0345..5257a4a1 100644
--- a/src/Managed/Complex.cs
+++ b/src/Managed/Complex.cs
@@ -1,4 +1,4 @@
-//
+//
// Math.NET Numerics, part of the Math.NET Project
// http://mathnet.opensourcedotnet.info
//
diff --git a/src/Managed/Constants.cs b/src/Managed/Constants.cs
index ab358298..df580dee 100644
--- a/src/Managed/Constants.cs
+++ b/src/Managed/Constants.cs
@@ -35,107 +35,107 @@ namespace MathNet.Numerics
///
public static class Constants
{
- /// e
+ /// The number e
public const double E = 2.7182818284590452353602874713526624977572470937000d;
- /// log[2](e)
+ /// The number log[2](e)
public const double Log2E = 1.4426950408889634073599246810018921374266459541530d;
- /// log[10](e)
+ /// The number log[10](e)
public const double Log10E = 0.43429448190325182765112891891660508229439700580366d;
- /// log[e](2)
+ /// The number log[e](2)
public const double Ln2 = 0.69314718055994530941723212145817656807550013436026d;
- /// log[e](10)
+ /// The number log[e](10)
public const double Ln10 = 2.3025850929940456840179914546843642076011014886288d;
- /// log[e](pi)
+ /// The number log[e](pi)
public const double LnPi = 1.1447298858494001741434273513530587116472948129153d;
- /// log[e](2*pi)/2
+ /// The number log[e](2*pi)/2
public const double Ln2PiOver2 = 0.91893853320467274178032973640561763986139747363780d;
- /// 1/e
+ /// The number 1/e
public const double InvE = 0.36787944117144232159552377016146086744581113103176d;
- /// sqrt(e)
+ /// The number sqrt(e)
public const double SqrtE = 1.6487212707001281468486507878141635716537761007101d;
- /// sqrt(2)
+ /// The number sqrt(2)
public const double Sqrt2 = 1.4142135623730950488016887242096980785696718753769d;
- /// sqrt(1/2) = 1/sqrt(2) = sqrt(2)/2
+ /// The number sqrt(1/2) = 1/sqrt(2) = sqrt(2)/2
public const double Sqrt1Over2 = 0.70710678118654752440084436210484903928483593768845d;
- /// sqrt(3)/2
+ /// The number sqrt(3)/2
public const double HalfSqrt3 = 0.86602540378443864676372317075293618347140262690520d;
- /// pi
+ /// The number pi
public const double Pi = 3.1415926535897932384626433832795028841971693993751d;
-
- /// 1/pi
+
+ /// The number 1/pi
public const double OneOverPi = 0.31830988618379067153776752674502872406891929148091d;
- /// pi/2
+ /// The number pi/2
public const double PiOver2 = 1.5707963267948966192313216916397514420985846996876d;
- /// pi/4
+ /// The number pi/4
public const double PiOver4 = 0.78539816339744830961566084581987572104929234984378d;
- /// sqrt(pi)
+ /// The number sqrt(pi)
public const double SqrtPi = 1.7724538509055160272981674833411451827975494561224d;
- /// sqrt(2pi)
+ /// The number sqrt(2pi)
public const double Sqrt2Pi = 2.5066282746310005024157652848110452530069867406099d;
- /// sqrt(2*pi*e)
+ /// The number sqrt(2*pi*e)
public const double Sqrt2PiE = 4.1327313541224929384693918842998526494455219169913d;
- /// log(sqrt(2*pi))
+ /// The number log(sqrt(2*pi))
public const double LogSqrt2Pi = 0.91893853320467274178032973640561763986139747363778;
- /// log(sqrt(2*pi*e))
+ /// The number log(sqrt(2*pi*e))
public const double LogSqrt2PiE = 1.4189385332046727417803297364056176398613974736378d;
- /// 1/pi
+ /// The number 1/pi
public const double InvPi = 0.31830988618379067153776752674502872406891929148091d;
- /// 2/pi
+ /// The number 2/pi
public const double TwoInvPi = 0.63661977236758134307553505349005744813783858296182d;
- /// 1/sqrt(pi)
+ /// The number 1/sqrt(pi)
public const double InvSqrtPi = 0.56418958354775628694807945156077258584405062932899d;
- /// 1/sqrt(2pi)
+ /// The number 1/sqrt(2pi)
public const double InvSqrt2Pi = 0.39894228040143267793994605993438186847585863116492d;
- /// 2/sqrt(pi)
+ /// The number 2/sqrt(pi)
public const double TwoInvSqrtPi = 1.1283791670955125738961589031215451716881012586580d;
- /// (pi)/180 - factor to convert from Degree (deg) to Radians (rad).
+ /// The number (pi)/180 - factor to convert from Degree (deg) to Radians (rad).
///
///
public const double Degree = 0.017453292519943295769236907684886127134428718885417d;
- /// (pi)/200 - factor to convert from NewGrad (grad) to Radians (rad).
+ /// The number (pi)/200 - factor to convert from NewGrad (grad) to Radians (rad).
///
///
public const double Grad = 0.015707963267948966192313216916397514420985846996876d;
- /// ln(10)/20 - factor to convert from Power Decibel (dB) to Neper (Np). Use this version when the Decibel represent a power gain but the compared values are not powers (e.g. amplitude, current, voltage).
+ /// The number ln(10)/20 - factor to convert from Power Decibel (dB) to Neper (Np). Use this version when the Decibel represent a power gain but the compared values are not powers (e.g. amplitude, current, voltage).
///
///
///
public const double PowerDecibel = 0.11512925464970228420089957273421821038005507443144d;
- /// ln(10)/10 - factor to convert from Neutral Decibel (dB) to Neper (Np). Use this version when either both or neither of the Decibel and the compared values represent powers.
+ /// The number ln(10)/10 - factor to convert from Neutral Decibel (dB) to Neper (Np). Use this version when either both or neither of the Decibel and the compared values represent powers.
///
///
///
public const double NeutralDecibel = 0.23025850929940456840179914546843642076011014886288d;
- /// Catalan constant
+ /// The Catalan constant
/// Sum(k=0 -> inf){ (-1)^k/(2*k + 1)2 }
public const double Catalan = 0.9159655941772190150546035149323841107741493742816721342664981196217630197762547694794d;
@@ -143,14 +143,14 @@ namespace MathNet.Numerics
/// lim(n -> inf){ Sum(k=1 -> n) { 1/k - log(n) } }
public const double EulerMascheroni = 0.5772156649015328606065120900824024310421593359399235988057672348849d;
- /// (1+sqrt(5))/2
+ /// The number (1+sqrt(5))/2, also known as the golden ratio
public const double GoldenRatio = 1.6180339887498948482045868343656381177203091798057628621354486227052604628189024497072d;
- /// Glaisher Constant
+ /// The Glaisher constant
/// e^(1/12 - Zeta(-1))
public const double Glaisher = 1.2824271291006226368753425688697917277676889273250011920637400217404063088588264611297d;
- /// Khinchin constant
+ /// The Khinchin constant
/// prod(k=1 -> inf){1+1/(k*(k+2))^log(k,2)}
public const double Khinchin = 2.6854520010653064453097148354817956938203822939944629530511523455572188595371520028011d;
}
diff --git a/src/Managed/Control.cs b/src/Managed/Control.cs
new file mode 100644
index 00000000..b10625d4
--- /dev/null
+++ b/src/Managed/Control.cs
@@ -0,0 +1,63 @@
+//
+// Math.NET Numerics, part of the Math.NET Project
+// http://mathnet.opensourcedotnet.info
+//
+// Copyright (c) 2009 Math.NET
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace MathNet.Numerics
+{
+ using System;
+
+ ///
+ /// Sets parameters for the library.
+ ///
+ public static partial class Control
+ {
+ ///
+ /// Initializes static members of the Control class.
+ ///
+ static Control()
+ {
+ CheckDistributionParameters = true;
+ ThreadSafeRandomNumberGenerators = true;
+ }
+
+ ///
+ /// Gets or sets a value indicating whether the distribution classes check validate each parameter.
+ /// For the multivariate distributions this could involve an expensive matrix factorization.
+ /// The default setting of this property is true.
+ ///
+ public static bool CheckDistributionParameters { get; set; }
+
+ ///
+ /// Gets or sets a value indicating whether to use thread safe random number generators (RNG).
+ /// Thread safe RNG about two and half time slower than non-thread safe RNG.
+ ///
+ ///
+ /// true to use thread safe random number generators ; otherwise, false.
+ ///
+ public static bool ThreadSafeRandomNumberGenerators { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/Managed/Distributions/Continuous/ContinuousUniform.cs b/src/Managed/Distributions/Continuous/ContinuousUniform.cs
new file mode 100644
index 00000000..b2f47b06
--- /dev/null
+++ b/src/Managed/Distributions/Continuous/ContinuousUniform.cs
@@ -0,0 +1,361 @@
+//
+// Math.NET Numerics, part of the Math.NET Project
+// http://mathnet.opensourcedotnet.info
+//
+// Copyright (c) 2009 Math.NET
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace MathNet.Numerics.Distributions
+{
+ using System;
+ using System.Collections.Generic;
+ using MathNet.Numerics.Properties;
+
+ ///
+ /// The continuous uniform distribution is a distribution over real numbers. For details about this distribution, see
+ /// Wikipedia - Continuous uniform distribution.
+ ///
+ /// The distribution will use the by default.
+ /// Users can get/set the random number generator by using the property.
+ /// The statistics classes will check all the incoming parameters whether they are in the allowed
+ /// range. This might involve heavy computation. Optionally, by setting Control.CheckDistributionParameters
+ /// to false, all parameter checks can be turned off.
+ public class ContinuousUniform : IContinuousDistribution
+ {
+ ///
+ /// The distribution's lower bound.
+ ///
+ private double mLower;
+
+ ///
+ /// The distribution's upper bound.
+ ///
+ private double mUpper;
+
+ ///
+ /// Initializes a new instance of the ContinuousUniform class with lower bound 0 and upper bound 1.
+ ///
+ public ContinuousUniform() : this(0.0, 1.0)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the ContinuousUniform class with given lower and upper bounds.
+ ///
+ /// Lower bound.
+ /// Upper bound; must be at least as large as .
+ /// If the upper bound is smaller than the lower bound.
+ public ContinuousUniform(double lower, double upper)
+ {
+ SetParameters(lower, upper);
+ RandomSource = new System.Random();
+ }
+
+ ///
+ /// A string representation of the distribution.
+ ///
+ /// a string representation of the distribution.
+ public override string ToString()
+ {
+ return "ContinuousUniform(Lower = " + mLower + ", Upper = " + mUpper + ")";
+ }
+
+ ///
+ /// Checks whether the parameters of the distribution are valid.
+ ///
+ /// Lower bound.
+ /// Upper bound; must be at least as large as .
+ /// True when the parameters are valid, false otherwise.
+ private static bool IsValidParameterSet(double lower, double upper)
+ {
+ if (upper < lower)
+ {
+ return false;
+ }
+ else if(Double.IsNaN(upper) || Double.IsNaN(lower))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ ///
+ /// Sets the parameters of the distribution after checking their validity.
+ ///
+ /// Lower bound.
+ /// Upper bound; must be at least as large as .
+ /// When the parameters don't pass the function.
+ private void SetParameters(double lower, double upper)
+ {
+ if (!Control.CheckDistributionParameters || IsValidParameterSet(lower, upper))
+ {
+ mLower = lower;
+ mUpper = upper;
+ }
+ else
+ {
+ throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ }
+ }
+
+ ///
+ /// Gets or sets the lower bound of the distribution.
+ ///
+ public double Lower
+ {
+ get
+ {
+ return mLower;
+ }
+
+ set
+ {
+ SetParameters(value, mUpper);
+ }
+ }
+
+ ///
+ /// Gets or sets the upper bound of the distribution.
+ ///
+ public double Upper
+ {
+ get
+ {
+ return mUpper;
+ }
+
+ set
+ {
+ SetParameters(mLower, value);
+ }
+ }
+
+ #region IDistribution Members
+
+ ///
+ /// Gets or sets the random number generator which is used to draw random samples.
+ ///
+ public Random RandomSource { get; set; }
+
+ ///
+ /// Gets the mean of the distribution.
+ ///
+ public double Mean
+ {
+ get { return (mLower + mUpper)/2.0; }
+ }
+
+ ///
+ /// Gets the variance of the distribution.
+ ///
+ public double Variance
+ {
+ get { return (mUpper - mLower)*(mUpper - mLower)/12.0; }
+ }
+
+ ///
+ /// Gets the standard deviation of the distribution.
+ ///
+ public double StdDev
+ {
+ get { return (mUpper - mLower) / System.Math.Sqrt(12.0); }
+ }
+
+ ///
+ /// Gets the entropy of the distribution.
+ ///
+ ///
+ public double Entropy
+ {
+ get { return System.Math.Log(mUpper - mLower); }
+ }
+
+ ///
+ /// Gets the skewness of the distribution.
+ ///
+ public double Skewness
+ {
+ get { return 0.0; }
+ }
+ #endregion
+
+ #region IContinuousDistribution Members
+
+ ///
+ /// Gets the mode of the distribution.
+ ///
+ ///
+ public double Mode
+ {
+ get { return (mLower + mUpper)/2.0; }
+ }
+
+ ///
+ /// Gets the median of the distribution.
+ ///
+ ///
+ public double Median
+ {
+ get { return (mLower + mUpper)/2.0; }
+ }
+
+ ///
+ /// Gets the minimum of the distribution.
+ ///
+ public double Minimum
+ {
+ get { return mLower; }
+ }
+
+ ///
+ /// Gets the maximum of the distribution.
+ ///
+ public double Maximum
+ {
+ get { return mUpper; }
+ }
+
+ ///
+ /// Computes the density of the distribution.
+ ///
+ /// The location at which to compute the density.
+ /// the density at .
+ public double Density(double x)
+ {
+ if (x >= mLower && x <= mUpper)
+ {
+ return 1.0/(mUpper - mLower);
+ }
+
+ return 0.0;
+ }
+
+ ///
+ /// Computes the log density of the distribution.
+ ///
+ /// The location at which to compute the log density.
+ /// the log density at .
+ public double DensityLn(double x)
+ {
+ if (x >= mLower && x <= mUpper)
+ {
+ return -Math.Log(mUpper - mLower);
+ }
+
+ return Double.NegativeInfinity;
+ }
+
+ ///
+ /// Computes the cumulative distribution function of the distribution.
+ ///
+ /// The location at which to compute the cumulative density.
+ /// the cumulative density at .
+ public double CumulativeDistribution(double x)
+ {
+ if(x <= mLower)
+ {
+ return 0.0;
+ }
+ else if(x >= mUpper)
+ {
+ return 1.0;
+ }
+
+ return (x - mLower)/(mUpper - mLower);
+ }
+
+ ///
+ /// Generates a sample from the ContinuousUniform distribution.
+ ///
+ /// a sample from the distribution.
+ public double Sample()
+ {
+ return DoSample(RandomSource, mLower, mUpper);
+ }
+
+ ///
+ /// Generates a sequence of samples from the ContinuousUniform distribution.
+ ///
+ /// a sequence of samples from the distribution.
+ public IEnumerable Samples()
+ {
+ while(true)
+ {
+ yield return DoSample(RandomSource, mLower, mUpper);
+ }
+ }
+
+ #endregion
+
+ ///
+ /// Generates a sample from the ContinuousUniform distribution.
+ ///
+ /// The random number generator to use.
+ /// The lower bound of the uniform random variable.
+ /// The upper bound of the uniform random variable.
+ /// a uniformly distributed sample.
+ public static double Sample(System.Random rnd, double lower, double upper)
+ {
+ if (Control.CheckDistributionParameters && !IsValidParameterSet(lower, upper))
+ {
+ throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ }
+
+ return DoSample(rnd, lower, upper);
+ }
+
+ ///
+ /// Generates a sequence of samples from the ContinuousUniform distribution.
+ ///
+ /// The random number generator to use.
+ /// The lower bound of the uniform random variable.
+ /// The upper bound of the uniform random variable.
+ /// a sequence of uniformly distributed samples.
+ public static IEnumerable Samples(System.Random rnd, double lower, double upper)
+ {
+ if (Control.CheckDistributionParameters && !IsValidParameterSet(lower, upper))
+ {
+ throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ }
+
+ while(true)
+ {
+ yield return DoSample(rnd, lower, upper);
+ }
+ }
+
+ ///
+ /// Generates one sample from the ContinuousUniform distribution without parameter checking.
+ ///
+ /// The random number generator to use.
+ /// The lower bound of the uniform random variable.
+ /// The upper bound of the uniform random variable.
+ /// a uniformly distributed random number.
+ private static double DoSample(System.Random rnd, double lower, double upper)
+ {
+ return lower + (rnd.NextDouble()*(upper - lower));
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Managed/Distributions/Continuous/Normal.cs b/src/Managed/Distributions/Continuous/Normal.cs
index 6430686e..3f9de891 100644
--- a/src/Managed/Distributions/Continuous/Normal.cs
+++ b/src/Managed/Distributions/Continuous/Normal.cs
@@ -1,4 +1,4 @@
-//
+//
// Math.NET Numerics, part of the Math.NET Project
// http://mathnet.opensourcedotnet.info
//
@@ -30,11 +30,18 @@ namespace MathNet.Numerics.Distributions
{
using System;
using System.Collections.Generic;
+ using MathNet.Numerics;
+ using MathNet.Numerics.Properties;
///
/// Implements the univariate Normal (or Gaussian) distribution. For details about this distribution, see
/// Wikipedia - Normal distribution.
///
+ /// The distribution will use the by default.
+ /// Users can get/set the random number generator by using the property.
+ /// The statistics classes will check all the incoming parameters whether they are in the allowed
+ /// range. This might involve heavy computation. Optionally, by setting Control.CheckDistributionParameters
+ /// to false, all parameter checks can be turned off.
public class Normal : IContinuousDistribution
{
///
@@ -145,14 +152,14 @@ namespace MathNet.Numerics.Distributions
/// When the parameters don't pass the function.
private void SetParameters(double mean, double stddev)
{
- if (IsValidParameterSet(mean, stddev))
+ if (!Control.CheckDistributionParameters || IsValidParameterSet(mean, stddev))
{
mMean = mean;
mStdDev = stddev;
}
else
{
- throw new System.ArgumentOutOfRangeException("Invalid parameterization for the normal distribution.");
+ throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
}
}
@@ -343,6 +350,11 @@ namespace MathNet.Numerics.Distributions
/// a sample from the distribution.
public static double Sample(System.Random rng, double mean, double stddev)
{
+ if(Control.CheckDistributionParameters && !IsValidParameterSet(mean, stddev))
+ {
+ throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ }
+
double r2;
return mean + (stddev * SampleBoxMuller(rng, out r2));
}
@@ -356,13 +368,20 @@ namespace MathNet.Numerics.Distributions
/// a sequence of samples from the distribution.
public static IEnumerable Samples(System.Random rng, double mean, double stddev)
{
- double r2;
-
- while(true)
+ if (Control.CheckDistributionParameters && !IsValidParameterSet(mean, stddev))
{
- double r1 = SampleBoxMuller(rng, out r2);
- yield return mean + (stddev * r1);
- yield return mean + (stddev * r2);
+ throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
+ }
+ else
+ {
+ double r2;
+
+ while (true)
+ {
+ double r1 = SampleBoxMuller(rng, out r2);
+ yield return mean + (stddev * r1);
+ yield return mean + (stddev * r2);
+ }
}
}
diff --git a/src/Managed/Managed.csproj b/src/Managed/Managed.csproj
index 6b7e273b..c30cf220 100644
--- a/src/Managed/Managed.csproj
+++ b/src/Managed/Managed.csproj
@@ -47,6 +47,8 @@
+
+
diff --git a/src/Managed/Precision.cs b/src/Managed/Precision.cs
index f5bf016b..2458742d 100644
--- a/src/Managed/Precision.cs
+++ b/src/Managed/Precision.cs
@@ -1,4 +1,4 @@
-//
+//
// Math.NET Numerics, part of the Math.NET Project
// http://mathnet.opensourcedotnet.info
//
diff --git a/src/Managed/Properties/Resources.Designer.cs b/src/Managed/Properties/Resources.Designer.cs
index 85a80424..a79a8bf7 100644
--- a/src/Managed/Properties/Resources.Designer.cs
+++ b/src/Managed/Properties/Resources.Designer.cs
@@ -1,18 +1,17 @@
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
-// Runtime Version:4.0.20506.1
+// Runtime Version:2.0.50727.3074
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
//------------------------------------------------------------------------------
-namespace MathNet.Numerics.Properties
-{
+namespace MathNet.Numerics.Properties {
using System;
-
-
+
+
///
/// A strongly-typed resource class, for looking up localized strings, etc.
///
@@ -20,491 +19,412 @@ namespace MathNet.Numerics.Properties
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources
- {
-
+ internal class Resources {
+
private static global::System.Resources.ResourceManager resourceMan;
-
+
private static global::System.Globalization.CultureInfo resourceCulture;
-
+
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resources()
- {
+ internal Resources() {
}
-
+
///
/// Returns the cached ResourceManager instance used by this class.
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager
- {
- get
- {
- if (object.ReferenceEquals(resourceMan, null))
- {
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MathNet.Numerics.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
-
+
///
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture
- {
- get
- {
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
return resourceCulture;
}
- set
- {
+ set {
resourceCulture = value;
}
}
-
+
///
/// Looks up a localized string similar to The histogram does not contains the value {0}..
///
- internal static string ArgumentHistogramContainsNot
- {
- get
- {
+ internal static string ArgumentHistogramContainsNot {
+ get {
return ResourceManager.GetString("ArgumentHistogramContainsNot", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Value is expected to be between {0} and {1} (including {0} and {1})..
///
- internal static string ArgumentInIntervalXYInclusive
- {
- get
- {
+ internal static string ArgumentInIntervalXYInclusive {
+ get {
return ResourceManager.GetString("ArgumentInIntervalXYInclusive", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to The matrix indices must not be out of range of the given matrix..
///
- internal static string ArgumentMatrixIndexOutOfRange
- {
- get
- {
+ internal static string ArgumentMatrixIndexOutOfRange {
+ get {
return ResourceManager.GetString("ArgumentMatrixIndexOutOfRange", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Matrix must not be rank deficient..
///
- internal static string ArgumentMatrixNotRankDeficient
- {
- get
- {
+ internal static string ArgumentMatrixNotRankDeficient {
+ get {
return ResourceManager.GetString("ArgumentMatrixNotRankDeficient", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Matrix must not be singular..
///
- internal static string ArgumentMatrixNotSingular
- {
- get
- {
+ internal static string ArgumentMatrixNotSingular {
+ get {
return ResourceManager.GetString("ArgumentMatrixNotSingular", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Matrix column dimensions must agree..
///
- internal static string ArgumentMatrixSameColumnDimension
- {
- get
- {
+ internal static string ArgumentMatrixSameColumnDimension {
+ get {
return ResourceManager.GetString("ArgumentMatrixSameColumnDimension", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Matrix dimensions must agree..
///
- internal static string ArgumentMatrixSameDimensions
- {
- get
- {
+ internal static string ArgumentMatrixSameDimensions {
+ get {
return ResourceManager.GetString("ArgumentMatrixSameDimensions", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Matrix row dimensions must agree..
///
- internal static string ArgumentMatrixSameRowDimension
- {
- get
- {
+ internal static string ArgumentMatrixSameRowDimension {
+ get {
return ResourceManager.GetString("ArgumentMatrixSameRowDimension", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Matrix must have exactly one column..
///
- internal static string ArgumentMatrixSingleColumn
- {
- get
- {
+ internal static string ArgumentMatrixSingleColumn {
+ get {
return ResourceManager.GetString("ArgumentMatrixSingleColumn", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Matrix must have exactly one column and row, thus have only one cell..
///
- internal static string ArgumentMatrixSingleColumnRow
- {
- get
- {
+ internal static string ArgumentMatrixSingleColumnRow {
+ get {
return ResourceManager.GetString("ArgumentMatrixSingleColumnRow", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Matrix must have exactly one row..
///
- internal static string ArgumentMatrixSingleRow
- {
- get
- {
+ internal static string ArgumentMatrixSingleRow {
+ get {
return ResourceManager.GetString("ArgumentMatrixSingleRow", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Matrix must be square..
///
- internal static string ArgumentMatrixSquare
- {
- get
- {
+ internal static string ArgumentMatrixSquare {
+ get {
return ResourceManager.GetString("ArgumentMatrixSquare", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Matrix must be symmetric..
///
- internal static string ArgumentMatrixSymmetric
- {
- get
- {
+ internal static string ArgumentMatrixSymmetric {
+ get {
return ResourceManager.GetString("ArgumentMatrixSymmetric", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Matrix must be symmetric positive definite..
///
- internal static string ArgumentMatrixSymmetricPositiveDefinite
- {
- get
- {
+ internal static string ArgumentMatrixSymmetricPositiveDefinite {
+ get {
return ResourceManager.GetString("ArgumentMatrixSymmetricPositiveDefinite", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Value must neither be infinite nor NaN..
///
- internal static string ArgumentNotInfinityNaN
- {
- get
- {
+ internal static string ArgumentNotInfinityNaN {
+ get {
return ResourceManager.GetString("ArgumentNotInfinityNaN", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Value must not be negative (zero is ok)..
///
- internal static string ArgumentNotNegative
- {
- get
- {
+ internal static string ArgumentNotNegative {
+ get {
return ResourceManager.GetString("ArgumentNotNegative", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to {0} is a null reference (Nothing in Visual Basic)..
///
- internal static string ArgumentNull
- {
- get
- {
+ internal static string ArgumentNull {
+ get {
return ResourceManager.GetString("ArgumentNull", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to {0} must be greater than {1}..
///
- internal static string ArgumentOutOfRangeGreater
- {
- get
- {
+ internal static string ArgumentOutOfRangeGreater {
+ get {
return ResourceManager.GetString("ArgumentOutOfRangeGreater", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to {0} must be greater than or equal to {1}..
///
- internal static string ArgumentOutOfRangeGreaterEqual
- {
- get
- {
+ internal static string ArgumentOutOfRangeGreaterEqual {
+ get {
return ResourceManager.GetString("ArgumentOutOfRangeGreaterEqual", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to The chosen parameter set is invalid (probably some value is out of range)..
///
- internal static string ArgumentParameterSetInvalid
- {
- get
- {
+ internal static string ArgumentParameterSetInvalid {
+ get {
return ResourceManager.GetString("ArgumentParameterSetInvalid", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to The given expression does not represent a complex number..
///
- internal static string ArgumentParseComplexNumber
- {
- get
- {
+ internal static string ArgumentParseComplexNumber {
+ get {
return ResourceManager.GetString("ArgumentParseComplexNumber", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Value must be positive (and not zero)..
///
- internal static string ArgumentPositive
- {
- get
- {
+ internal static string ArgumentPositive {
+ get {
return ResourceManager.GetString("ArgumentPositive", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Size must be a Power of Two..
///
- internal static string ArgumentPowerOfTwo
- {
- get
- {
+ internal static string ArgumentPowerOfTwo {
+ get {
return ResourceManager.GetString("ArgumentPowerOfTwo", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Size must be a Power of Two in every dimension..
///
- internal static string ArgumentPowerOfTwoEveryDimension
- {
- get
- {
+ internal static string ArgumentPowerOfTwoEveryDimension {
+ get {
return ResourceManager.GetString("ArgumentPowerOfTwoEveryDimension", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to The range between {0} and {1} must be less than or equal to {2}..
///
- internal static string ArgumentRangeLessEqual
- {
- get
- {
+ internal static string ArgumentRangeLessEqual {
+ get {
return ResourceManager.GetString("ArgumentRangeLessEqual", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Array must have exactly one dimension (and not be null)..
///
- internal static string ArgumentSingleDimensionArray
- {
- get
- {
+ internal static string ArgumentSingleDimensionArray {
+ get {
return ResourceManager.GetString("ArgumentSingleDimensionArray", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Value is too large..
///
- internal static string ArgumentTooLarge
- {
- get
- {
+ internal static string ArgumentTooLarge {
+ get {
return ResourceManager.GetString("ArgumentTooLarge", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Value is too large for the current iteration limit..
///
- internal static string ArgumentTooLargeForIterationLimit
- {
- get
- {
+ internal static string ArgumentTooLargeForIterationLimit {
+ get {
return ResourceManager.GetString("ArgumentTooLargeForIterationLimit", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Type mismatch..
///
- internal static string ArgumentTypeMismatch
- {
- get
- {
+ internal static string ArgumentTypeMismatch {
+ get {
return ResourceManager.GetString("ArgumentTypeMismatch", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Array length must be a multiple of {0}..
///
- internal static string ArgumentVectorLengthsMultipleOf
- {
- get
- {
+ internal static string ArgumentVectorLengthsMultipleOf {
+ get {
return ResourceManager.GetString("ArgumentVectorLengthsMultipleOf", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to All vectors must have the same dimensionality..
///
- internal static string ArgumentVectorsSameLengths
- {
- get
- {
+ internal static string ArgumentVectorsSameLengths {
+ get {
return ResourceManager.GetString("ArgumentVectorsSameLengths", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to The vector must have 3 dimensions..
///
- internal static string ArgumentVectorThreeDimensional
- {
- get
- {
+ internal static string ArgumentVectorThreeDimensional {
+ get {
return ResourceManager.GetString("ArgumentVectorThreeDimensional", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to This feature is not implemented yet (but is planned)..
///
- internal static string FeaturePlannedButNotImplementedYet
- {
- get
- {
+ internal static string FeaturePlannedButNotImplementedYet {
+ get {
return ResourceManager.GetString("FeaturePlannedButNotImplementedYet", resourceCulture);
}
}
-
+
+ ///
+ /// Looks up a localized string similar to Invalid parameterization for the distribution..
+ ///
+ internal static string InvalidDistributionParameters {
+ get {
+ return ResourceManager.GetString("InvalidDistributionParameters", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Invalid Left Boundary Condition..
///
- internal static string InvalidLeftBoundaryCondition
- {
- get
- {
+ internal static string InvalidLeftBoundaryCondition {
+ get {
return ResourceManager.GetString("InvalidLeftBoundaryCondition", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to The operation could not be performed because the accumulator is empty..
///
- internal static string InvalidOperationAccumulatorEmpty
- {
- get
- {
+ internal static string InvalidOperationAccumulatorEmpty {
+ get {
return ResourceManager.GetString("InvalidOperationAccumulatorEmpty", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to The operation could not be performed because the histogram is empty..
///
- internal static string InvalidOperationHistogramEmpty
- {
- get
- {
+ internal static string InvalidOperationHistogramEmpty {
+ get {
return ResourceManager.GetString("InvalidOperationHistogramEmpty", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Not enough points in the distribution..
///
- internal static string InvalidOperationHistogramNotEnoughPoints
- {
- get
- {
+ internal static string InvalidOperationHistogramNotEnoughPoints {
+ get {
return ResourceManager.GetString("InvalidOperationHistogramNotEnoughPoints", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to No Samples Provided. Preparation Required..
///
- internal static string InvalidOperationNoSamplesProvided
- {
- get
- {
+ internal static string InvalidOperationNoSamplesProvided {
+ get {
return ResourceManager.GetString("InvalidOperationNoSamplesProvided", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Invalid Right Boundary Condition..
///
- internal static string InvalidRightBoundaryCondition
- {
- get
- {
+ internal static string InvalidRightBoundaryCondition {
+ get {
return ResourceManager.GetString("InvalidRightBoundaryCondition", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to This special case is not supported yet (but is planned)..
///
- internal static string SpecialCasePlannedButNotImplementedYet
- {
- get
- {
+ internal static string SpecialCasePlannedButNotImplementedYet {
+ get {
return ResourceManager.GetString("SpecialCasePlannedButNotImplementedYet", resourceCulture);
}
}
diff --git a/src/Managed/Properties/Resources.resx b/src/Managed/Properties/Resources.resx
index d34c3b9b..80fa917f 100644
--- a/src/Managed/Properties/Resources.resx
+++ b/src/Managed/Properties/Resources.resx
@@ -237,4 +237,7 @@
This special case is not supported yet (but is planned).
+
+ Invalid parameterization for the distribution.
+
\ No newline at end of file
diff --git a/src/Managed/SiPrefixes.cs b/src/Managed/SiPrefixes.cs
index 6f4d4e8d..1e5ea63f 100644
--- a/src/Managed/SiPrefixes.cs
+++ b/src/Managed/SiPrefixes.cs
@@ -35,64 +35,64 @@ namespace MathNet.Numerics
///
public static class SiPrefixes
{
- /// 1 000 000 000 000 000 000 000 000
+ /// The SI prefix factor corresponding to 1 000 000 000 000 000 000 000 000
public const double Yotta = 1e24;
- /// 1 000 000 000 000 000 000 000
+ /// The SI prefix factor corresponding to 1 000 000 000 000 000 000 000
public const double Zetta = 1e21;
- /// 1 000 000 000 000 000 000
+ /// The SI prefix factor corresponding to 1 000 000 000 000 000 000
public const double Exa = 1e18;
- /// 1 000 000 000 000 000
+ /// The SI prefix factor corresponding to 1 000 000 000 000 000
public const double Peta = 1e15;
- /// 1 000 000 000 000
+ /// The SI prefix factor corresponding to 1 000 000 000 000
public const double Tera = 1e12;
- /// 1 000 000 000
+ /// The SI prefix factor corresponding to 1 000 000 000
public const double Giga = 1e9;
- /// 1 000 000
+ /// The SI prefix factor corresponding to 1 000 000
public const double Mega = 1e6;
- /// 1 000
+ /// The SI prefix factor corresponding to 1 000
public const double Kilo = 1e3;
- /// 100
+ /// The SI prefix factor corresponding to 100
public const double Hecto = 1e2;
- /// 10
+ /// The SI prefix factor corresponding to 10
public const double Deca = 1e1;
- /// 0.1
+ /// The SI prefix factor corresponding to 0.1
public const double Deci = 1e-1;
- /// 0.01
+ /// The SI prefix factor corresponding to 0.01
public const double Centi = 1e-2;
- /// 0.001
+ /// The SI prefix factor corresponding to 0.001
public const double Milli = 1e-3;
- /// 0.000 001
+ /// The SI prefix factor corresponding to 0.000 001
public const double Micro = 1e-6;
- /// 0.000 000 001
+ /// The SI prefix factor corresponding to 0.000 000 001
public const double Nano = 1e-9;
- /// 0.000 000 000 001
+ /// The SI prefix factor corresponding to 0.000 000 000 001
public const double Pico = 1e-12;
- /// 0.000 000 000 000 001
+ /// The SI prefix factor corresponding to 0.000 000 000 000 001
public const double Femto = 1e-15;
- /// 0.000 000 000 000 000 001
+ /// The SI prefix factor corresponding to 0.000 000 000 000 000 001
public const double Atto = 1e-18;
- /// 0.000 000 000 000 000 000 001
+ /// The SI prefix factor corresponding to 0.000 000 000 000 000 000 001
public const double Zepto = 1e-21;
- /// 0.000 000 000 000 000 000 000 001
+ /// The SI prefix factor corresponding to 0.000 000 000 000 000 000 000 001
public const double Yocto = 1e-24;
}
}
diff --git a/src/Managed/SpecialFunctions.cs b/src/Managed/SpecialFunctions.cs
index 931c82fd..2f5f5dd2 100644
--- a/src/Managed/SpecialFunctions.cs
+++ b/src/Managed/SpecialFunctions.cs
@@ -1,4 +1,4 @@
-//
+//
// Math.NET Numerics, part of the Math.NET Project
// http://mathnet.opensourcedotnet.info
//
diff --git a/src/Native.UnitTests/Native.UnitTests.csproj b/src/Native.UnitTests/Native.UnitTests.csproj
index 3b5a099a..ca324d9a 100644
--- a/src/Native.UnitTests/Native.UnitTests.csproj
+++ b/src/Native.UnitTests/Native.UnitTests.csproj
@@ -66,6 +66,9 @@
ComplexTest.cs
+
+ DistributionTests\Continuous\ContinuousUniformTests.cs
+
DistributionTests\Continuous\NormalTests.cs
diff --git a/src/Native/Native.csproj b/src/Native/Native.csproj
index e9e068f9..d93a1743 100644
--- a/src/Native/Native.csproj
+++ b/src/Native/Native.csproj
@@ -50,6 +50,12 @@
Constants.cs
+
+ Control.cs
+
+
+ Distributions\Continuous\ContinuousUniform.cs
+
Distributions\Continuous\Normal.cs