/[gsl]/gsl/doc/randist.texi
ViewVC logotype

Diff of /gsl/doc/randist.texi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.1.3 by bjg, Sun Sep 8 09:54:56 2002 UTC revision 1.1.1.3.8.1 by bjg, Sun Jul 20 15:02:50 2003 UTC
# Line 9  obtained analytically from the uniform d Line 9  obtained analytically from the uniform d
9  generator by applying an appropriate transformation.  This method uses  generator by applying an appropriate transformation.  This method uses
10  one call to the random number generator.  one call to the random number generator.
11    
   
12  More complicated distributions are created by the  More complicated distributions are created by the
13  @dfn{acceptance-rejection} method, which compares the desired  @dfn{acceptance-rejection} method, which compares the desired
14  distribution against a distribution which is similar and known  distribution against a distribution which is similar and known
15  analytically.  This usually requires several samples from the generator.  analytically.  This usually requires several samples from the generator.
16    
17  The functions described in this section are declared in  The library also provides cumulative distribution functions and inverse
18  @file{gsl_randist.h}.  cumulative distribution functions, sometimes referred to as quantile
19    functions.  The cumulative distribution functions and their inverses are
20    computed separately for the upper and lower tails of the distribution,
21    allowing full accuracy to be retained for small results.
22    
23    The functions for random variates and probability density functions
24    described in this section are declared in @file{gsl_randist.h}.  The
25    corresponding cumulative distribution functions are declared in
26    @file{gsl_cdf.h}.
27    
28  @menu  @menu
29    * Random Number Distribution Introduction::  
30  * The Gaussian Distribution::    * The Gaussian Distribution::  
31  * The Gaussian Tail Distribution::    * The Gaussian Tail Distribution::  
32  * The Bivariate Gaussian Distribution::    * The Bivariate Gaussian Distribution::  
# Line 58  The functions described in this section Line 66  The functions described in this section
66  * Random Number Distribution References and Further Reading::    * Random Number Distribution References and Further Reading::  
67  @end menu  @end menu
68    
69    @node Random Number Distribution Introduction
70    @section Introduction
71    
72    Continuous random number distributions are defined by a probability
73    density function, @math{p(x)}, such that the probability of @math{x}
74    occurring in the infinitesimal range @math{x} to @math{x+dx} is @c{$p\,dx$}
75    @math{p dx}.
76    
77    The cumulative distribution function for the lower tail is defined by,
78    @tex
79    \beforedisplay
80    $$
81    P(x) = \int_{-\infty}^{x} dx' p(x')
82    $$
83    \afterdisplay
84    @end tex
85    @ifinfo
86    @example
87    P(x) = \int_@{-\infty@}^@{x@} dx' p(x')
88    @end example
89    @end ifinfo
90    @noindent
91    and gives the probability of a variate taking a value less than @math{x}.
92    
93    The cumulative distribution function for the upper tail is defined by,
94    @tex
95    \beforedisplay
96    $$
97    Q(x) = \int_{x}^{-\infty} dx' p(x')
98    $$
99    \afterdisplay
100    @end tex
101    @ifinfo
102    @example
103    P(x) = \int_@{x@}^@{-\infty@} dx' p(x')
104    @end example
105    @end ifinfo
106    @noindent
107    and gives the probability of a variate taking a greater than @math{x}.
108    The upper and lower cumulative distribution functions are related by
109    @math{P(x) + Q(x) = 1}
110    
111    The inverse cumulative distributions, @c{$P^{-1}(x)$}
112    @math{P^@{-1@}(x)} and @c{$Q^{-1}(x)$}
113    @math{Q^@{-1@}(x)} give the value of @math{x}
114    which corresponds to a given value of @math{P} or {Q}.  
115    They can be used to find confidence limits from probability values.
116    
117  @page  @page
118  @node The Gaussian Distribution  @node The Gaussian Distribution
119  @section The Gaussian Distribution  @section The Gaussian Distribution
# Line 98  the formula given above. Line 154  the formula given above.
154  \centerline{\input rand-gaussian.tex}  \centerline{\input rand-gaussian.tex}
155  @end tex  @end tex
156    
157  @deftypefun double gsl_ran_gaussian_ratio_method (const gsl_rng * @var{r}, const double @var{sigma})  @deftypefun double gsl_ran_gaussian_ratio_method (const gsl_rng * @var{r}, double @var{sigma})
158  This function computes a gaussian random variate using the  This function computes a gaussian random variate using the
159  Kinderman-Monahan ratio method.  Kinderman-Monahan ratio method.
160  @end deftypefun  @end deftypefun
# Line 111  are equivalent to the functions above wi Line 167  are equivalent to the functions above wi
167  @var{sigma} = 1.  @var{sigma} = 1.
168  @end deftypefn  @end deftypefn
169    
170    @deftypefun double gsl_cdf_gaussian_P (double @var{x}, double @var{sigma})
171    @deftypefunx double gsl_cdf_gaussian_Q (double @var{x}, double @var{sigma})
172    @deftypefunx double gsl_cdf_gaussian_Pinv (double @var{P}, double @var{sigma})
173    @deftypefunx double gsl_cdf_gaussian_Qinv (double @var{Q}, double @var{sigma})
174    These functions compute the cumulative distribution functions
175    @math{P(x)} and @math{Q(x)}, and their inverses, for the Gaussian
176    distribution with standard deviation @var{sigma}.
177    @end deftypefun
178    
179    @deftypefun double gsl_cdf_ugaussian_P (double @var{x})
180    @deftypefunx double gsl_cdf_ugaussian_Q (double @var{x})
181    @deftypefunx double gsl_cdf_ugaussian_Pinv (double @var{P})
182    @deftypefunx double gsl_cdf_ugaussian_Qinv (double @var{Q})
183    These functions compute the cumulative distribution functions
184    @math{P(x)} and @math{Q(x)}, and their inverses, for the unit Gaussian
185    distribution.
186    @end deftypefun
187    
188  @page  @page
189  @node The Gaussian Tail Distribution  @node The Gaussian Tail Distribution
190  @section The Gaussian Tail Distribution  @section The Gaussian Tail Distribution
# Line 254  given above. Line 328  given above.
328  \centerline{\input rand-exponential.tex}  \centerline{\input rand-exponential.tex}
329  @end tex  @end tex
330    
331    @deftypefun double gsl_cdf_exponential_P (double @var{x}, double @var{mu})
332    @deftypefunx double gsl_cdf_exponential_Q (double @var{x}, double @var{mu})
333    @deftypefunx double gsl_cdf_exponential_Pinv (double @var{P}, double @var{mu})
334    @deftypefunx double gsl_cdf_exponential_Qinv (double @var{Q}, double @var{mu})
335    These functions compute the cumulative distribution functions
336    @math{P(x)} and @math{Q(x)}, and their inverses, for the exponential
337    distribution with mean @var{mu}.
338    @end deftypefun
339    
340  @page  @page
341  @node The Laplace Distribution  @node The Laplace Distribution
342  @section The Laplace Distribution  @section The Laplace Distribution
# Line 624  formula given above. Line 707  formula given above.
707  \centerline{\input rand-gamma.tex}  \centerline{\input rand-gamma.tex}
708  @end tex  @end tex
709    
710    @deftypefun double gsl_cdf_gamma_P (double @var{x}, double @var{a}, double @var{b})
711    @deftypefunx double gsl_cdf_gamma_Q (double @var{x}, double @var{a}, double @var{b})
712    @deftypefunx double gsl_cdf_gamma_Pinv (double @var{P}, double @var{a}, double @var{b})
713    @deftypefunx double gsl_cdf_gamma_Qinv (double @var{Q}, double @var{a}, double @var{b})
714    These functions compute the cumulative distribution functions
715    @math{P(x)} and @math{Q(x)}, and their inverses, for the gamma
716    distribution with parameters @var{a} and @var{b}.
717    @end deftypefun
718    
719  @page  @page
720  @node The Flat (Uniform) Distribution  @node The Flat (Uniform) Distribution
721  @section The Flat (Uniform) Distribution  @section The Flat (Uniform) Distribution
# Line 751  the formula given above. Line 843  the formula given above.
843  \centerline{\input rand-chisq.tex}  \centerline{\input rand-chisq.tex}
844  @end tex  @end tex
845    
846    @deftypefun double gsl_cdf_chisq_P (double @var{x}, double @var{nu})
847    @deftypefunx double gsl_cdf_chisq_Q (double @var{x}, double @var{nu})
848    @deftypefunx double gsl_cdf_chisq_Pinv (double @var{P}, double @var{nu})
849    @deftypefunx double gsl_cdf_chisq_Qinv (double @var{Q}, double @var{nu})
850    These functions compute the cumulative distribution functions
851    @math{P(x)} and @math{Q(x)}, and their inverses, for the chi-squared
852    distribution with @var{nu} degrees of freedom.
853    @end deftypefun
854    
855    
856    
857  @page  @page
858  @node The F-distribution  @node The F-distribution
859  @section The F-distribution  @section The F-distribution
# Line 814  using the formula given above. Line 917  using the formula given above.
917  \centerline{\input rand-fdist.tex}  \centerline{\input rand-fdist.tex}
918  @end tex  @end tex
919    
920    @deftypefun double gsl_cdf_Fdist_P (double @var{x}, double @var{nu1}, double @var{nu2})
921    @deftypefunx double gsl_cdf_Fdist_Q (double @var{x}, double @var{nu1}, double @var{nu2})
922    These functions compute the cumulative distribution functions
923    @math{P(x)} and @math{Q(x)} for the F-distribution with @var{nu1} and
924    @var{nu2} degrees of freedom.
925    @end deftypefun
926    
927  @page  @page
928  @node The t-distribution  @node The t-distribution
929  @section The t-distribution  @section The t-distribution
# Line 871  given above. Line 981  given above.
981  \centerline{\input rand-tdist.tex}  \centerline{\input rand-tdist.tex}
982  @end tex  @end tex
983    
984    @deftypefun double gsl_cdf_tdist_P (double @var{x}, double @var{nu})
985    @deftypefunx double gsl_cdf_tdist_Q (double @var{x}, double @var{nu})
986    @deftypefunx double gsl_cdf_tdist_Pinv (double @var{P}, double @var{nu})
987    @deftypefunx double gsl_cdf_tdist_Qinv (double @var{Q}, double @var{nu})
988    These functions compute the cumulative distribution functions
989    @math{P(x)} and @math{Q(x)}, and their inverses, for the t-distribution
990    with @var{nu} degrees of freedom.
991    @end deftypefun
992    
993  @page  @page
994  @node The Beta Distribution  @node The Beta Distribution
995  @section The Beta Distribution  @section The Beta Distribution
# Line 907  formula given above. Line 1026  formula given above.
1026  \centerline{\input rand-beta.tex}  \centerline{\input rand-beta.tex}
1027  @end tex  @end tex
1028    
1029    @deftypefun double gsl_cdf_beta_P (double @var{x}, double @var{a}, double @var{b})
1030    @deftypefunx double gsl_cdf_beta_Q (double @var{x}, double @var{a}, double @var{b})
1031    These functions compute the cumulative distribution functions
1032    @math{P(x)} and @math{Q(x)} for the beta distribution with
1033    parameters @var{a} and @var{b}.
1034    @end deftypefun
1035    
1036  @page  @page
1037  @node The Logistic Distribution  @node The Logistic Distribution
1038  @section The Logistic Distribution  @section The Logistic Distribution
# Line 1744  Example output from the program, three 1 Line 1870  Example output from the program, three 1
1870  \centerline{\input random-walk.tex}  \centerline{\input random-walk.tex}
1871  @end tex  @end tex
1872    
1873    The following program computes the upper and lower cumulative
1874    distribution functions for the standard normal distribution at
1875    @math{x=2}.
1876    
1877    @example
1878    #include <stdio.h>
1879    #include <gsl/gsl_cdf.h>
1880    
1881    int
1882    main (void)
1883    @{
1884      double P, Q;
1885      double x = 2.0;
1886    
1887      P = gsl_cdf_ugaussian_P (x);
1888      printf ("prob(x < %f) = %f\n", x, P);
1889    
1890      Q = gsl_cdf_ugaussian_Q (x);
1891      printf ("prob(x > %f) = %f\n", x, Q);
1892    
1893      x = gsl_cdf_ugaussian_Pinv (P);
1894      printf ("Pinv(%f) = %f\n", P, x);
1895    
1896      x = gsl_cdf_ugaussian_Qinv (Q);
1897      printf ("Qinv(%f) = %f\n", Q, x);
1898    
1899      return 0;
1900    @}
1901    @end example
1902    @noindent
1903    Here is the output of the program,
1904    
1905    @example
1906    prob(x < 2.000000) = 0.977250
1907    prob(x > 2.000000) = 0.022750
1908    Pinv(0.977250) = 2.000000
1909    Qinv(0.022750) = 2.000000
1910    @end example
1911    
1912  @node Random Number Distribution References and Further Reading  @node Random Number Distribution References and Further Reading
1913  @section References and Further Reading  @section References and Further Reading
1914  @noindent  @noindent
# Line 1782  R.M. Barnett et al., Physical Review D54 Line 1947  R.M. Barnett et al., Physical Review D54
1947  @noindent  @noindent
1948  The Review of Particle Physics is available online in postscript and pdf  The Review of Particle Physics is available online in postscript and pdf
1949  format.  format.
1950    
1951    @noindent
1952    An overview of methods used to compute cumulative distribution functions
1953    can be found in @cite{Statistical Computing} by W.J. Kennedy and
1954    J.E. Gentle. Another general reference is @cite{Elements of Statistical
1955    Computing} by R.A. Thisted.
1956    
1957    @itemize @asis
1958    @item
1959    William E. Kennedy and James E. Gentle, @cite{Statistical Computing} (1980),
1960    Marcel Dekker, ISBN 0-8247-6898-1.
1961    @end itemize
1962    
1963    @itemize @asis
1964    @item
1965    Ronald A. Thisted, @cite{Elements of Statistical Computing} (1988),
1966    Chapman & Hall, ISBN 0-412-01371-1.
1967    @end itemize
1968    @noindent
1969    The cumulative distribution functions for the Gaussian distribution
1970    are based on the following papers,
1971    
1972    @itemize @asis
1973    @item
1974    @cite{Rational Chebyshev Approximations Using Linear Equations},
1975    W.J. Cody, W. Fraser, J.F. Hart. Numerische Mathematik 12, 242-251 (1968).
1976    @end itemize
1977    
1978    @itemize @asis
1979    @item
1980    @cite{Rational Chebyshev Approximations for the Error Function},
1981    W.J. Cody. Mathematics of Computation 23, n107, 631-637 (July 1969).
1982    @end itemize

Legend:
Removed from v.1.1.1.3  
changed lines
  Added in v.1.1.1.3.8.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26