rgsl/randist/
mod.rs

1//
2// A rust binding for the GSL library by Guillaume Gomez (guillaume1.gomez@gmail.com)
3//
4
5/*!
6# Random Number Distributions
7
8This chapter describes functions for generating random variates and computing their probability distributions.
9Samples from the distributions described in this chapter can be obtained using any of the random number generators in the library as an underlying source of randomness.
10
11In the simplest cases a non-uniform distribution can be obtained analytically from the uniform distribution of a random number generator by applying an appropriate transformation.
12This method uses one call to the random number generator. More complicated distributions are created by the acceptance-rejection method, which compares the desired distribution against a distribution which is similar and known analytically.
13This usually requires several samples from the generator.
14
15The library also provides cumulative distribution functions and inverse cumulative distribution functions, sometimes referred to as quantile functions.
16The cumulative distribution functions and their inverses are computed separately for the upper and lower tails of the distribution, allowing full accuracy to be retained for small results.
17
18Note that the discrete random variate functions always return a value of type unsigned int, and on most platforms this has a maximum value of 2^32-1 ~=~ 4.29e9. They should only be called with a safe range of parameters (where there is a negligible probability of a variate exceeding this limit) to prevent incorrect results due to overflow.
19
20## Introduction
21
22Continuous random number distributions are defined by a probability density function, p(x), such that the probability of x occurring in the infinitesimal range x to x+dx is p dx.
23
24The cumulative distribution function for the lower tail P(x) is defined by the integral,
25
26P(x) = \int_{-\infty}^{x} dx' p(x')
27
28and gives the probability of a variate taking a value less than x.
29
30The cumulative distribution function for the upper tail Q(x) is defined by the integral,
31
32Q(x) = \int_{x}^{+\infty} dx' p(x')
33
34and gives the probability of a variate taking a value greater than x.
35
36The upper and lower cumulative distribution functions are related by P(x) + Q(x) = 1 and satisfy 0 <= P(x) <= 1, 0 <= Q(x) <= 1.
37
38The inverse cumulative distributions, x=P^{-1}(P) and x=Q^{-1}(Q) give the values of x which correspond to a specific value of P or Q. They can be used to find confidence limits from probability values.
39
40For discrete distributions the probability of sampling the integer value k is given by p(k), where \sum_k p(k) = 1. The cumulative distribution for the lower tail P(k) of a discrete distribution is defined as,
41
42P(k) = \sum_{i <= k} p(i)
43
44where the sum is over the allowed range of the distribution less than or equal to k.
45
46
47The cumulative distribution for the upper tail of a discrete distribution Q(k) is defined as
48
49Q(k) = \sum_{i > k} p(i)
50
51giving the sum of probabilities for all values greater than k. These two definitions satisfy the identity P(k)+Q(k)=1.
52
53If the range of the distribution is 1 to n inclusive then P(n)=1, Q(n)=0 while P(1) = p(1), Q(1)=1-p(1).
54!*/
55
56pub mod bernoulli;
57pub mod beta;
58pub mod binomial;
59pub mod bivariate_gaussian;
60pub mod cauchy;
61pub mod chi_squared;
62pub mod dirichlet;
63pub mod exponential;
64pub mod exponential_power;
65pub mod f_distribution;
66pub mod flat;
67pub mod gamma;
68pub mod gaussian;
69pub mod gaussian_tail;
70pub mod geometric;
71pub mod gumbel;
72pub mod hypergeometric;
73pub mod landau;
74pub mod laplace;
75pub mod logarithmic;
76pub mod logistic;
77pub mod lognormal;
78pub mod multinomial;
79pub mod negative_binomial;
80pub mod pareto;
81pub mod pascal;
82pub mod poisson;
83pub mod rayleigh;
84pub mod rayleigh_tail;
85pub mod t_distribution;
86pub mod weibull;