11 changed files with 10621 additions and 0 deletions
File diff suppressed because it is too large
@ -0,0 +1,156 @@ |
|||||
|
// <copyright file="Combinatorics.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 |
||||
|
{ |
||||
|
using System; |
||||
|
using MbUnit.Framework; |
||||
|
using MathNet.Numerics.Distributions; |
||||
|
|
||||
|
[TestFixture] |
||||
|
public class NormalTests |
||||
|
{ |
||||
|
[Test, MultipleAsserts] |
||||
|
public void CanCreateStandardNormal() |
||||
|
{ |
||||
|
var n = new Normal(); |
||||
|
AssertEx.AreEqual<double>(0.0, n.Mean); |
||||
|
AssertEx.AreEqual<double>(1.0, n.StdDev); |
||||
|
} |
||||
|
|
||||
|
[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, 1.0)] |
||||
|
[Row(-5.0, 100.0)] |
||||
|
[Row(0.0, Double.PositiveInfinity)] |
||||
|
public void CanCreateNormal(double mean, double sdev) |
||||
|
{ |
||||
|
var n = new Normal(mean, sdev); |
||||
|
AssertEx.AreEqual<double>(mean, n.Mean); |
||||
|
AssertEx.AreEqual<double>(sdev, n.StdDev); |
||||
|
} |
||||
|
|
||||
|
[Test] |
||||
|
[ExpectedException(typeof(ArgumentOutOfRangeException))] |
||||
|
public void NormalCreateFailsWithMeanIsNaN() |
||||
|
{ |
||||
|
var n = new Normal(Double.NaN, 1.0); |
||||
|
} |
||||
|
|
||||
|
[Test] |
||||
|
[ExpectedException(typeof(ArgumentOutOfRangeException))] |
||||
|
public void NormalCreateFailsWithStdDevIsNaN() |
||||
|
{ |
||||
|
var n = new Normal(0.0, Double.NaN); |
||||
|
} |
||||
|
|
||||
|
[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, 1.0)] |
||||
|
[Row(-5.0, 100.0)] |
||||
|
[Row(0.0, Double.PositiveInfinity)] |
||||
|
public void CanCreateNormalFromMeanAndStdDev(double mean, double sdev) |
||||
|
{ |
||||
|
var n = Normal.WithMeanStdDev(mean, sdev); |
||||
|
AssertEx.AreEqual<double>(mean, n.Mean); |
||||
|
AssertEx.AreEqual<double>(sdev, n.StdDev); |
||||
|
} |
||||
|
|
||||
|
[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, 1.0)] |
||||
|
[Row(-5.0, 100.0)] |
||||
|
[Row(0.0, Double.PositiveInfinity)] |
||||
|
public void CanCreateNormalFromMeanAndVariance(double mean, double var) |
||||
|
{ |
||||
|
var n = Normal.WithMeanVariance(mean, var); |
||||
|
AssertEx.AreEqual<double>(mean, n.Mean); |
||||
|
AssertEx.AreEqual<double>(var, n.Variance); |
||||
|
} |
||||
|
|
||||
|
[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, 1.0)] |
||||
|
[Row(-5.0, 100.0)] |
||||
|
[Row(0.0, Double.PositiveInfinity)] |
||||
|
public void CanCreateNormalFromMeanAndPrecision(double mean, double prec) |
||||
|
{ |
||||
|
var n = Normal.WithMeanAndPrecision(mean, prec); |
||||
|
AssertEx.AreEqual<double>(mean, n.Mean); |
||||
|
AssertEx.AreEqual<double>(prec, n.Precision); |
||||
|
} |
||||
|
|
||||
|
[Test] |
||||
|
public void ToStringTest() |
||||
|
{ |
||||
|
var n = new Normal(1.0, 2.0); |
||||
|
AssertEx.AreEqual<string>("Normal(Mean = 1, StdDev = 2)", n.ToString()); |
||||
|
} |
||||
|
|
||||
|
[Test] |
||||
|
public void CanGetRandomNumberGenerator() |
||||
|
{ |
||||
|
var n = new Normal(); |
||||
|
var rs = n.RandomNumberGenerator; |
||||
|
Assert.IsNotNull(rs); |
||||
|
} |
||||
|
|
||||
|
[Test] |
||||
|
[Row(-0.0)] |
||||
|
[Row(0.0)] |
||||
|
[Row(0.1)] |
||||
|
[Row(1.0)] |
||||
|
[Row(10.0)] |
||||
|
[Row(0.0, Double.PositiveInfinity)] |
||||
|
public void CanSetRandomNumberGenerator(double prec) |
||||
|
{ |
||||
|
var n = new Normal(); |
||||
|
n.Precision = prec; |
||||
|
} |
||||
|
|
||||
|
[Test] |
||||
|
[ExpectedException(typeof(ArgumentOutOfRangeException))] |
||||
|
public void SetPrecisionFailsWithNegativePrecision() |
||||
|
{ |
||||
|
var n = new Normal(); |
||||
|
n.Precision = -1.0; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,193 @@ |
|||||
|
// <copyright file="Combinatorics.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; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Implements the univariate Normal (or Gaussian) distribution.
|
||||
|
/// </summary>
|
||||
|
public class Normal : IContinuousDistribution |
||||
|
{ |
||||
|
// Keeps track of the mean of the normal distribution.
|
||||
|
private double mMean; |
||||
|
// Keeps track of the standard deviation of the normal distribution.
|
||||
|
private double mStdDev; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Constructs a standard normal distribution. This is a normal distribution with mean 0.0
|
||||
|
/// and standard deviation 1.0.
|
||||
|
/// </summary>
|
||||
|
public Normal() : this(0.0, 1.0) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Construct a normal distribution with a particular mean and standard deviation.
|
||||
|
/// </summary>
|
||||
|
/// <param name="mean">The mean of the normal distribution.</param>
|
||||
|
/// <param name="stddev">The standard deviation of the normal distribution.</param>
|
||||
|
public Normal(double mean, double stddev) |
||||
|
{ |
||||
|
SetParameters(mean, stddev); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Constructs a normal distribution from a mean and standard deviation.
|
||||
|
/// </summary>
|
||||
|
/// <param name="mean">The mean of the normal distribution.</param>
|
||||
|
/// <param name="stddev">The standard deviation of the normal distribution.</param>
|
||||
|
public static Normal WithMeanStdDev(double mean, double stddev) |
||||
|
{ |
||||
|
return new Normal(mean, stddev); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Constructs a normal distribution from a mean and variance.
|
||||
|
/// </summary>
|
||||
|
/// <param name="mean">The mean of the normal distribution.</param>
|
||||
|
/// <param name="stddev">The variance of the normal distribution.</param>
|
||||
|
public static Normal WithMeanVariance(double mean, double var) |
||||
|
{ |
||||
|
return new Normal(mean, System.Math.Sqrt(var)); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Constructs a normal distribution from a mean and precision.
|
||||
|
/// </summary>
|
||||
|
/// <param name="mean">The mean of the normal distribution.</param>
|
||||
|
/// <param name="stddev">The precision of the normal distribution.</param>
|
||||
|
public static Normal WithMeanAndPrecision(double mean, double prec) |
||||
|
{ |
||||
|
return new Normal(mean, 1.0 / System.Math.Sqrt(prec)); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// A string representation of the distribution.
|
||||
|
/// </summary>
|
||||
|
public override string ToString() |
||||
|
{ |
||||
|
return "Normal(Mean = " + mMean + ", StdDev = " + mStdDev + ")"; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Checks whether the parameters of the distribution are valid.
|
||||
|
/// </summary>
|
||||
|
/// <param name="mean">The mean of the normal distribution.</param>
|
||||
|
/// <param name="stddev">The standard deviation of the normal distribution.</param>
|
||||
|
/// <returns>True when the parameters are valid, false otherwise.</returns>
|
||||
|
private static bool IsValidParameterSet(double mean, double stddev) |
||||
|
{ |
||||
|
if (stddev < 0.0) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
else if (System.Double.IsNaN(mean)) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
else if (System.Double.IsNaN(stddev)) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Sets the parameters of the distribution after checking their validity.
|
||||
|
/// </summary>
|
||||
|
/// <param name="mean">The mean of the normal distribution.</param>
|
||||
|
/// <param name="stddev">The standard deviation of the normal distribution.</param>
|
||||
|
/// <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)) |
||||
|
{ |
||||
|
mMean = mean; |
||||
|
mStdDev = stddev; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
throw new System.ArgumentOutOfRangeException("Invalid parameterization for the normal distribution."); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public double Precision |
||||
|
{ |
||||
|
get { return 1.0 / (mStdDev * mStdDev); } |
||||
|
set { throw new NotImplementedException(); } |
||||
|
} |
||||
|
|
||||
|
#region IDistribution implementation
|
||||
|
public Random RandomNumberGenerator { get; set; } |
||||
|
|
||||
|
public double Mean |
||||
|
{ |
||||
|
get { return mMean; } |
||||
|
set { throw new NotImplementedException(); } |
||||
|
} |
||||
|
public double Variance |
||||
|
{ |
||||
|
get { return mStdDev * mStdDev; } |
||||
|
set { throw new NotImplementedException(); } |
||||
|
} |
||||
|
public double StdDev |
||||
|
{ |
||||
|
get { return mStdDev; } |
||||
|
set { throw new NotImplementedException(); } |
||||
|
} |
||||
|
public double Entropy { get { throw new NotImplementedException(); } } |
||||
|
public double Skewness { get { throw new NotImplementedException(); } } |
||||
|
#endregion
|
||||
|
|
||||
|
#region IContinuousDistribution implementation
|
||||
|
public double Mode { get { throw new NotImplementedException(); } } |
||||
|
public double Median { get { throw new NotImplementedException(); } } |
||||
|
public double Minimum { get { throw new NotImplementedException(); } } |
||||
|
public double Maximum { get { throw new NotImplementedException(); } } |
||||
|
public double Density(double x) { throw new NotImplementedException(); } |
||||
|
public double DensityLn(double x) { throw new NotImplementedException(); } |
||||
|
public double CumulativeDistribution(double x) { throw new NotImplementedException(); } |
||||
|
|
||||
|
public double Sample() { throw new NotImplementedException(); } |
||||
|
public IEnumerable<double> Samples() { throw new NotImplementedException(); } |
||||
|
#endregion
|
||||
|
|
||||
|
public double InverseCumulativeDistribution(double p) |
||||
|
{ |
||||
|
throw new NotImplementedException(); |
||||
|
} |
||||
|
|
||||
|
public static double Sample(System.Random rng, double mean, double stddev) { throw new NotImplementedException(); } |
||||
|
public static IEnumerable<double> Samples(System.Random rng, double mean, double stddev) { throw new NotImplementedException(); } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,48 @@ |
|||||
|
// <copyright file="Combinatorics.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.Collections.Generic; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The interface for continuous univariate distributions.
|
||||
|
/// </summary>
|
||||
|
public interface IContinuousDistribution : IDistribution |
||||
|
{ |
||||
|
double Mode { get; } |
||||
|
double Median { get; } |
||||
|
double Minimum { get; } |
||||
|
double Maximum { get; } |
||||
|
double Density(double x); |
||||
|
double DensityLn(double x); |
||||
|
|
||||
|
double Sample(); |
||||
|
IEnumerable<double> Samples(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,80 @@ |
|||||
|
// <copyright file="Combinatorics.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.Collections.Generic; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The interface for discrete univariate distributions.
|
||||
|
/// </summary>
|
||||
|
public interface IDiscreteDistribution : IDistribution |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// The mode of the distribution.
|
||||
|
/// </summary>
|
||||
|
int Mode { get; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The median of the distribution.
|
||||
|
/// </summary>
|
||||
|
int Median { get; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The smallest element in the domain of the distributions which can be represented by an integer.
|
||||
|
/// </summary>
|
||||
|
int Minimum { get; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The largest element in the domain of the distributions which can be represented by an integer.
|
||||
|
/// </summary>
|
||||
|
int Maximum { get; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Computes values of the probability mass function.
|
||||
|
/// </summary>
|
||||
|
/// <param name="k">The location in the domain where we want to evaluate the probability mass function.</param>
|
||||
|
double Probability(int k); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Computes values of the log probability mass function.
|
||||
|
/// </summary>
|
||||
|
/// <param name="k">The location in the domain where we want to evaluate the log probability mass function.</param>
|
||||
|
double ProbabilityLn(int k); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Draws a random sample from the distribution.
|
||||
|
/// </summary>
|
||||
|
int Sample(); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Draws a sequence of random samples from the distribution.
|
||||
|
/// </summary>
|
||||
|
IEnumerable<int> Samples(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,73 @@ |
|||||
|
// <copyright file="Combinatorics.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; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The interface for univariate distributions.
|
||||
|
/// </summary>
|
||||
|
public interface IDistribution |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Gets or sets the random number generator which is used to generate random samples from the distribution.
|
||||
|
/// </summary>
|
||||
|
Random RandomNumberGenerator { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The mean of the distribution.
|
||||
|
/// </summary>
|
||||
|
double Mean { get; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The variance of the distribution.
|
||||
|
/// </summary>
|
||||
|
double Variance { get; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The standard deviation of the distribution.
|
||||
|
/// </summary>
|
||||
|
double StdDev { get; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The entropy of the distribution.
|
||||
|
/// </summary>
|
||||
|
double Entropy { get; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The skewness of the distribution.
|
||||
|
/// </summary>
|
||||
|
double Skewness { get; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Computes the cumulative distribution function (cdf) for this probability distribution.
|
||||
|
/// </summary>
|
||||
|
double CumulativeDistribution(double x); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,35 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace Pnl.RandomSources |
||||
|
{ |
||||
|
// Do we want to inherit from System.Random so people can plugin any RNG not from our library?
|
||||
|
public abstract class RandomSource /* : System.Random */ |
||||
|
{ |
||||
|
protected RandomSource(bool threadSafe) { } |
||||
|
public abstract int Next(); |
||||
|
public abstract int Next(int maxValue); |
||||
|
public abstract int Next(int minValue, int maxValue); |
||||
|
public abstract double NextDouble(); |
||||
|
public abstract double NextDouble(double maxValue); |
||||
|
public abstract double NextDouble(double minValue, double maxValue); |
||||
|
public abstract bool NextBoolean(); |
||||
|
public abstract void NextBytes(byte[] buffer); |
||||
|
|
||||
|
// Do we want Reset() or just a SetSeed kind of method?
|
||||
|
public abstract void Reset(); |
||||
|
public abstract bool CanReset |
||||
|
{ |
||||
|
get; |
||||
|
} |
||||
|
|
||||
|
public virtual long NextInt64() |
||||
|
{ |
||||
|
throw new NotImplementedException(); |
||||
|
} |
||||
|
|
||||
|
public virtual decimal NextDecimal() |
||||
|
{ |
||||
|
throw new NotImplementedException(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue