1[section:variates Random Variates and Distribution Parameters] 2 3[@http://en.wikipedia.org/wiki/Random_variate Random variates] 4and [@http://en.wikipedia.org/wiki/Parameter distribution parameters] 5are conventionally distinguished (for example in Wikipedia and Wolfram MathWorld 6by placing a semi-colon after the __random_variate (whose value you 'choose'), 7to separate the variate from the parameter(s) that defines the shape of the distribution. 8 9For example, the binomial distribution has two parameters: 10n (the number of trials) and p (the probability of success on one trial). 11It also has the __random_variate /k/: the number of successes observed. 12This means the probability density\/mass function (pdf) is written as ['f(k; n, p)]. 13 14Translating this into code the `binomial_distribution` constructor 15therefore has two parameters: 16 17 binomial_distribution(RealType n, RealType p); 18 19While the function `pdf` has one argument specifying the distribution type 20(which includes its parameters, if any), 21and a second argument for the __random_variate. So taking our binomial distribution 22example, we would write: 23 24 pdf(binomial_distribution<RealType>(n, p), k); 25 26[endsect] 27 28[section:dist_params Discrete Probability Distributions] 29 30Note that the [@http://en.wikipedia.org/wiki/Discrete_probability_distribution 31discrete distributions], including the binomial, negative binomial, Poisson & Bernoulli, 32are all mathematically defined as discrete functions: 33only integral values of the __random_variate are envisaged 34and the functions are only defined at these integral values. 35However because the method of calculation often uses continuous functions, 36it is convenient to treat them as if they were continuous functions, 37and permit non-integral values of their parameters. 38 39To enforce a strict mathematical model, 40users may use floor or ceil functions on the __random_variate, 41prior to calling the distribution function, to enforce integral values. 42 43For similar reasons, in continuous distributions, parameters like degrees of freedom 44that might appear to be integral, are treated as real values 45(and are promoted from integer to floating-point if necessary). 46In this case however, that there are a small number of situations where non-integral 47degrees of freedom do have a genuine meaning. 48 49Generally speaking there is no loss of performance from allowing real-values 50parameters: the underlying special functions contain optimizations for 51integer-valued arguments when applicable. 52 53[caution 54The quantile function of a discrete distribution will by 55default return an integer result that has been 56/rounded outwards/. That is to say lower quantiles (where the probability is 57less than 0.5) are rounded downward, and upper quantiles (where the probability 58is greater than 0.5) are rounded upwards. This behaviour 59ensures that if an X% quantile is requested, then /at least/ the requested 60coverage will be present in the central region, and /no more than/ 61the requested coverage will be present in the tails. 62 63This behaviour can be changed so that the quantile functions are rounded 64differently, or even return a real-valued result using 65[link math_toolkit.pol_overview Policies]. It is strongly 66recommended that you read the tutorial 67[link math_toolkit.pol_tutorial.understand_dis_quant 68Understanding Quantiles of Discrete Distributions] before 69using the quantile function on a discrete distribution. The 70[link math_toolkit.pol_ref.discrete_quant_ref reference docs] 71describe how to change the rounding policy 72for these distributions. 73] 74 75[endsect] [/section:variates Random Variates and Distribution Parameters] 76 77[/ 78 Copyright 2006 John Maddock and Paul A. Bristow. 79 Distributed under the Boost Software License, Version 1.0. 80 (See accompanying file LICENSE_1_0.txt or copy at 81 http://www.boost.org/LICENSE_1_0.txt). 82] 83 84 85