Latest Updates
Latest Tweets
Fork me on GitHub

Probability Distributions

In MathNet.Numerics.Distributions we have various probability distributions. They are divided up into univariate continuous, univariate discrete and multivariate distributions. All the univariate distributions derive from the MathNet.Numerics.Distributions.IDistribution interface whereas the continuous ones derive from MathNet.Numerics.Distributions.IContinuousDistribution and the discrete distributions derive from MathNet.Numerics.Distributions.IDiscreteDistribution. There is no particular class hierarchy for the multivariate distributions: as their domains can be quite different it would be hard to come up with a simple and clean unifying interface.

One has to be very careful when using the distributions. There are many ways to parameterize one distribution in the literature; when using the default constructor, study carefully which parameters it requires. If they do not suite your needs, there will very likely be static method which can construct the distribution for you. E.g. to construct a normal distribution with mean 0.0 and standard deviation 2.0

var n = new Normal(0.0, 2.0);
If you'd rather parameterize the normal distribution using a mean and precision, one can use the following code
var n = Normal.WithMeanPrecision(0.0,0.5);

All the distributions implement a basic set of operations such as computing the mean, standard deviation, density, etc. Note that it is often much faster to compute quantities in the log domain; for some quantities (e.g. Density) we implement an equivalent method that does all computations in the log domain (e.g. DensityLn).

Each distribution provides methods to generate random numbers from that distribution. These random variate generators work by accessing the distribution's member RandomSource (which is a subclass of System.Random, see Random Numbers for details) to provide uniform random numbers. By default, this member is an instance of System.Random but one can easily replace this with more sophisticated random number generators from MathNet.Numerics.Random. Each distribution class has two static and two class methods: for each pair (static and class), one of them generates a single sample, the other will generate an IEnumerable<T> of samples. The static methods allow random number generation without instantiating the actual class.

Discrete Distributions

The following discrete distributions are currently implemented. Strikeout items are not ported yet but are available in Iridium or dnAnalytics and thus should be available soon.

Continuous Distributions

Multivariate Distributions