1 |
@cindex random number distributions |
@cindex random number distributions |
2 |
|
@cindex cumulative distribution functions (CDFs) |
3 |
|
@cindex CDFs, cumulative distribution functions |
4 |
|
@cindex inverse cumulative distribution functions |
5 |
|
@cindex quantile functions |
6 |
This chapter describes functions for generating random variates and |
This chapter describes functions for generating random variates and |
7 |
computing their probability distributions. Samples from the |
computing their probability distributions. Samples from the |
8 |
distributions described in this chapter can be obtained using any of the |
distributions described in this chapter can be obtained using any of the |
111 |
The upper and lower cumulative distribution functions are related by |
The upper and lower cumulative distribution functions are related by |
112 |
@math{P(x) + Q(x) = 1} |
@math{P(x) + Q(x) = 1} |
113 |
|
|
114 |
The inverse cumulative distributions, @c{$P^{-1}(x)$} |
The inverse cumulative distributions, @c{$x=P^{-1}(P)$} |
115 |
@math{P^@{-1@}(x)} and @c{$Q^{-1}(x)$} |
@math{x=P^@{-1@}(P)} and @c{$x=Q^{-1}(Q)$} |
116 |
@math{Q^@{-1@}(x)} give the value of @math{x} |
@math{x=Q^@{-1@}(Q)} give the values of @math{x} |
117 |
which corresponds to a given value of @math{P} or {Q}. |
which correspond to a specific value of @math{P} or {Q}. |
118 |
They can be used to find confidence limits from probability values. |
They can be used to find confidence limits from probability values. |
119 |
|
|
120 |
@page |
@page |
175 |
@deftypefunx double gsl_cdf_gaussian_Pinv (double @var{P}, double @var{sigma}) |
@deftypefunx double gsl_cdf_gaussian_Pinv (double @var{P}, double @var{sigma}) |
176 |
@deftypefunx double gsl_cdf_gaussian_Qinv (double @var{Q}, double @var{sigma}) |
@deftypefunx double gsl_cdf_gaussian_Qinv (double @var{Q}, double @var{sigma}) |
177 |
These functions compute the cumulative distribution functions |
These functions compute the cumulative distribution functions |
178 |
@math{P(x)} and @math{Q(x)}, and their inverses, for the Gaussian |
@math{P(x)}, @math{Q(x)} and their inverses for the Gaussian |
179 |
distribution with standard deviation @var{sigma}. |
distribution with standard deviation @var{sigma}. |
180 |
@end deftypefun |
@end deftypefun |
181 |
|
|
184 |
@deftypefunx double gsl_cdf_ugaussian_Pinv (double @var{P}) |
@deftypefunx double gsl_cdf_ugaussian_Pinv (double @var{P}) |
185 |
@deftypefunx double gsl_cdf_ugaussian_Qinv (double @var{Q}) |
@deftypefunx double gsl_cdf_ugaussian_Qinv (double @var{Q}) |
186 |
These functions compute the cumulative distribution functions |
These functions compute the cumulative distribution functions |
187 |
@math{P(x)} and @math{Q(x)}, and their inverses, for the unit Gaussian |
@math{P(x)}, @math{Q(x)} and their inverses for the unit Gaussian |
188 |
distribution. |
distribution. |
189 |
@end deftypefun |
@end deftypefun |
190 |
|
|
336 |
@deftypefunx double gsl_cdf_exponential_Pinv (double @var{P}, double @var{mu}) |
@deftypefunx double gsl_cdf_exponential_Pinv (double @var{P}, double @var{mu}) |
337 |
@deftypefunx double gsl_cdf_exponential_Qinv (double @var{Q}, double @var{mu}) |
@deftypefunx double gsl_cdf_exponential_Qinv (double @var{Q}, double @var{mu}) |
338 |
These functions compute the cumulative distribution functions |
These functions compute the cumulative distribution functions |
339 |
@math{P(x)} and @math{Q(x)}, and their inverses, for the exponential |
@math{P(x)}, @math{Q(x)} and their inverses for the exponential |
340 |
distribution with mean @var{mu}. |
distribution with mean @var{mu}. |
341 |
@end deftypefun |
@end deftypefun |
342 |
|
|
368 |
|
|
369 |
@deftypefun double gsl_ran_laplace_pdf (double @var{x}, double @var{a}) |
@deftypefun double gsl_ran_laplace_pdf (double @var{x}, double @var{a}) |
370 |
This function computes the probability density @math{p(x)} at @var{x} |
This function computes the probability density @math{p(x)} at @var{x} |
371 |
for a Laplace distribution with mean @var{a}, using the formula |
for a Laplace distribution with width @var{a}, using the formula |
372 |
given above. |
given above. |
373 |
@end deftypefun |
@end deftypefun |
374 |
|
|
377 |
\centerline{\input rand-laplace.tex} |
\centerline{\input rand-laplace.tex} |
378 |
@end tex |
@end tex |
379 |
|
|
380 |
|
@deftypefun double gsl_cdf_laplace_P (const double @var{x}, const double @var{a}) |
381 |
|
@deftypefunx double gsl_cdf_laplace_Q (const double @var{x}, const double @var{a}) |
382 |
|
@deftypefunx double gsl_cdf_laplace_Pinv (const double @var{P}, const double @var{a}) |
383 |
|
@deftypefunx double gsl_cdf_laplace_Qinv (const double @var{Q}, const double @var{a}) |
384 |
|
These functions compute the cumulative distribution functions |
385 |
|
@math{P(x)}, @math{Q(x)} and their inverses for the Laplace |
386 |
|
distribution with width @var{a}. |
387 |
|
@end deftypefun |
388 |
|
|
389 |
|
|
390 |
@page |
@page |
391 |
@node The Exponential Power Distribution |
@node The Exponential Power Distribution |
392 |
@section The Exponential Power Distribution |
@section The Exponential Power Distribution |
464 |
\centerline{\input rand-cauchy.tex} |
\centerline{\input rand-cauchy.tex} |
465 |
@end tex |
@end tex |
466 |
|
|
467 |
|
@deftypefun double gsl_cdf_cauchy_P (const double @var{x}, const double @var{a}) |
468 |
|
@deftypefunx double gsl_cdf_cauchy_Q (const double @var{x}, const double @var{a}) |
469 |
|
@deftypefunx double gsl_cdf_cauchy_Pinv (const double @var{P}, const double @var{a}) |
470 |
|
@deftypefunx double gsl_cdf_cauchy_Qinv (const double @var{Q}, const double @var{a}) |
471 |
|
These functions compute the cumulative distribution functions |
472 |
|
@math{P(x)}, @math{Q(x)} and their inverses for the Cauchy |
473 |
|
distribution with scale parameter @var{a}. |
474 |
|
@end deftypefun |
475 |
|
|
476 |
|
|
477 |
@page |
@page |
478 |
@node The Rayleigh Distribution |
@node The Rayleigh Distribution |
479 |
@section The Rayleigh Distribution |
@section The Rayleigh Distribution |
509 |
\centerline{\input rand-rayleigh.tex} |
\centerline{\input rand-rayleigh.tex} |
510 |
@end tex |
@end tex |
511 |
|
|
512 |
|
@deftypefun double gsl_cdf_rayleigh_P (const double @var{x}, const double @var{sigma}) |
513 |
|
@deftypefunx double gsl_cdf_rayleigh_Q (const double @var{x}, const double @var{sigma}) |
514 |
|
@deftypefunx double gsl_cdf_rayleigh_Pinv (const double @var{P}, const double @var{sigma}) |
515 |
|
@deftypefunx double gsl_cdf_rayleigh_Qinv (const double @var{Q}, const double @var{sigma}) |
516 |
|
These functions compute the cumulative distribution functions |
517 |
|
@math{P(x)}, @math{Q(x)} and their inverses for the Rayleigh |
518 |
|
distribution with scale parameter @var{sigma}. |
519 |
|
@end deftypefun |
520 |
|
|
521 |
@page |
@page |
522 |
@node The Rayleigh Tail Distribution |
@node The Rayleigh Tail Distribution |
523 |
@section The Rayleigh Tail Distribution |
@section The Rayleigh Tail Distribution |
744 |
@deftypefunx double gsl_cdf_gamma_Pinv (double @var{P}, double @var{a}, double @var{b}) |
@deftypefunx double gsl_cdf_gamma_Pinv (double @var{P}, double @var{a}, double @var{b}) |
745 |
@deftypefunx double gsl_cdf_gamma_Qinv (double @var{Q}, double @var{a}, double @var{b}) |
@deftypefunx double gsl_cdf_gamma_Qinv (double @var{Q}, double @var{a}, double @var{b}) |
746 |
These functions compute the cumulative distribution functions |
These functions compute the cumulative distribution functions |
747 |
@math{P(x)} and @math{Q(x)}, and their inverses, for the gamma |
@math{P(x)}, @math{Q(x)} and their inverses for the gamma |
748 |
distribution with parameters @var{a} and @var{b}. |
distribution with parameters @var{a} and @var{b}. |
749 |
@end deftypefun |
@end deftypefun |
750 |
|
|
784 |
\centerline{\input rand-flat.tex} |
\centerline{\input rand-flat.tex} |
785 |
@end tex |
@end tex |
786 |
|
|
787 |
|
@deftypefun double gsl_cdf_flat_P (double @var{x}, double @var{a}, double @var{b}) |
788 |
|
@deftypefunx double gsl_cdf_flat_Q (double @var{x}, double @var{a}, double @var{b}) |
789 |
|
@deftypefunx double gsl_cdf_flat_Pinv (double @var{P}, double @var{a}, double @var{b}) |
790 |
|
@deftypefunx double gsl_cdf_flat_Qinv (double @var{Q}, double @var{a}, double @var{b}) |
791 |
|
These functions compute the cumulative distribution functions |
792 |
|
@math{P(x)}, @math{Q(x)} and their inverses for a uniform distribution |
793 |
|
from @var{a} to @var{b}. |
794 |
|
@end deftypefun |
795 |
|
|
796 |
|
|
797 |
@page |
@page |
798 |
@node The Lognormal Distribution |
@node The Lognormal Distribution |
799 |
@section The Lognormal Distribution |
@section The Lognormal Distribution |
829 |
\centerline{\input rand-lognormal.tex} |
\centerline{\input rand-lognormal.tex} |
830 |
@end tex |
@end tex |
831 |
|
|
832 |
|
@deftypefun double gsl_cdf_lognormal_P (double @var{x}, double @var{zeta}, double @var{sigma}) |
833 |
|
@deftypefunx double gsl_cdf_lognormal_Q (double @var{x}, double @var{zeta}, double @var{sigma}) |
834 |
|
@deftypefunx double gsl_cdf_lognormal_Pinv (double @var{P}, double @var{zeta}, double @var{sigma}) |
835 |
|
@deftypefunx double gsl_cdf_lognormal_Qinv (double @var{Q}, double @var{zeta}, double @var{sigma}) |
836 |
|
These functions compute the cumulative distribution functions |
837 |
|
@math{P(x)}, @math{Q(x)} and their inverses for the lognormal |
838 |
|
distribution with parameters @var{zeta} and @var{sigma}, |
839 |
|
@end deftypefun |
840 |
|
|
841 |
|
|
842 |
@page |
@page |
843 |
@node The Chi-squared Distribution |
@node The Chi-squared Distribution |
844 |
@section The Chi-squared Distribution |
@section The Chi-squared Distribution |
900 |
@deftypefunx double gsl_cdf_chisq_Pinv (double @var{P}, double @var{nu}) |
@deftypefunx double gsl_cdf_chisq_Pinv (double @var{P}, double @var{nu}) |
901 |
@deftypefunx double gsl_cdf_chisq_Qinv (double @var{Q}, double @var{nu}) |
@deftypefunx double gsl_cdf_chisq_Qinv (double @var{Q}, double @var{nu}) |
902 |
These functions compute the cumulative distribution functions |
These functions compute the cumulative distribution functions |
903 |
@math{P(x)} and @math{Q(x)}, and their inverses, for the chi-squared |
@math{P(x)}, @math{Q(x)} and their inverses for the chi-squared |
904 |
distribution with @var{nu} degrees of freedom. |
distribution with @var{nu} degrees of freedom. |
905 |
@end deftypefun |
@end deftypefun |
906 |
|
|
1038 |
@deftypefunx double gsl_cdf_tdist_Pinv (double @var{P}, double @var{nu}) |
@deftypefunx double gsl_cdf_tdist_Pinv (double @var{P}, double @var{nu}) |
1039 |
@deftypefunx double gsl_cdf_tdist_Qinv (double @var{Q}, double @var{nu}) |
@deftypefunx double gsl_cdf_tdist_Qinv (double @var{Q}, double @var{nu}) |
1040 |
These functions compute the cumulative distribution functions |
These functions compute the cumulative distribution functions |
1041 |
@math{P(x)} and @math{Q(x)}, and their inverses, for the t-distribution |
@math{P(x)}, @math{Q(x)} and their inverses for the t-distribution |
1042 |
with @var{nu} degrees of freedom. |
with @var{nu} degrees of freedom. |
1043 |
@end deftypefun |
@end deftypefun |
1044 |
|
|
1121 |
\centerline{\input rand-logistic.tex} |
\centerline{\input rand-logistic.tex} |
1122 |
@end tex |
@end tex |
1123 |
|
|
1124 |
|
@deftypefun double gsl_cdf_logistic_P (const double @var{x}, const double @var{a}) |
1125 |
|
@deftypefunx double gsl_cdf_logistic_Q (const double @var{x}, const double @var{a}) |
1126 |
|
@deftypefunx double gsl_cdf_logistic_Pinv (const double @var{P}, const double @var{a}) |
1127 |
|
@deftypefunx double gsl_cdf_logistic_Qinv (const double @var{Q}, const double @var{a}) |
1128 |
|
These functions compute the cumulative distribution functions |
1129 |
|
@math{P(x)}, @math{Q(x)} and their inverses for the logistic |
1130 |
|
distribution with scale parameter @var{a}. |
1131 |
|
@end deftypefun |
1132 |
|
|
1133 |
@page |
@page |
1134 |
@node The Pareto Distribution |
@node The Pareto Distribution |
1135 |
@section The Pareto Distribution |
@section The Pareto Distribution |
1166 |
\centerline{\input rand-pareto.tex} |
\centerline{\input rand-pareto.tex} |
1167 |
@end tex |
@end tex |
1168 |
|
|
1169 |
|
@deftypefun double gsl_cdf_pareto_P (double @var{x}, double @var{a}, double @var{b}) |
1170 |
|
@deftypefunx double gsl_cdf_pareto_Q (double @var{x}, double @var{a}, double @var{b}) |
1171 |
|
@deftypefunx double gsl_cdf_pareto_Pinv (double @var{P}, double @var{a}, double @var{b}) |
1172 |
|
@deftypefunx double gsl_cdf_pareto_Qinv (double @var{Q}, double @var{a}, double @var{b}) |
1173 |
|
These functions compute the cumulative distribution functions |
1174 |
|
@math{P(x)}, @math{Q(x)} and their inverses for the Pareto |
1175 |
|
distribution with exponent @var{a} and scale @var{b}. |
1176 |
|
@end deftypefun |
1177 |
|
|
1178 |
@page |
@page |
1179 |
@node The Spherical Distribution (2D & 3D) |
@node The Spherical Distribution (2D & 3D) |
1180 |
@section The Spherical Distribution (2D & 3D) |
@section The Spherical Distribution (2D & 3D) |
1195 |
@var{y} be the sine and cosine respectively. Two trig functions would |
@var{y} be the sine and cosine respectively. Two trig functions would |
1196 |
have been expensive in the old days, but with modern hardware |
have been expensive in the old days, but with modern hardware |
1197 |
implementations, this is sometimes the fastest way to go. This is the |
implementations, this is sometimes the fastest way to go. This is the |
1198 |
case for my home Pentium (but not the case for my Sun Sparcstation 20 at |
case for the Pentium (but not the case of a Sun Sparcstation 20). |
1199 |
work). Once can avoid the trig evaluations by choosing @var{x} and |
One can avoid the trigonometric evaluations by choosing @var{x} and |
1200 |
@var{y} in the interior of a unit circle (choose them at random from the |
@var{y} in the interior of a unit circle (choose them at random from the |
1201 |
interior of the enclosing square, and then reject those that are outside |
interior of the enclosing square, and then reject those that are outside |
1202 |
the unit circle), and then dividing by @c{$\sqrt{x^2 + y^2}$} |
the unit circle), and then dividing by @c{$\sqrt{x^2 + y^2}$} |
1277 |
\centerline{\input rand-weibull.tex} |
\centerline{\input rand-weibull.tex} |
1278 |
@end tex |
@end tex |
1279 |
|
|
1280 |
|
@deftypefun double gsl_cdf_weibull_P (double @var{x}, double @var{a}, double @var{b}) |
1281 |
|
@deftypefunx double gsl_cdf_weibull_Q (double @var{x}, double @var{a}, double @var{b}) |
1282 |
|
@deftypefunx double gsl_cdf_weibull_Pinv (double @var{P}, double @var{a}, double @var{b}) |
1283 |
|
@deftypefunx double gsl_cdf_weibull_Qinv (double @var{Q}, double @var{a}, double @var{b}) |
1284 |
|
These functions compute the cumulative distribution functions |
1285 |
|
@math{P(x)}, @math{Q(x)} and their inverses for the Weibull |
1286 |
|
distribution with scale @var{a} and exponent @var{b}. |
1287 |
|
@end deftypefun |
1288 |
|
|
1289 |
|
|
1290 |
@page |
@page |
1291 |
@node The Type-1 Gumbel Distribution |
@node The Type-1 Gumbel Distribution |
1292 |
@section The Type-1 Gumbel Distribution |
@section The Type-1 Gumbel Distribution |
1324 |
\centerline{\input rand-gumbel1.tex} |
\centerline{\input rand-gumbel1.tex} |
1325 |
@end tex |
@end tex |
1326 |
|
|
1327 |
|
@deftypefun double gsl_cdf_gumbel1_P (double @var{x}, double @var{a}, double @var{b}) |
1328 |
|
@deftypefunx double gsl_cdf_gumbel1_Q (double @var{x}, double @var{a}, double @var{b}) |
1329 |
|
@deftypefunx double gsl_cdf_gumbel1_Pinv (double @var{P}, double @var{a}, double @var{b}) |
1330 |
|
@deftypefunx double gsl_cdf_gumbel1_Qinv (double @var{Q}, double @var{a}, double @var{b}) |
1331 |
|
These functions compute the cumulative distribution functions |
1332 |
|
@math{P(x)}, @math{Q(x)} and their inverses for the Type-1 Gumbel |
1333 |
|
distribution with parameters @var{a} and @var{b}. |
1334 |
|
@end deftypefun |
1335 |
|
|
1336 |
|
|
1337 |
@page |
@page |
1338 |
@node The Type-2 Gumbel Distribution |
@node The Type-2 Gumbel Distribution |
1339 |
@section The Type-2 Gumbel Distribution |
@section The Type-2 Gumbel Distribution |
1371 |
\centerline{\input rand-gumbel2.tex} |
\centerline{\input rand-gumbel2.tex} |
1372 |
@end tex |
@end tex |
1373 |
|
|
1374 |
|
@deftypefun double gsl_cdf_gumbel2_P (double @var{x}, double @var{a}, double @var{b}) |
1375 |
|
@deftypefunx double gsl_cdf_gumbel2_Q (double @var{x}, double @var{a}, double @var{b}) |
1376 |
|
@deftypefunx double gsl_cdf_gumbel2_Pinv (double @var{P}, double @var{a}, double @var{b}) |
1377 |
|
@deftypefunx double gsl_cdf_gumbel2_Qinv (double @var{Q}, double @var{a}, double @var{b}) |
1378 |
|
These functions compute the cumulative distribution functions |
1379 |
|
@math{P(x)}, @math{Q(x)} and their inverses for the Type-2 Gumbel |
1380 |
|
distribution with parameters @var{a} and @var{b}. |
1381 |
|
@end deftypefun |
1382 |
|
|
1383 |
|
|
1384 |
@page |
@page |
1385 |
@node General Discrete Distributions |
@node General Discrete Distributions |
1386 |
@section General Discrete Distributions |
@section General Discrete Distributions |