Browse Source

Fixed StyleCop warnings.

Added ContinuousDistribution class.
Added ContinuousDistribution unit tests.
Added more unit tests in Normal class.
Added Control class with property to check distribution parameters.
Tried to fix the StyleCop header warnings by changing the file encoding but didn't seem to work all that well.

Signed-off-by: Christoph Ruegg <git@cdrnet.ch>
pull/36/head
Jurgen Van Gael 17 years ago
committed by Christoph Ruegg
parent
commit
4e22ba370d
  1. 339
      src/Managed.UnitTests/DistributionTests/Continuous/ContinuousUniformTests.cs
  2. 48
      src/Managed.UnitTests/DistributionTests/Continuous/NormalTests.cs
  3. 1
      src/Managed.UnitTests/Managed.UnitTests.csproj
  4. 2
      src/Managed/Combinatorics.cs
  5. 2
      src/Managed/Complex.cs
  6. 70
      src/Managed/Constants.cs
  7. 63
      src/Managed/Control.cs
  8. 361
      src/Managed/Distributions/Continuous/ContinuousUniform.cs
  9. 37
      src/Managed/Distributions/Continuous/Normal.cs
  10. 2
      src/Managed/Managed.csproj
  11. 2
      src/Managed/Precision.cs
  12. 374
      src/Managed/Properties/Resources.Designer.cs
  13. 3
      src/Managed/Properties/Resources.resx
  14. 40
      src/Managed/SiPrefixes.cs
  15. 2
      src/Managed/SpecialFunctions.cs
  16. 3
      src/Native.UnitTests/Native.UnitTests.csproj
  17. 6
      src/Native/Native.csproj

339
src/Managed.UnitTests/DistributionTests/Continuous/ContinuousUniformTests.cs

@ -0,0 +1,339 @@
// <copyright file="ContinuousUniformTests.cs" company="Math.NET">
// 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.
// </copyright>
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<double>(0.0, n.Lower);
AssertEx.AreEqual<double>(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<double>(lower, n.Lower);
AssertEx.AreEqual<double>(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<string>("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<double>(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<double>(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<double>( (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<double>((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<double>(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<double>(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<double>(1.0 / (upper - lower), n.Density(x));
}
else
{
AssertEx.AreEqual<double>(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<double>(-Math.Log(upper - lower), n.DensityLn(x));
}
else
{
AssertEx.AreEqual<double>(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<double>(0.0, n.CumulativeDistribution(x));
}
else if (x >= upper)
{
AssertEx.AreEqual<double>(1.0, n.CumulativeDistribution(x));
}
else
{
AssertEx.AreEqual<double>((x - lower) / (upper - lower), n.CumulativeDistribution(x));
}
}
}
}
}

48
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<string>("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]

1
src/Managed.UnitTests/Managed.UnitTests.csproj

@ -60,6 +60,7 @@
<Compile Include="AssertHelpers.cs" />
<Compile Include="CombinatoricsTests\CombinatoricsCountingTest.cs" />
<Compile Include="ComplexTest.cs" />
<Compile Include="DistributionTests\Continuous\ContinuousUniformTests.cs" />
<Compile Include="DistributionTests\Continuous\NormalTests.cs" />
<Compile Include="PrecisionTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

2
src/Managed/Combinatorics.cs

@ -1,4 +1,4 @@
// <copyright file="Combinatorics.cs" company="Math.NET">
// <copyright file="Combinatorics.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://mathnet.opensourcedotnet.info
//

2
src/Managed/Complex.cs

@ -1,4 +1,4 @@
// <copyright file="Complex.cs" company="Math.NET">
// <copyright file="Complex.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://mathnet.opensourcedotnet.info
//

70
src/Managed/Constants.cs

@ -35,107 +35,107 @@ namespace MathNet.Numerics
/// <seealso cref="SiPrefixes"/>
public static class Constants
{
/// <summary>e</summary>
/// <summary>The number e</summary>
public const double E = 2.7182818284590452353602874713526624977572470937000d;
/// <summary>log[2](e)</summary>
/// <summary>The number log[2](e)</summary>
public const double Log2E = 1.4426950408889634073599246810018921374266459541530d;
/// <summary>log[10](e)</summary>
/// <summary>The number log[10](e)</summary>
public const double Log10E = 0.43429448190325182765112891891660508229439700580366d;
/// <summary>log[e](2)</summary>
/// <summary>The number log[e](2)</summary>
public const double Ln2 = 0.69314718055994530941723212145817656807550013436026d;
/// <summary>log[e](10)</summary>
/// <summary>The number log[e](10)</summary>
public const double Ln10 = 2.3025850929940456840179914546843642076011014886288d;
/// <summary>log[e](pi)</summary>
/// <summary>The number log[e](pi)</summary>
public const double LnPi = 1.1447298858494001741434273513530587116472948129153d;
/// <summary>log[e](2*pi)/2</summary>
/// <summary>The number log[e](2*pi)/2</summary>
public const double Ln2PiOver2 = 0.91893853320467274178032973640561763986139747363780d;
/// <summary>1/e</summary>
/// <summary>The number 1/e</summary>
public const double InvE = 0.36787944117144232159552377016146086744581113103176d;
/// <summary>sqrt(e)</summary>
/// <summary>The number sqrt(e)</summary>
public const double SqrtE = 1.6487212707001281468486507878141635716537761007101d;
/// <summary>sqrt(2)</summary>
/// <summary>The number sqrt(2)</summary>
public const double Sqrt2 = 1.4142135623730950488016887242096980785696718753769d;
/// <summary>sqrt(1/2) = 1/sqrt(2) = sqrt(2)/2</summary>
/// <summary>The number sqrt(1/2) = 1/sqrt(2) = sqrt(2)/2</summary>
public const double Sqrt1Over2 = 0.70710678118654752440084436210484903928483593768845d;
/// <summary>sqrt(3)/2</summary>
/// <summary>The number sqrt(3)/2</summary>
public const double HalfSqrt3 = 0.86602540378443864676372317075293618347140262690520d;
/// <summary>pi</summary>
/// <summary>The number pi</summary>
public const double Pi = 3.1415926535897932384626433832795028841971693993751d;
/// <summary>1/pi</summary>
/// <summary>The number 1/pi</summary>
public const double OneOverPi = 0.31830988618379067153776752674502872406891929148091d;
/// <summary>pi/2</summary>
/// <summary>The number pi/2</summary>
public const double PiOver2 = 1.5707963267948966192313216916397514420985846996876d;
/// <summary>pi/4</summary>
/// <summary>The number pi/4</summary>
public const double PiOver4 = 0.78539816339744830961566084581987572104929234984378d;
/// <summary>sqrt(pi)</summary>
/// <summary>The number sqrt(pi)</summary>
public const double SqrtPi = 1.7724538509055160272981674833411451827975494561224d;
/// <summary>sqrt(2pi)</summary>
/// <summary>The number sqrt(2pi)</summary>
public const double Sqrt2Pi = 2.5066282746310005024157652848110452530069867406099d;
/// <summary> sqrt(2*pi*e)</summary>
/// <summary>The number sqrt(2*pi*e)</summary>
public const double Sqrt2PiE = 4.1327313541224929384693918842998526494455219169913d;
/// <summary> log(sqrt(2*pi))</summary>
/// <summary>The number log(sqrt(2*pi))</summary>
public const double LogSqrt2Pi = 0.91893853320467274178032973640561763986139747363778;
/// <summary>log(sqrt(2*pi*e))</summary>
/// <summary>The number log(sqrt(2*pi*e))</summary>
public const double LogSqrt2PiE = 1.4189385332046727417803297364056176398613974736378d;
/// <summary>1/pi</summary>
/// <summary>The number 1/pi</summary>
public const double InvPi = 0.31830988618379067153776752674502872406891929148091d;
/// <summary>2/pi</summary>
/// <summary>The number 2/pi</summary>
public const double TwoInvPi = 0.63661977236758134307553505349005744813783858296182d;
/// <summary>1/sqrt(pi)</summary>
/// <summary>The number 1/sqrt(pi)</summary>
public const double InvSqrtPi = 0.56418958354775628694807945156077258584405062932899d;
/// <summary>1/sqrt(2pi)</summary>
/// <summary>The number 1/sqrt(2pi)</summary>
public const double InvSqrt2Pi = 0.39894228040143267793994605993438186847585863116492d;
/// <summary>2/sqrt(pi)</summary>
/// <summary>The number 2/sqrt(pi)</summary>
public const double TwoInvSqrtPi = 1.1283791670955125738961589031215451716881012586580d;
/// <summary>(pi)/180 - factor to convert from Degree (deg) to Radians (rad).</summary>
/// <summary>The number (pi)/180 - factor to convert from Degree (deg) to Radians (rad).</summary>
/// <seealso cref="Trig.DegreeToRadian"/>
/// <seealso cref="Trig.RadianToDegree"/>
public const double Degree = 0.017453292519943295769236907684886127134428718885417d;
/// <summary>(pi)/200 - factor to convert from NewGrad (grad) to Radians (rad).</summary>
/// <summary>The number (pi)/200 - factor to convert from NewGrad (grad) to Radians (rad).</summary>
/// <seealso cref="Trig.GradToRadian"/>
/// <seealso cref="Trig.RadianToGrad"/>
public const double Grad = 0.015707963267948966192313216916397514420985846996876d;
/// <summary>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).</summary>
/// <summary>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).</summary>
/// <seealso cref="Ratios.RatioToPowerDecibel(double)"/>
/// <seealso cref="Ratios.PowerDecibelToRatio"/>
/// <seealso cref="Ratios.PowerDecibelToValue"/>
public const double PowerDecibel = 0.11512925464970228420089957273421821038005507443144d;
/// <summary>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.</summary>
/// <summary>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.</summary>
/// <seealso cref="Ratios.RatioToDecibel(double)"/>
/// <seealso cref="Ratios.DecibelToRatio"/>
/// <seealso cref="Ratios.DecibelToValue"/>
public const double NeutralDecibel = 0.23025850929940456840179914546843642076011014886288d;
/// <summary>Catalan constant</summary>
/// <summary>The Catalan constant</summary>
/// <remarks>Sum(k=0 -> inf){ (-1)^k/(2*k + 1)2 }</remarks>
public const double Catalan = 0.9159655941772190150546035149323841107741493742816721342664981196217630197762547694794d;
@ -143,14 +143,14 @@ namespace MathNet.Numerics
/// <remarks>lim(n -> inf){ Sum(k=1 -> n) { 1/k - log(n) } }</remarks>
public const double EulerMascheroni = 0.5772156649015328606065120900824024310421593359399235988057672348849d;
/// <summary>(1+sqrt(5))/2</summary>
/// <summary>The number (1+sqrt(5))/2, also known as the golden ratio</summary>
public const double GoldenRatio = 1.6180339887498948482045868343656381177203091798057628621354486227052604628189024497072d;
/// <summary>Glaisher Constant</summary>
/// <summary>The Glaisher constant</summary>
/// <remarks>e^(1/12 - Zeta(-1))</remarks>
public const double Glaisher = 1.2824271291006226368753425688697917277676889273250011920637400217404063088588264611297d;
/// <summary>Khinchin constant</summary>
/// <summary>The Khinchin constant</summary>
/// <remarks>prod(k=1 -> inf){1+1/(k*(k+2))^log(k,2)}</remarks>
public const double Khinchin = 2.6854520010653064453097148354817956938203822939944629530511523455572188595371520028011d;
}

63
src/Managed/Control.cs

@ -0,0 +1,63 @@
// <copyright file="ContinuousUniformTests.cs" company="Math.NET">
// 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.
// </copyright>
namespace MathNet.Numerics
{
using System;
/// <summary>
/// Sets parameters for the library.
/// </summary>
public static partial class Control
{
/// <summary>
/// Initializes static members of the Control class.
/// </summary>
static Control()
{
CheckDistributionParameters = true;
ThreadSafeRandomNumberGenerators = true;
}
/// <summary>
/// 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.
/// </summary>
public static bool CheckDistributionParameters { get; set; }
/// <summary>
/// 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.
/// </summary>
/// <value>
/// <c>true</c> to use thread safe random number generators ; otherwise, <c>false</c>.
/// </value>
public static bool ThreadSafeRandomNumberGenerators { get; set; }
}
}

361
src/Managed/Distributions/Continuous/ContinuousUniform.cs

@ -0,0 +1,361 @@
// <copyright file="ContinuousUniform.cs" company="Math.NET">
// 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.
// </copyright>
namespace MathNet.Numerics.Distributions
{
using System;
using System.Collections.Generic;
using MathNet.Numerics.Properties;
/// <summary>
/// The continuous uniform distribution is a distribution over real numbers. For details about this distribution, see
/// <a href="http://en.wikipedia.org/wiki/Uniform_distribution_%28continuous%29">Wikipedia - Continuous uniform distribution</a>.
/// </summary>
/// <remarks><para>The distribution will use the <see cref="System.Random"/> by default.
/// Users can get/set the random number generator by using the <see cref="RandomSource"/> property.</para>
/// <para>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.</para></remarks>
public class ContinuousUniform : IContinuousDistribution
{
/// <summary>
/// The distribution's lower bound.
/// </summary>
private double mLower;
/// <summary>
/// The distribution's upper bound.
/// </summary>
private double mUpper;
/// <summary>
/// Initializes a new instance of the ContinuousUniform class with lower bound 0 and upper bound 1.
/// </summary>
public ContinuousUniform() : this(0.0, 1.0)
{
}
/// <summary>
/// Initializes a new instance of the ContinuousUniform class with given lower and upper bounds.
/// </summary>
/// <param name="lower">Lower bound.</param>
/// <param name="upper">Upper bound; must be at least as large as <paramref name="lower"/>.</param>
/// <exception cref="ArgumentException">If the upper bound is smaller than the lower bound.</exception>
public ContinuousUniform(double lower, double upper)
{
SetParameters(lower, upper);
RandomSource = new System.Random();
}
/// <summary>
/// A string representation of the distribution.
/// </summary>
/// <returns>a string representation of the distribution.</returns>
public override string ToString()
{
return "ContinuousUniform(Lower = " + mLower + ", Upper = " + mUpper + ")";
}
/// <summary>
/// Checks whether the parameters of the distribution are valid.
/// </summary>
/// <param name="lower">Lower bound.</param>
/// <param name="upper">Upper bound; must be at least as large as <paramref name="lower"/>.</param>
/// <returns>True when the parameters are valid, false otherwise.</returns>
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;
}
/// <summary>
/// Sets the parameters of the distribution after checking their validity.
/// </summary>
/// <param name="lower">Lower bound.</param>
/// <param name="upper">Upper bound; must be at least as large as <paramref name="lower"/>.</param>
/// <exception cref="ArgumentOutOfRangeException">When the parameters don't pass the <see cref="IsValidParameterSet"/> function.</exception>
private void SetParameters(double lower, double upper)
{
if (!Control.CheckDistributionParameters || IsValidParameterSet(lower, upper))
{
mLower = lower;
mUpper = upper;
}
else
{
throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
}
}
/// <summary>
/// Gets or sets the lower bound of the distribution.
/// </summary>
public double Lower
{
get
{
return mLower;
}
set
{
SetParameters(value, mUpper);
}
}
/// <summary>
/// Gets or sets the upper bound of the distribution.
/// </summary>
public double Upper
{
get
{
return mUpper;
}
set
{
SetParameters(mLower, value);
}
}
#region IDistribution Members
/// <summary>
/// Gets or sets the random number generator which is used to draw random samples.
/// </summary>
public Random RandomSource { get; set; }
/// <summary>
/// Gets the mean of the distribution.
/// </summary>
public double Mean
{
get { return (mLower + mUpper)/2.0; }
}
/// <summary>
/// Gets the variance of the distribution.
/// </summary>
public double Variance
{
get { return (mUpper - mLower)*(mUpper - mLower)/12.0; }
}
/// <summary>
/// Gets the standard deviation of the distribution.
/// </summary>
public double StdDev
{
get { return (mUpper - mLower) / System.Math.Sqrt(12.0); }
}
/// <summary>
/// Gets the entropy of the distribution.
/// </summary>
/// <value></value>
public double Entropy
{
get { return System.Math.Log(mUpper - mLower); }
}
/// <summary>
/// Gets the skewness of the distribution.
/// </summary>
public double Skewness
{
get { return 0.0; }
}
#endregion
#region IContinuousDistribution Members
/// <summary>
/// Gets the mode of the distribution.
/// </summary>
/// <value></value>
public double Mode
{
get { return (mLower + mUpper)/2.0; }
}
/// <summary>
/// Gets the median of the distribution.
/// </summary>
/// <value></value>
public double Median
{
get { return (mLower + mUpper)/2.0; }
}
/// <summary>
/// Gets the minimum of the distribution.
/// </summary>
public double Minimum
{
get { return mLower; }
}
/// <summary>
/// Gets the maximum of the distribution.
/// </summary>
public double Maximum
{
get { return mUpper; }
}
/// <summary>
/// Computes the density of the distribution.
/// </summary>
/// <param name="x">The location at which to compute the density.</param>
/// <returns>the density at <paramref name="x"/>.</returns>
public double Density(double x)
{
if (x >= mLower && x <= mUpper)
{
return 1.0/(mUpper - mLower);
}
return 0.0;
}
/// <summary>
/// Computes the log density of the distribution.
/// </summary>
/// <param name="x">The location at which to compute the log density.</param>
/// <returns>the log density at <paramref name="x"/>.</returns>
public double DensityLn(double x)
{
if (x >= mLower && x <= mUpper)
{
return -Math.Log(mUpper - mLower);
}
return Double.NegativeInfinity;
}
/// <summary>
/// Computes the cumulative distribution function of the distribution.
/// </summary>
/// <param name="x">The location at which to compute the cumulative density.</param>
/// <returns>the cumulative density at <paramref name="x"/>.</returns>
public double CumulativeDistribution(double x)
{
if(x <= mLower)
{
return 0.0;
}
else if(x >= mUpper)
{
return 1.0;
}
return (x - mLower)/(mUpper - mLower);
}
/// <summary>
/// Generates a sample from the ContinuousUniform distribution.
/// </summary>
/// <returns>a sample from the distribution.</returns>
public double Sample()
{
return DoSample(RandomSource, mLower, mUpper);
}
/// <summary>
/// Generates a sequence of samples from the ContinuousUniform distribution.
/// </summary>
/// <returns>a sequence of samples from the distribution.</returns>
public IEnumerable<double> Samples()
{
while(true)
{
yield return DoSample(RandomSource, mLower, mUpper);
}
}
#endregion
/// <summary>
/// Generates a sample from the ContinuousUniform distribution.
/// </summary>
/// <param name="rnd">The random number generator to use.</param>
/// <param name="lower">The lower bound of the uniform random variable.</param>
/// <param name="upper">The upper bound of the uniform random variable.</param>
/// <returns>a uniformly distributed sample.</returns>
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);
}
/// <summary>
/// Generates a sequence of samples from the ContinuousUniform distribution.
/// </summary>
/// <param name="rnd">The random number generator to use.</param>
/// <param name="lower">The lower bound of the uniform random variable.</param>
/// <param name="upper">The upper bound of the uniform random variable.</param>
/// <returns>a sequence of uniformly distributed samples.</returns>
public static IEnumerable<double> 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);
}
}
/// <summary>
/// Generates one sample from the ContinuousUniform distribution without parameter checking.
/// </summary>
/// <param name="rnd">The random number generator to use.</param>
/// <param name="lower">The lower bound of the uniform random variable.</param>
/// <param name="upper">The upper bound of the uniform random variable.</param>
/// <returns>a uniformly distributed random number.</returns>
private static double DoSample(System.Random rnd, double lower, double upper)
{
return lower + (rnd.NextDouble()*(upper - lower));
}
}
}

37
src/Managed/Distributions/Continuous/Normal.cs

@ -1,4 +1,4 @@
// <copyright file="Normal.cs" company="Math.NET">
// <copyright file="Normal.cs" company="Math.NET">
// 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;
/// <summary>
/// Implements the univariate Normal (or Gaussian) distribution. For details about this distribution, see
/// <a href="http://en.wikipedia.org/wiki/Normal_distribution">Wikipedia - Normal distribution</a>.
/// </summary>
/// <remarks><para>The distribution will use the <see cref="System.Random"/> by default.
/// Users can get/set the random number generator by using the <see cref="RandomSource"/> property.</para>
/// <para>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.</para></remarks>
public class Normal : IContinuousDistribution
{
/// <summary>
@ -145,14 +152,14 @@ namespace MathNet.Numerics.Distributions
/// <exception cref="ArgumentOutOfRangeException">When the parameters don't pass the <see cref="IsValidParameterSet"/> function.</exception>
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
/// <returns>a sample from the distribution.</returns>
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
/// <returns>a sequence of samples from the distribution.</returns>
public static IEnumerable<double> 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);
}
}
}

2
src/Managed/Managed.csproj

@ -47,6 +47,8 @@
<Compile Include="Combinatorics.cs" />
<Compile Include="Complex.cs" />
<Compile Include="Constants.cs" />
<Compile Include="Control.cs" />
<Compile Include="Distributions\Continuous\ContinuousUniform.cs" />
<Compile Include="Distributions\Continuous\Normal.cs" />
<Compile Include="Distributions\Discrete\Bernoulli.cs" />
<Compile Include="Distributions\IContinuousDistribution.cs" />

2
src/Managed/Precision.cs

@ -1,4 +1,4 @@
// <copyright file="Precision.cs" company="Math.NET">
// <copyright file="Precision.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://mathnet.opensourcedotnet.info
//

374
src/Managed/Properties/Resources.Designer.cs

@ -1,18 +1,17 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MathNet.Numerics.Properties
{
namespace MathNet.Numerics.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
@ -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() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[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;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[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;
}
}
/// <summary>
/// Looks up a localized string similar to The histogram does not contains the value {0}..
/// </summary>
internal static string ArgumentHistogramContainsNot
{
get
{
internal static string ArgumentHistogramContainsNot {
get {
return ResourceManager.GetString("ArgumentHistogramContainsNot", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Value is expected to be between {0} and {1} (including {0} and {1})..
/// </summary>
internal static string ArgumentInIntervalXYInclusive
{
get
{
internal static string ArgumentInIntervalXYInclusive {
get {
return ResourceManager.GetString("ArgumentInIntervalXYInclusive", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The matrix indices must not be out of range of the given matrix..
/// </summary>
internal static string ArgumentMatrixIndexOutOfRange
{
get
{
internal static string ArgumentMatrixIndexOutOfRange {
get {
return ResourceManager.GetString("ArgumentMatrixIndexOutOfRange", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Matrix must not be rank deficient..
/// </summary>
internal static string ArgumentMatrixNotRankDeficient
{
get
{
internal static string ArgumentMatrixNotRankDeficient {
get {
return ResourceManager.GetString("ArgumentMatrixNotRankDeficient", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Matrix must not be singular..
/// </summary>
internal static string ArgumentMatrixNotSingular
{
get
{
internal static string ArgumentMatrixNotSingular {
get {
return ResourceManager.GetString("ArgumentMatrixNotSingular", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Matrix column dimensions must agree..
/// </summary>
internal static string ArgumentMatrixSameColumnDimension
{
get
{
internal static string ArgumentMatrixSameColumnDimension {
get {
return ResourceManager.GetString("ArgumentMatrixSameColumnDimension", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Matrix dimensions must agree..
/// </summary>
internal static string ArgumentMatrixSameDimensions
{
get
{
internal static string ArgumentMatrixSameDimensions {
get {
return ResourceManager.GetString("ArgumentMatrixSameDimensions", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Matrix row dimensions must agree..
/// </summary>
internal static string ArgumentMatrixSameRowDimension
{
get
{
internal static string ArgumentMatrixSameRowDimension {
get {
return ResourceManager.GetString("ArgumentMatrixSameRowDimension", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Matrix must have exactly one column..
/// </summary>
internal static string ArgumentMatrixSingleColumn
{
get
{
internal static string ArgumentMatrixSingleColumn {
get {
return ResourceManager.GetString("ArgumentMatrixSingleColumn", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Matrix must have exactly one column and row, thus have only one cell..
/// </summary>
internal static string ArgumentMatrixSingleColumnRow
{
get
{
internal static string ArgumentMatrixSingleColumnRow {
get {
return ResourceManager.GetString("ArgumentMatrixSingleColumnRow", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Matrix must have exactly one row..
/// </summary>
internal static string ArgumentMatrixSingleRow
{
get
{
internal static string ArgumentMatrixSingleRow {
get {
return ResourceManager.GetString("ArgumentMatrixSingleRow", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Matrix must be square..
/// </summary>
internal static string ArgumentMatrixSquare
{
get
{
internal static string ArgumentMatrixSquare {
get {
return ResourceManager.GetString("ArgumentMatrixSquare", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Matrix must be symmetric..
/// </summary>
internal static string ArgumentMatrixSymmetric
{
get
{
internal static string ArgumentMatrixSymmetric {
get {
return ResourceManager.GetString("ArgumentMatrixSymmetric", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Matrix must be symmetric positive definite..
/// </summary>
internal static string ArgumentMatrixSymmetricPositiveDefinite
{
get
{
internal static string ArgumentMatrixSymmetricPositiveDefinite {
get {
return ResourceManager.GetString("ArgumentMatrixSymmetricPositiveDefinite", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Value must neither be infinite nor NaN..
/// </summary>
internal static string ArgumentNotInfinityNaN
{
get
{
internal static string ArgumentNotInfinityNaN {
get {
return ResourceManager.GetString("ArgumentNotInfinityNaN", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Value must not be negative (zero is ok)..
/// </summary>
internal static string ArgumentNotNegative
{
get
{
internal static string ArgumentNotNegative {
get {
return ResourceManager.GetString("ArgumentNotNegative", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {0} is a null reference (Nothing in Visual Basic)..
/// </summary>
internal static string ArgumentNull
{
get
{
internal static string ArgumentNull {
get {
return ResourceManager.GetString("ArgumentNull", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {0} must be greater than {1}..
/// </summary>
internal static string ArgumentOutOfRangeGreater
{
get
{
internal static string ArgumentOutOfRangeGreater {
get {
return ResourceManager.GetString("ArgumentOutOfRangeGreater", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {0} must be greater than or equal to {1}..
/// </summary>
internal static string ArgumentOutOfRangeGreaterEqual
{
get
{
internal static string ArgumentOutOfRangeGreaterEqual {
get {
return ResourceManager.GetString("ArgumentOutOfRangeGreaterEqual", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The chosen parameter set is invalid (probably some value is out of range)..
/// </summary>
internal static string ArgumentParameterSetInvalid
{
get
{
internal static string ArgumentParameterSetInvalid {
get {
return ResourceManager.GetString("ArgumentParameterSetInvalid", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The given expression does not represent a complex number..
/// </summary>
internal static string ArgumentParseComplexNumber
{
get
{
internal static string ArgumentParseComplexNumber {
get {
return ResourceManager.GetString("ArgumentParseComplexNumber", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Value must be positive (and not zero)..
/// </summary>
internal static string ArgumentPositive
{
get
{
internal static string ArgumentPositive {
get {
return ResourceManager.GetString("ArgumentPositive", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Size must be a Power of Two..
/// </summary>
internal static string ArgumentPowerOfTwo
{
get
{
internal static string ArgumentPowerOfTwo {
get {
return ResourceManager.GetString("ArgumentPowerOfTwo", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Size must be a Power of Two in every dimension..
/// </summary>
internal static string ArgumentPowerOfTwoEveryDimension
{
get
{
internal static string ArgumentPowerOfTwoEveryDimension {
get {
return ResourceManager.GetString("ArgumentPowerOfTwoEveryDimension", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The range between {0} and {1} must be less than or equal to {2}..
/// </summary>
internal static string ArgumentRangeLessEqual
{
get
{
internal static string ArgumentRangeLessEqual {
get {
return ResourceManager.GetString("ArgumentRangeLessEqual", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Array must have exactly one dimension (and not be null)..
/// </summary>
internal static string ArgumentSingleDimensionArray
{
get
{
internal static string ArgumentSingleDimensionArray {
get {
return ResourceManager.GetString("ArgumentSingleDimensionArray", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Value is too large..
/// </summary>
internal static string ArgumentTooLarge
{
get
{
internal static string ArgumentTooLarge {
get {
return ResourceManager.GetString("ArgumentTooLarge", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Value is too large for the current iteration limit..
/// </summary>
internal static string ArgumentTooLargeForIterationLimit
{
get
{
internal static string ArgumentTooLargeForIterationLimit {
get {
return ResourceManager.GetString("ArgumentTooLargeForIterationLimit", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Type mismatch..
/// </summary>
internal static string ArgumentTypeMismatch
{
get
{
internal static string ArgumentTypeMismatch {
get {
return ResourceManager.GetString("ArgumentTypeMismatch", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Array length must be a multiple of {0}..
/// </summary>
internal static string ArgumentVectorLengthsMultipleOf
{
get
{
internal static string ArgumentVectorLengthsMultipleOf {
get {
return ResourceManager.GetString("ArgumentVectorLengthsMultipleOf", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to All vectors must have the same dimensionality..
/// </summary>
internal static string ArgumentVectorsSameLengths
{
get
{
internal static string ArgumentVectorsSameLengths {
get {
return ResourceManager.GetString("ArgumentVectorsSameLengths", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The vector must have 3 dimensions..
/// </summary>
internal static string ArgumentVectorThreeDimensional
{
get
{
internal static string ArgumentVectorThreeDimensional {
get {
return ResourceManager.GetString("ArgumentVectorThreeDimensional", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to This feature is not implemented yet (but is planned)..
/// </summary>
internal static string FeaturePlannedButNotImplementedYet
{
get
{
internal static string FeaturePlannedButNotImplementedYet {
get {
return ResourceManager.GetString("FeaturePlannedButNotImplementedYet", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Invalid parameterization for the distribution..
/// </summary>
internal static string InvalidDistributionParameters {
get {
return ResourceManager.GetString("InvalidDistributionParameters", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Invalid Left Boundary Condition..
/// </summary>
internal static string InvalidLeftBoundaryCondition
{
get
{
internal static string InvalidLeftBoundaryCondition {
get {
return ResourceManager.GetString("InvalidLeftBoundaryCondition", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The operation could not be performed because the accumulator is empty..
/// </summary>
internal static string InvalidOperationAccumulatorEmpty
{
get
{
internal static string InvalidOperationAccumulatorEmpty {
get {
return ResourceManager.GetString("InvalidOperationAccumulatorEmpty", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The operation could not be performed because the histogram is empty..
/// </summary>
internal static string InvalidOperationHistogramEmpty
{
get
{
internal static string InvalidOperationHistogramEmpty {
get {
return ResourceManager.GetString("InvalidOperationHistogramEmpty", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Not enough points in the distribution..
/// </summary>
internal static string InvalidOperationHistogramNotEnoughPoints
{
get
{
internal static string InvalidOperationHistogramNotEnoughPoints {
get {
return ResourceManager.GetString("InvalidOperationHistogramNotEnoughPoints", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to No Samples Provided. Preparation Required..
/// </summary>
internal static string InvalidOperationNoSamplesProvided
{
get
{
internal static string InvalidOperationNoSamplesProvided {
get {
return ResourceManager.GetString("InvalidOperationNoSamplesProvided", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Invalid Right Boundary Condition..
/// </summary>
internal static string InvalidRightBoundaryCondition
{
get
{
internal static string InvalidRightBoundaryCondition {
get {
return ResourceManager.GetString("InvalidRightBoundaryCondition", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to This special case is not supported yet (but is planned)..
/// </summary>
internal static string SpecialCasePlannedButNotImplementedYet
{
get
{
internal static string SpecialCasePlannedButNotImplementedYet {
get {
return ResourceManager.GetString("SpecialCasePlannedButNotImplementedYet", resourceCulture);
}
}

3
src/Managed/Properties/Resources.resx

@ -237,4 +237,7 @@
<data name="SpecialCasePlannedButNotImplementedYet" xml:space="preserve">
<value>This special case is not supported yet (but is planned).</value>
</data>
<data name="InvalidDistributionParameters" xml:space="preserve">
<value>Invalid parameterization for the distribution.</value>
</data>
</root>

40
src/Managed/SiPrefixes.cs

@ -35,64 +35,64 @@ namespace MathNet.Numerics
/// <seealso cref="Constants"/>
public static class SiPrefixes
{
/// <summary>1 000 000 000 000 000 000 000 000</summary>
/// <summary>The SI prefix factor corresponding to 1 000 000 000 000 000 000 000 000</summary>
public const double Yotta = 1e24;
/// <summary>1 000 000 000 000 000 000 000</summary>
/// <summary>The SI prefix factor corresponding to 1 000 000 000 000 000 000 000</summary>
public const double Zetta = 1e21;
/// <summary>1 000 000 000 000 000 000</summary>
/// <summary>The SI prefix factor corresponding to 1 000 000 000 000 000 000</summary>
public const double Exa = 1e18;
/// <summary>1 000 000 000 000 000</summary>
/// <summary>The SI prefix factor corresponding to 1 000 000 000 000 000</summary>
public const double Peta = 1e15;
/// <summary>1 000 000 000 000</summary>
/// <summary>The SI prefix factor corresponding to 1 000 000 000 000</summary>
public const double Tera = 1e12;
/// <summary>1 000 000 000</summary>
/// <summary>The SI prefix factor corresponding to 1 000 000 000</summary>
public const double Giga = 1e9;
/// <summary>1 000 000</summary>
/// <summary>The SI prefix factor corresponding to 1 000 000</summary>
public const double Mega = 1e6;
/// <summary>1 000</summary>
/// <summary>The SI prefix factor corresponding to 1 000</summary>
public const double Kilo = 1e3;
/// <summary>100</summary>
/// <summary>The SI prefix factor corresponding to 100</summary>
public const double Hecto = 1e2;
/// <summary>10</summary>
/// <summary>The SI prefix factor corresponding to 10</summary>
public const double Deca = 1e1;
/// <summary>0.1</summary>
/// <summary>The SI prefix factor corresponding to 0.1</summary>
public const double Deci = 1e-1;
/// <summary>0.01</summary>
/// <summary>The SI prefix factor corresponding to 0.01</summary>
public const double Centi = 1e-2;
/// <summary>0.001</summary>
/// <summary>The SI prefix factor corresponding to 0.001</summary>
public const double Milli = 1e-3;
/// <summary>0.000 001</summary>
/// <summary>The SI prefix factor corresponding to 0.000 001</summary>
public const double Micro = 1e-6;
/// <summary>0.000 000 001</summary>
/// <summary>The SI prefix factor corresponding to 0.000 000 001</summary>
public const double Nano = 1e-9;
/// <summary>0.000 000 000 001</summary>
/// <summary>The SI prefix factor corresponding to 0.000 000 000 001</summary>
public const double Pico = 1e-12;
/// <summary>0.000 000 000 000 001</summary>
/// <summary>The SI prefix factor corresponding to 0.000 000 000 000 001</summary>
public const double Femto = 1e-15;
/// <summary>0.000 000 000 000 000 001</summary>
/// <summary>The SI prefix factor corresponding to 0.000 000 000 000 000 001</summary>
public const double Atto = 1e-18;
/// <summary>0.000 000 000 000 000 000 001</summary>
/// <summary>The SI prefix factor corresponding to 0.000 000 000 000 000 000 001</summary>
public const double Zepto = 1e-21;
/// <summary>0.000 000 000 000 000 000 000 001</summary>
/// <summary>The SI prefix factor corresponding to 0.000 000 000 000 000 000 000 001</summary>
public const double Yocto = 1e-24;
}
}

2
src/Managed/SpecialFunctions.cs

@ -1,4 +1,4 @@
// <copyright file="SpecialFunctions.cs" company="Math.NET">
// <copyright file="SpecialFunctions.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://mathnet.opensourcedotnet.info
//

3
src/Native.UnitTests/Native.UnitTests.csproj

@ -66,6 +66,9 @@
<Compile Include="..\Managed.UnitTests\ComplexTest.cs">
<Link>ComplexTest.cs</Link>
</Compile>
<Compile Include="..\Managed.UnitTests\DistributionTests\Continuous\ContinuousUniformTests.cs">
<Link>DistributionTests\Continuous\ContinuousUniformTests.cs</Link>
</Compile>
<Compile Include="..\Managed.UnitTests\DistributionTests\Continuous\NormalTests.cs">
<Link>DistributionTests\Continuous\NormalTests.cs</Link>
</Compile>

6
src/Native/Native.csproj

@ -50,6 +50,12 @@
<Compile Include="..\Managed\Constants.cs">
<Link>Constants.cs</Link>
</Compile>
<Compile Include="..\Managed\Control.cs">
<Link>Control.cs</Link>
</Compile>
<Compile Include="..\Managed\Distributions\Continuous\ContinuousUniform.cs">
<Link>Distributions\Continuous\ContinuousUniform.cs</Link>
</Compile>
<Compile Include="..\Managed\Distributions\Continuous\Normal.cs">
<Link>Distributions\Continuous\Normal.cs</Link>
</Compile>

Loading…
Cancel
Save