1 @c -*- mode: texinfo -*-
3 * Introduction to distrib::
4 * Functions and Variables for continuous distributions::
5 * Functions and Variables for discrete distributions::
8 @c Define an m4 macro for the NormalRV function that is used below.
9 @c Can't use @macro because m4 is processed too late for this to work.
10 m4_define(<<<m4_Normal_RV>>>,
11 m4_math(<<<{\it Normal}($1, $2)>>>, <<<Normal($1, $2)>>>))
13 @c Define the function student t to denote Student's t random variable
14 m4_define(<<<m4_Student_T_RV>>>,
17 @c Define noncentral Student's t RV
18 m4_define(<<<m4_Noncentral_T_RV>>>,
19 m4_math(<<<{\it nc\_t}($1, $2)>>>,<<<nc_t($1, $2)>>>))
21 @c Define Chi^2(n), the chi-squared random variate function.
22 m4_define(<<<m4_Chi2_RV>>>,
23 m4_math(<<<\chi^2($1)>>>, <<<Chi^2($2)>>>))
25 @c Define the Gamma RV
26 m4_define(<<<m4_Gamma_RV>>>,
27 m4_math(<<<\Gamma\left($1,$2\right)>>>, <<<Gamma($1,$2)>>>))
29 @c Define the noncentral chi-squared RV
30 m4_define(<<<m4_noncentral_chi2_RV>>>,
31 m4_math(<<<{\it nc\_Chi}^2($1,$2)>>>, <<<nc_Chi^2($1,$2)>>>))
33 @c Define the exponential RV
34 m4_define(<<<m4_Exponential_RV>>>,
35 m4_math(<<<{\it Exponential}($1)>>>, <<<Exponential($1)>>>))
37 @c Define the Weibull RV
38 m4_define(<<<m4_Weibull_RV>>>,
39 m4_math(<<<{\it Weibull}($1,$2)>>>, <<<Weibull($1,$2)>>>))
41 @c Define lognormal RV
42 m4_define(<<<m4_Lognormal_RV>>>,
43 m4_math(<<<{\it Lognormal}($1,$2)>>>,<<<Lognormal($1,$2)>>>))
46 m4_define(<<<m4_Beta_RV>>>,
47 m4_math(<<<{\it Beta}($1,$2)>>>,<<<Beta($1,$2)>>>))
49 @c Define continuous uniform RV
50 m4_define(<<<m4_Continuous_Uniform_RV>>>,
52 ContinuousUniform}($1,$2)>>>,<<<ContinuousUniform($1,$2)>>>))
55 m4_define(<<<m4_Logistic_RV>>>,
56 m4_math(<<<{\it Logistic}($1,$2)>>>,<<<<Logistice($1,$2)>>>))
59 m4_define(<<<m4_Pareto_RV>>>,
60 m4_math(<<<{\it Pareto}($1,$2)>>>,<<<Pareto($1,$2)>>>))
63 m4_define(<<<m4_Rayleigh_RV>>>,
64 m4_math(<<<{\it Rayleigh}($1)>>>,<<<Rayleigh($1)>>>))
67 m4_define(<<<m4_Laplace_RV>>>,
68 m4_math(<<<{\it Laplace}($1,$2)>>>,<<<Laplace($1,$2)>>>))
71 m4_define(<<<m4_Cauchy_RV>>>,
72 m4_math(<<<{\it Cauchy}($1,$2)>>>,<<<Cauchy($1,$2)>>>))
75 m4_define(<<<m4_Gumbel_RV>>>,
76 m4_math(<<<{\it Gumbel}($1,$2)>>>,<<<Gumbel($1,$2)>>>))
79 m4_define(<<<m4_Binomial_RV>>>,
80 m4_math(<<<{\it Binomial}($1,$2)>>>,<<<Binomial($1,$2)>>>))
83 m4_define(<<<m4_Poisson_RV>>>,
84 m4_math(<<<{\it Poisson}($1)>>>,<<<Poisson($1)>>>))
86 @c Define Bernoulli RV
87 m4_define(<<<m4_Bernoulli_RV>>>,
88 m4_math(<<<{\it Bernoulli}($1)>>>,<<<Bernoulli($1)>>>))
90 @c Define Geometric RV
91 m4_define(<<<m4_Geometric_RV>>>,
92 m4_math(<<<{\it Geometric}($1)>>>,<<<Geometric($1)>>>))
94 @c Define Discrete Uniform RV
95 m4_define(<<<m4_DiscreteUniform_RV>>>,
96 m4_math(<<<{\it DiscreteUniform}($1)>>>,<<<DiscreteUniform($1)>>>))
98 @c Define Hypergeometric RV
99 m4_define(<<<m4_Hypergeometric_RV>>>,
100 m4_math(<<<{\it Hypergeometric}($1,$2,$3)>>>,<<<Hypergeometric($1,$2,$3)>>>))
102 @c Define Negative Binomial RV
103 m4_define(<<<m4_NegativeBinomial_RV>>>,
104 m4_math(<<<{\it NegativeBinomial}($1,$2)>>>,<<<NegativeBinomial($1,$2)>>>))
107 @node Introduction to distrib, Functions and Variables for continuous distributions, , Package distrib
108 @section Introduction to distrib
111 Package @code{distrib} contains a set of functions for making probability computations on both discrete and continuous univariate models.
113 What follows is a short reminder of basic probabilistic related definitions.
115 Let @math{f(x)} be the @var{density function} of an absolute continuous random variable @math{X}. The @var{cumulative distribution function} is defined as
117 <<<F\left(x\right)=\int_{ -\infty }^{x}{f\left(u\right)\;du}>>>,
129 which equals the probability
130 m4_mathdot(<<<{\rm Pr}(X \le x)>>>, <<<Pr(X <= x)>>>)
132 The @var{mean} value is a localization parameter and is defined as
134 <<<E\left[X\right]=\int_{ -\infty }^{\infty }{x\,f\left(x\right)\;dx}>>>,
147 The @var{variance} is a measure of variation,
149 <<<V\left[X\right]=\int_{ -\infty }^{\infty }{f\left(x\right)\,\left(x
150 -E\left[X\right]\right)^2\;dx}>>>,
156 V[X] = I f(x) (x - E[X]) dx
162 which is a positive real number. The square root of the variance is
163 the @var{standard deviation},
164 m4_mathcomma(<<<D[x]=\sqrt{V[X]}>>>, <<<D[X]=sqrt(V[X])>>>)
165 and it is another measure of variation.
167 The @var{skewness coefficient} is a measure of non-symmetry,
169 <<<SK\left[X\right]={{\int_{ -\infty }^{\infty }{f\left(x\right)\,
170 \left(x-E\left[X\right]\right)^3\;dx}}\over{D\left[X\right]^3}}>>>,
176 SK[X] = ----- I f(x) (x - E[X]) dx
183 And the @var{kurtosis coefficient} measures the peakedness of the distribution,
185 <<<KU\left[X\right]={{\int_{ -\infty }^{\infty }{f\left(x\right)\,
186 \left(x-E\left[X\right]\right)^4\;dx}}\over{D\left[X\right]^4}}-3>>>,
192 KU[X] = ----- I f(x) (x - E[X]) dx - 3
198 If @math{X} is gaussian, @math{KU[X]=0}. In fact, both skewness and kurtosis are shape parameters used to measure the non--gaussianity of a distribution.
200 If the random variable @math{X} is discrete, the density, or @var{probability}, function @math{f(x)} takes positive values within certain countable set of numbers @math{x_i}, and zero elsewhere. In this case, the cumulative distribution function is
202 <<< F\left(x\right)=\sum_{x_{i}\leq x}{f\left(x_{i}\right)} >>>,
215 The mean, variance, standard deviation, skewness coefficient and kurtosis coefficient take the form
218 E\left[X\right]&=\sum_{x_{i}}{x_{i}f\left(x_{i}\right)}, \cr
219 V\left[X\right]&=\sum_{x_{i}}{f\left(x_{i}\right)\left(x_{i}-E\left[X\right]\right)^2},\cr
220 D\left[X\right]&=\sqrt{V\left[X\right]},\cr
221 SK\left[X\right]&={{\sum_{x_{i}}{f\left(x\right)\,
222 \left(x-E\left[X\right]\right)^3\;dx}}\over{D\left[X\right]^3}}, \cr
223 KU\left[X\right]&={{\sum_{x_{i}}{f\left(x\right)\,
224 \left(x-E\left[X\right]\right)^4\;dx}}\over{D\left[X\right]^4}}-3,
238 V[X] = > f(x ) (x - E[X]) ,
248 SK[X] = ------- > f(x ) (x - E[X])
256 KU[X] = ------- > f(x ) (x - E[X]) - 3 ,
265 There is a naming convention in package @code{distrib}. Every function name has two parts, the first one makes reference to the function or parameter we want to calculate,
268 Density function (pdf_*)
269 Distribution function (cdf_*)
270 Quantile (quantile_*)
273 Standard deviation (std_*)
274 Skewness coefficient (skewness_*)
275 Kurtosis coefficient (kurtosis_*)
276 Random variate (random_*)
279 The second part is an explicit reference to the probabilistic model,
281 Continuous distributions:
285 Noncentral Chi^2 (*noncentral_chi2)
288 Lognormal (*lognormal)
291 Continuous uniform (*continuous_uniform)
300 Discrete distributions:
303 Bernoulli (*bernoulli)
304 Geometric (*geometric)
305 Discrete uniform (*discrete_uniform)
306 hypergeometric (*hypergeometric)
307 Negative binomial (*negative_binomial)
308 Finite discrete (*general_finite_discrete)
311 For example, @code{pdf_student_t(x,n)} is the density function of the Student distribution with @var{n} degrees of freedom, @code{std_pareto(a,b)} is the standard deviation of the Pareto distribution with parameters @var{a} and @var{b} and @code{kurtosis_poisson(m)} is the kurtosis coefficient of the Poisson distribution with mean @var{m}.
314 In order to make use of package @code{distrib} you need first to load it by typing
316 (%i1) load("distrib")$
319 For comments, bugs or suggestions, please contact the author at @var{'riotorto AT yahoo DOT com'}.
321 @opencatbox{Categories:}
322 @category{Statistical functions}
323 @category{Share packages}
324 @category{Package distrib}
330 @node Functions and Variables for continuous distributions, Functions and Variables for discrete distributions, Introduction to distrib, Package distrib
331 @section Functions and Variables for continuous distributions
332 Maxima knows the following kinds of continuous distributions.
335 * Normal Random Variable::
336 * Student's t Random Variable::
337 * Noncentral Student's t Random Variable::
338 * Chi-squared Random Variable::
339 * Noncentral Chi-squared Random Variable::
340 * F Random Variable::
341 * Exponential Random Variable::
342 * Lognormal Random Variable::
343 * Gamma Random Variable::
344 * Beta Random Variable::
345 * Continuous Uniform Random Variable::
346 * Logistic Random Variable::
347 * Pareto Random Variable::
348 * Weibull Random Variable::
349 * Rayleigh Random Variable::
350 * Laplace Random Variable::
351 * Cauchy Random Variable::
352 * Gumbel Random Variable::
355 @node Normal Random Variable, Student's t Random Variable, Functions and Variables for continuous distributions, Functions and Variables for continuous distributions
356 @subsection Normal Random Variable
358 Normal random variables (also called Gaussian) is denoted
362 @math{m} is the mean and @math{s > 0} is the standard deviation.
365 @deffn {Function} pdf_normal (@var{x},@var{m},@var{s})
366 Returns the value at @var{x} of the density function of a
368 random variable, with @math{s>0}. To make use of this function, write first @code{load("distrib")}.
372 <<<f(x; m, s) = {1\over s\sqrt{2\pi}} e^{\displaystyle -{(x-m)^2\over 2s^2}}>>>,
381 f(x, m, s) = -------------------
386 @opencatbox{Categories:}
387 @category{Package distrib}
394 @deffn {Function} cdf_normal (@var{x},@var{m},@var{s})
395 Returns the value at @var{x} of the cumulative distribution function of a
397 random variable, with @math{s>0}. This function is defined in terms of Maxima's built-in error function @code{erf}.
399 The cdf can be written analytically:
401 <<<F(x; m, s) = {1\over 2} + {1\over 2} {\rm erf}\left(x-m\over s\sqrt{2}\right)>>>,
407 F(x, m, s) = -------------- + -
414 @c cdf_normal(x,m,s);
417 (%i1) load ("distrib")$
419 (%i2) cdf_normal(x,m,s);
423 (%o2) -------------- + -
428 See also @mrefdot{erf}
430 @opencatbox{Categories:}
431 @category{Package distrib}
437 @anchor{quantile_normal}
438 @deffn {Function} quantile_normal (@var{q},@var{m},@var{s})
439 Returns the @var{q}-quantile of a
441 random variable, with @math{s>0}; in other words, this is the inverse of @mrefdot{cdf_normal} Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
445 @c quantile_normal(95/100,0,1);
449 (%i1) load ("distrib")$
451 (%i2) quantile_normal(95/100,0,1);
453 (%o2) sqrt(2) inverse_erf(--)
458 (%o3) 1.644853626951472
462 @opencatbox{Categories:}
463 @category{Package distrib}
470 @deffn {Function} mean_normal (@var{m},@var{s})
471 Returns the mean of a
473 random variable, with @math{s>0}. To make use of this function, write first @code{load("distrib")}.
484 @opencatbox{Categories:}
485 @category{Package distrib}
492 @deffn {Function} var_normal (@var{m},@var{s})
493 Returns the variance of a
495 random variable, with @math{s>0}. To make use of this function, write first @code{load("distrib")}.
507 @opencatbox{Categories:}
508 @category{Package distrib}
514 @deffn {Function} std_normal (@var{m},@var{s})
515 Returns the standard deviation of a
517 random variable, with @math{s>0}, namely @var{s}. To make use of this function, write first @code{load("distrib")}.
519 The standard deviation is
528 @opencatbox{Categories:}
529 @category{Package distrib}
535 @anchor{skewness_normal}
536 @deffn {Function} skewness_normal (@var{m},@var{s})
537 Returns the skewness coefficient of a
539 random variable, with @math{s>0}. To make use of this function, write first @code{load("distrib")}.
541 The skewness coefficient is
549 @opencatbox{Categories:}
550 @category{Package distrib}
556 @anchor{kurtosis_normal}
557 @deffn {Function} kurtosis_normal (@var{m},@var{s})
558 Returns the kurtosis coefficient of a
560 random variable, with @math{s>0}, which is always equal to 0. To make use of this function, write first @code{load("distrib")}.
562 The kurtosis coefficient is
572 @opencatbox{Categories:}
573 @category{Package distrib}
579 @anchor{random_normal}
580 @deffn {Function} random_normal (@var{m},@var{s}) @
581 @fname{random_normal} (@var{m},@var{s},@var{n})
585 random variate, with @math{s>0}. Calling @code{random_normal} with a third argument @var{n}, a random sample of size @var{n} will be simulated.
587 This is an implementation of the Box-Mueller algorithm, as described in Knuth, D.E. (1981) @var{Seminumerical Algorithms. The Art of Computer Programming.} Addison-Wesley.
589 To make use of this function, write first @code{load("distrib")}.
591 @opencatbox{Categories:}
592 @category{Package distrib}
593 @category{Random numbers}
598 @node Student's t Random Variable, Noncentral Student's t Random Variable, Normal Random Variable, Functions and Variables for continuous distributions
599 @subsection Student's t Random Variable
602 Student's t random variable is denoted by
605 @math{n} is the degrees of freedom with @math{n > 0}. If @math{Z} is
608 variable and @math{V} is an
610 m4_math(\chi^2, chi^2)
611 random variable with @math{n} degress of
615 <<<Z \over \sqrt{V/n}>>>,
616 <<<@math{Z/sqrt(V/n)}>>>)
618 has a Student's @math{t}-distribution with @math{n} degrees of freedom.
620 @anchor{pdf_student_t}
621 @deffn {Function} pdf_student_t (@var{x},@var{n})
622 Returns the value at @var{x} of the density function of a Student
625 , with @math{n>0} degrees of freedom. To make use of this function, write first @code{load("distrib")}.
629 <<<f(x; n) = \left[\sqrt{n} B\left({1\over 2}, {n\over 2}\right)\right]^{-1}
630 \left(1+{x^2\over n}\right)^{\displaystyle -{n+1\over 2}}>>>,
636 gamma(-----) (-- + 1)
638 f(x, n) = ------------------------------
640 sqrt(%pi) gamma(-) sqrt(n)
643 @math{(sqrt(n)*beta(1/2,n/2))^(-1) (1+x^2/n)^(-(n+1)/2)}>>>)
645 @opencatbox{Categories:}
646 @category{Package distrib}
652 @anchor{cdf_student_t}
653 @deffn {Function} cdf_student_t (@var{x},@var{n})
654 Returns the value at @var{x} of the cumulative distribution function of a Student
657 , with @math{n>0} degrees of freedom.
663 1-\displaystyle{1\over 2} I_t\left({n\over 2}, {1\over 2}\right) & $x \ge 0$ \cr
665 \displaystyle{1\over 2} I_t\left({n\over 2}, {1\over 2}\right) & $x < 0$
669 [ 1-1/2*I_t(n/2, 1/2) x >= 0
671 [ 1/2*I_t(n/2, 1/2) x < 0
676 m4_math(<<<t = n/(n+x^2)>>>, <<<t = n/(n+x^2)>>>)
678 m4_math(<<<I_t(a,b)>>>, <<<I_t(a,b)>>>)
680 @ref{beta_incomplete_regularized} function.
684 @c cdf_student_t(1/2, 7/3);
688 (%i1) load ("distrib")$
690 (%i2) cdf_student_t(1/2, 7/3);
692 beta_incomplete_regularized(-, -, --)
694 (%o2) 1 - -------------------------------------
699 (%o3) 0.6698450596140415
703 @opencatbox{Categories:}
704 @category{Package distrib}
710 @anchor{quantile_student_t}
711 @deffn {Function} quantile_student_t (@var{q},@var{n})
712 Returns the @var{q}-quantile of a Student random variable
714 , with @math{n>0}; in other words, this is the inverse of @code{cdf_student_t}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
716 @opencatbox{Categories:}
717 @category{Package distrib}
723 @anchor{mean_student_t}
724 @deffn {Function} mean_student_t (@var{n})
725 Returns the mean of a Student random variable
727 , with @math{n>0}. To make use of this function, write first @code{load("distrib")}.
737 @opencatbox{Categories:}
738 @category{Package distrib}
744 @anchor{var_student_t}
745 @deffn {Function} var_student_t (@var{n})
746 Returns the variance of a Student random variable
752 <<<V[X] = {n\over n-2}>>>,
766 (%i1) load ("distrib")$
768 (%i2) var_student_t(n);
775 @opencatbox{Categories:}
776 @category{Package distrib}
782 @anchor{std_student_t}
783 @deffn {Function} std_student_t (@var{n})
784 Returns the standard deviation of a Student random variable
786 , with @math{n>2}. To make use of this function, write first @code{load("distrib")}.
788 The standard deviation is
790 <<<D[X] = \sqrt{\displaystyle{n\over n-2}}>>>,
800 @opencatbox{Categories:}
801 @category{Package distrib}
807 @anchor{skewness_student_t}
808 @deffn {Function} skewness_student_t (@var{n})
809 Returns the skewness coefficient of a Student random variable
811 , with @math{n>3}, which is always equal to 0. To make use of this function, write first @code{load("distrib")}.
813 The skewness coefficient is
822 @opencatbox{Categories:}
823 @category{Package distrib}
829 @anchor{kurtosis_student_t}
830 @deffn {Function} kurtosis_student_t (@var{n})
831 Returns the kurtosis coefficient of a Student random variable
833 , with @math{n>4}. To make use of this function, write first @code{load("distrib")}.
835 The kurtosis coefficient is
837 <<<KU[X] = {6\over n-4}>>>,
846 @opencatbox{Categories:}
847 @category{Package distrib}
853 @anchor{random_student_t}
854 @deffn {Function} random_student_t (@var{n}) @
855 @fname{random_student_t} (@var{n},@var{m})
857 Returns a Student random variate
859 , with @math{n>0}. Calling @code{random_student_t} with a second argument @var{m}, a random sample of size @var{m} will be simulated.
861 The implemented algorithm is based on the fact that if @math{Z} is a
862 normal random variable
866 m4_math(\chi^2, chi squared)
867 random variable with @math{n} degrees of
873 <<<X={{Z}\over{\sqrt{{S^2}\over{n}}}}>>>,
884 is a Student random variable with @math{n} degrees of freedom,
888 To make use of this function, write first @code{load("distrib")}.
890 @opencatbox{Categories:}
891 @category{Package distrib}
892 @category{Random numbers}
897 @node Noncentral Student's t Random Variable, Chi-squared Random Variable, Student's t Random Variable, Functions and Variables for continuous distributions
898 @subsection Noncentral Student's t Random Variable
900 Let @math{ncp} be the non-centrality parameter, @math{n} be the
901 degrees of freedom for the non-central Student's @math{t} random
904 Then let @math{X} be a
908 m4_math(\chi^2, chi squared)
909 random variable with @math{n} degrees of freedom, the
912 <<<U = {X \over \sqrt{S^2\over n}}>>>,
913 <<<@math{U = X/sqrt(S^2/n)}>>>)
915 has a non-central Student's @math{t} distribution with non-centrality
916 parameter @math{ncp}.
918 @anchor{pdf_noncentral_student_t}
919 @deffn {Function} pdf_noncentral_student_t (@var{x},@var{n},@var{ncp})
920 Returns the value at @var{x} of the density function of a noncentral
921 Student random variable
922 m4_Noncentral_T_RV(n,ncp)
923 , with @math{n>0} degrees of freedom and noncentrality parameter @math{ncp}. To make use of this function, write first @code{load("distrib")}.
927 <<<f(x; n, \mu) = \left[\sqrt{n} B\left({1\over 2}, {n\over
928 2}\right)\right]^{-1}\left(1+{x^2\over n}\right)^{-{(n+1)/2}}
930 \bigg[A_n(x; \mu) + B_n(x; \mu)\bigg]>>>,
937 %e (x + 1) (B(x, n, mu) + An(x, n, mu))
938 f(x;n,mu) = -------------------------------------------------
948 A_n(x;\mu) &= {}_1F_1\left({n+1\over 2}; {1\over 2}; {\mu^2 x^2\over
949 2\left(x^2+n\right)}\right) \cr
950 B_n(x;\mu) &= {\sqrt{2}\mu x \over \sqrt{x^2+n}} {\Gamma\left({n\over
951 2} + 1\right)\over \Gamma\left({n+1\over 2}\right)}\;
952 {}_1F_1\left({n\over 2} + 1; {3\over 2}; {\mu^2 x^2\over
953 2\left(x^2+n\right)}\right)
959 A(x, n, mu) = %f ([-----], [-], ----------)
965 sqrt(2) mu %f ([- + 1], [-], ----------) gamma(- + 1) x
968 B(x, n, mu) = ----------------------------------------------------------
970 gamma(-----) sqrt(x + n)
976 is the non-centrality parameter @math{ncp}.
978 Sometimes an extra work is necessary to get the final result.
982 @c expand(pdf_noncentral_student_t(3,5,0.1));
986 (%i1) load ("distrib")$
988 (%i2) expand(pdf_noncentral_student_t(3,5,0.1));
989 rat: replaced 0.01889822365046136 by 15934951/843198350 = 0.01889822365046136
991 rat: replaced -8.734356480209641 by -294697965/33740089 = -8.734356480209641
993 rat: replaced 4.136255165816327 by 51033443/12338079 = 4.136255165816332
995 rat: replaced 1.08061432164203 by 56754827/52520891 = 1.08061432164203
997 rat: replaced 0.0565127306411839 by 5608717/99246965 = 0.05651273064118384
999 rat: replaced -300.8069396896258 by -79782423/265228 = -300.8069396896256
1001 rat: replaced 160.6269176184973 by 178374907/1110492 = 160.626917618497
1003 0.04296414417400905 5 1.323650307289301e-6 5
1004 (%o2) ------------------------ + -------------------------
1008 1.94793720435093e-4 5
1009 + ------------------------
1014 (%o3) 0.02080593159405671
1018 @opencatbox{Categories:}
1019 @category{Package distrib}
1025 @anchor{cdf_noncentral_student_t}
1026 @deffn {Function} cdf_noncentral_student_t (@var{x},@var{n},@var{ncp})
1027 Returns the value at @var{x} of the cumulative distribution function of a
1028 noncentral Student random variable
1029 m4_Noncentral_T_RV(n,ncp)
1030 , with @math{n>0} degrees of freedom and noncentrality parameter @math{ncp}. This function has no closed form and it is numerically computed.
1033 @c load ("distrib")$
1034 @c cdf_noncentral_student_t(-2,5,-5);
1037 (%i1) load ("distrib")$
1039 (%i2) cdf_noncentral_student_t(-2,5,-5);
1040 (%o2) 0.995203009331975
1044 @opencatbox{Categories:}
1045 @category{Package distrib}
1051 @anchor{quantile_noncentral_student_t}
1052 @deffn {Function} quantile_noncentral_student_t (@var{q},@var{n},@var{ncp})
1053 Returns the @var{q}-quantile of a noncentral Student random variable
1054 m4_Noncentral_T_RV(n,ncp)
1055 , with @math{n>0} degrees of freedom and noncentrality parameter @math{ncp}; in other words, this is the inverse of @code{cdf_noncentral_student_t}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
1057 @opencatbox{Categories:}
1058 @category{Package distrib}
1064 @anchor{mean_noncentral_student_t}
1065 @deffn {Function} mean_noncentral_student_t (@var{n},@var{ncp})
1066 Returns the mean of a noncentral Student random variable
1067 m4_Noncentral_T_RV(n,ncp)
1068 , with @math{n>1} degrees of freedom and noncentrality parameter @math{ncp}. To make use of this function, write first @code{load("distrib")}.
1072 <<<E[X] = {\mu \sqrt{n}\; \Gamma\left(\displaystyle{n-1\over 2}\right) \over
1073 \sqrt{2}\;\Gamma\left(\displaystyle{n\over 2}\right)}>>>,
1077 mu gamma(-----) sqrt(n)
1079 E[X] = -----------------------
1088 is the noncentrality parameter @math{ncp}.
1091 @c load ("distrib")$
1092 @c mean_noncentral_student_t(df,k);
1095 (%i1) load ("distrib")$
1097 (%i2) mean_noncentral_student_t(df,k);
1099 gamma(------) sqrt(df) k
1101 (%o2) ------------------------
1108 @opencatbox{Categories:}
1109 @category{Package distrib}
1115 @anchor{var_noncentral_student_t}
1116 @deffn {Function} var_noncentral_student_t (@var{n},@var{ncp})
1117 Returns the variance of a noncentral Student random variable
1118 m4_Noncentral_T_RV(n,ncp)
1119 , with @math{n>2} degrees of freedom and noncentrality parameter @math{ncp}. To make use of this function, write first @code{load("distrib")}.
1123 <<<V[X] = {n(\mu^2+1)\over n-2} - {n\mu^2\; \Gamma\left(\displaystyle{n-1\over 2}\right)^2
1124 \over 2\Gamma\left(\displaystyle{n\over 2}\right)^2}>>>,
1128 2 gamma (-----) n ncp
1130 V[X] = ------------ - --------------------
1139 is the noncentrality parameter @math{ncp}.
1141 @opencatbox{Categories:}
1142 @category{Package distrib}
1148 @anchor{std_noncentral_student_t}
1149 @deffn {Function} std_noncentral_student_t (@var{n},@var{ncp})
1150 Returns the standard deviation of a noncentral Student random variable
1151 m4_Noncentral_T_RV(n,ncp)
1152 , with @math{n>2} degrees of freedom and noncentrality parameter @math{ncp}. To make use of this function, write first @code{load("distrib")}.
1154 The standard deviation is
1156 <<<D[X] = \sqrt{{n(\mu^2+1)\over n-2} - {n\mu^2\; \Gamma\left(\displaystyle{n-1\over 2}\right)^2
1157 \over 2\Gamma\left(\displaystyle{n\over 2}\right)^2}}>>>,
1161 2 gamma (-----) n ncp
1163 D[X] = sqrt(------------ - --------------------)
1171 @opencatbox{Categories:}
1172 @category{Package distrib}
1178 @anchor{skewness_noncentral_student_t}
1179 @deffn {Function} skewness_noncentral_student_t (@var{n},@var{ncp})
1180 Returns the skewness coefficient of a noncentral Student random
1182 m4_Noncentral_T_RV(n,ncp)
1183 , with @math{n>3} degrees of freedom and noncentrality parameter @math{ncp}. To make use of this function, write first @code{load("distrib")}.
1185 @c The TeX form is obtained from
1186 @c tex(skewness_noncentral_student_t(n,mu)). Likewise the info form
1187 @c is just cut-n-pasted from maxima's terminal output.
1188 If @math{U} is a non-central Student's @math{t} random variable with
1189 @math{n} degrees of freedom and a noncentrality parameter
1190 m4_mathcomma(\mu, mu)
1195 {\mu\sqrt{n}\,\Gamma\left({{n-1}\over{2}}\right)
1196 \over{\sqrt{2}\Gamma\left({{n
1197 }\over{2}}\right)\sigma^{3}}}\left({{n
1198 \left(2n+\mu^2-3\right)}\over{\left(n-3\right)\left(n-2\right)}}
1199 -2\sigma^2\right) \cr
1200 \sigma^2 &= {{n\left(\mu^2+1\right)}\over{n-2}}-{{n \mu^2\,
1201 \Gamma\left({{n-1}\over{2}}\right)^2}\over{2\Gamma\left({{n
1202 }\over{2}}\right)^2}}
1209 n - 1 n (2 n + mu - 3)
1210 (mu gamma(-----) sqrt(n) (-----------------
1213 2 mu gamma (-----) n
1215 - 2 (----------- - -------------------)))
1220 2 mu gamma (-----) n
1222 /(sqrt(2) gamma(-) (----------- - -------------------) )
1229 @opencatbox{Categories:}
1230 @category{Package distrib}
1236 @anchor{kurtosis_noncentral_student_t}
1237 @deffn {Function} kurtosis_noncentral_student_t (@var{n},@var{ncp})
1238 Returns the kurtosis coefficient of a noncentral Student random
1240 m4_Noncentral_T_RV(n,ncp)
1241 , with @math{n>4} degrees of freedom and noncentrality parameter @math{ncp}. To make use of this function, write first @code{load("distrib")}.
1243 If @math{U} is a non-central Student's @math{t} random variable with
1244 @math{n} degrees of freedom and a noncentrality parameter
1245 m4_mathcomma(\mu, mu)
1248 @c The formula we see can be basically derived by computing
1249 @c (kurtosis_noncentral_student_t(n,mu)+3)*var_noncentral_student_t(n,mu)^2,
1250 @c which comes from the definition of kurtosis. The rest is then
1251 @c obtained by replacing a constant by F.
1255 {\mu_4\over \sigma^4} - 3\cr
1256 \mu_4 &= {{\left(\mu^4+6\mu^2+3\right)n^2}\over{(n-4)(n-2)}}
1257 -\left({{n\left(3(3n-5)+\mu^2(n+1)\right)
1258 }\over{(n-3)(n-2)}}-3\sigma^2\right) F \cr
1259 \sigma^2 &= {{n\left(\mu^2+1\right)}\over{n-2}}-{{n \mu^2
1260 \Gamma\left({{n-1}\over{2}}\right)^2}\over{2\Gamma\left({{n
1261 }\over{2}}\right)^2}} \cr
1262 F &= {n\mu^2\Gamma\left({n-1\over 2}\right)^2 \over
1263 2\sigma^4\Gamma\left({n\over 2}\right)^2}
1269 (mu + 6 mu + 3) n 2 2 n - 1
1270 (-------------------- - (mu gamma (-----) n
1273 2 2 mu gamma (-----) n
1274 n (3 (3 n - 5) + mu (n + 1)) (mu + 1) n 2
1275 (----------------------------- - 3 (----------- - -------------------)))
1276 (n - 3) (n - 2) n - 2 2 n
1280 2 mu gamma (-----) n
1282 /(2 gamma (-)))/(----------- - -------------------) - 3
1289 @opencatbox{Categories:}
1290 @category{Package distrib}
1296 @anchor{random_noncentral_student_t}
1297 @deffn {Function} random_noncentral_student_t (@var{n},@var{ncp}) @
1298 @fname{random_noncentral_student_t} (@var{n},@var{ncp},@var{m})
1300 Returns a noncentral Student random variate
1301 m4_Noncentral_T_RV(n,ncp)
1302 , with @math{n>0}. Calling @code{random_noncentral_student_t} with a third argument @var{m}, a random sample of size @var{m} will be simulated.
1304 The implemented algorithm is based on the fact that if @var{X} is a
1305 normal random variable
1309 m4_math(\chi^2, chi square)
1310 random variable with @var{n} degrees of freedom,
1314 <<<U={{X}\over{\sqrt{{S^2}\over{n}}}}>>>,
1325 is a noncentral Student random variable with @math{n} degrees of
1326 freedom and noncentrality parameter @math{ncp},
1327 m4_Noncentral_T_RV(n,ncp)
1330 To make use of this function, write first @code{load("distrib")}.
1332 @opencatbox{Categories:}
1333 @category{Package distrib}
1334 @category{Random numbers}
1340 @node Chi-squared Random Variable, Noncentral Chi-squared Random Variable, Noncentral Student's t Random Variable, Functions and Variables for continuous distributions
1341 @subsection Chi-squared Random Variable
1344 m4_math(<<<X_1, X_2, \ldots, X_n>>>, <<<X_1, X_2, ...,
1346 be independent and identically distributed
1350 <<<X^2 = \sum_{i=1}^n X_i^2>>>,
1351 <<<@math{X^2 = sum(X_i^2, i, 1, n)}>>>)
1353 is said to follow a chi-square distribution with @math{n} degrees of
1357 @deffn {Function} pdf_chi2 (@var{x},@var{n})
1358 Returns the value at @var{x} of the density function of a Chi-square
1364 random variable is equivalent to the
1373 \displaystyle{x^{n/2-1} e^{-x/2} \over 2^{n/2}
1374 \Gamma\left(\displaystyle{n\over 2}\right)} & for $x
1383 [ ----------------------------- for x >= 0
1385 f(x, n) = [ gamma(-) 2
1393 @c load ("distrib")$
1397 (%i1) load ("distrib")$
1399 (%i2) pdf_chi2(x,n);
1402 (%o2) -----------------------------
1409 @opencatbox{Categories:}
1410 @category{Package distrib}
1417 @deffn {Function} cdf_chi2 (@var{x},@var{n})
1418 Returns the value at @math{x} of the cumulative distribution function of a
1419 Chi-square random variable
1427 1 - Q\left(\displaystyle{n\over 2}, {x\over 2}\right) & $x > 0$ \cr
1433 [ (1 - Q(-, -)) for x >= 0
1439 where @math{Q(a,z)} is the @ref{gamma_incomplete_regularized} function.
1442 @c load ("distrib")$
1447 (%i1) load ("distrib")$
1449 (%i2) cdf_chi2(3,4);
1451 (%o2) 1 - gamma_incomplete_regularized(2, -)
1456 (%o3) 0.4421745996289252
1460 @opencatbox{Categories:}
1461 @category{Package distrib}
1467 @anchor{quantile_chi2}
1468 @deffn {Function} quantile_chi2 (@var{q},@var{n})
1469 Returns the @var{q}-quantile of a Chi-square random variable
1471 , with @math{n>0}; in other words, this is the inverse of @code{cdf_chi2}. Argument @var{q} must be an element of @math{[0,1]}.
1473 This function has no closed form and it is numerically computed.
1476 @c load ("distrib")$
1477 @c quantile_chi2(0.99,9);
1480 (%i1) load ("distrib")$
1482 (%i2) quantile_chi2(0.99,9);
1483 (%o2) 21.66599433346194
1487 @opencatbox{Categories:}
1488 @category{Package distrib}
1495 @deffn {Function} mean_chi2 (@var{n})
1496 Returns the mean of a Chi-square random variable
1502 random variable is equivalent to the
1516 @c load ("distrib")$
1520 (%i1) load ("distrib")$
1527 @opencatbox{Categories:}
1528 @category{Package distrib}
1535 @deffn {Function} var_chi2 (@var{n})
1536 Returns the variance of a Chi-square random variable
1542 random variable is equivalent to the
1556 @c load ("distrib")$
1560 (%i1) load ("distrib")$
1567 @opencatbox{Categories:}
1568 @category{Package distrib}
1575 @deffn {Function} std_chi2 (@var{n})
1576 Returns the standard deviation of a Chi-square random variable
1582 random variable is equivalent to the
1586 The standard deviation is
1588 <<<D[X] = \sqrt{2n}>>>,
1591 D[X] = sqrt(2) sqrt(n)
1596 @c load ("distrib")$
1600 (%i1) load ("distrib")$
1603 (%o2) sqrt(2) sqrt(n)
1607 @opencatbox{Categories:}
1608 @category{Package distrib}
1614 @anchor{skewness_chi2}
1615 @deffn {Function} skewness_chi2 (@var{n})
1616 Returns the skewness coefficient of a Chi-square random variable
1622 random variable is equivalent to the
1626 The skewness coefficient is
1628 <<<SK[X] = \sqrt{8\over n}>>>,
1639 @c load ("distrib")$
1640 @c skewness_chi2(n);
1643 (%i1) load ("distrib")$
1645 (%i2) skewness_chi2(n);
1653 @opencatbox{Categories:}
1654 @category{Package distrib}
1660 @anchor{kurtosis_chi2}
1661 @deffn {Function} kurtosis_chi2 (@var{n})
1662 Returns the kurtosis coefficient of a Chi-square random variable
1668 random variable is equivalent to the
1672 The kurtosis coefficient is
1674 <<<KU[X] = {12\over n}>>>,
1684 @c load ("distrib")$
1685 @c kurtosis_chi2(n);
1688 (%i1) load ("distrib")$
1690 (%i2) kurtosis_chi2(n);
1697 @opencatbox{Categories:}
1698 @category{Package distrib}
1704 @anchor{random_chi2}
1705 @deffn {Function} random_chi2 (@var{n}) @
1706 @fname{random_chi2} (@var{n},@var{m})
1708 Returns a Chi-square random variate
1710 , with @math{n>0}. Calling @code{random_chi2} with a second argument @var{m}, a random sample of size @var{m} will be simulated.
1712 The simulation is based on the Ahrens-Cheng algorithm. See @code{random_gamma} for details.
1714 To make use of this function, write first @code{load("distrib")}.
1716 @opencatbox{Categories:}
1717 @category{Package distrib}
1718 @category{Random numbers}
1724 @node Noncentral Chi-squared Random Variable, F Random Variable, Chi-squared Random Variable, Functions and Variables for continuous distributions
1725 @subsection Noncentral Chi-squared Random Variable
1728 m4_math(<<<X_1, X_2, ..., X_n>>>, <<<X[1], X[2], ..., X[n]>>>)
1730 independent normally distributed random variables with
1732 m4_math(\mu_k, mu[k])
1733 and unit variances. Then the random variable
1736 <<<\sum_{k=1}^n X_k^2>>>,
1737 <<<@math{sum(X[k]^2, k, 1, n)}>>>)
1740 m4_math(\chi^2, chi-squared)
1742 number of degrees of freedom is @math{n}, and the noncentrality
1743 parameter is defined by
1746 <<<\sum_{k=1}^n \mu_k^2>>>,
1747 <<<@math{sum(mu[k]^2, k, 1, n)}>>>)
1749 @anchor{pdf_noncentral_chi2}
1750 @deffn {Function} pdf_noncentral_chi2 (@var{x},@var{n},@var{ncp})
1751 Returns the value at @math{x} of the density function of a
1753 m4_math(\chi^2, Chi-square)
1756 m4_noncentral_chi2(n,ncp)
1757 , with @math{n>0} and noncentrality
1759 m4_mathdot(<<<ncp \ge 0>>>, <<<ncp >= 0>>>)
1761 make use of this function, write first @code{load("distrib")}.
1763 For @math{x < 0}, the pdf is 0, and for
1764 m4_math(x \ge 0, x >= 0)
1767 <<<f(x; n, \lambda) =
1768 {1\over 2}e^{-(x+\lambda)/2} \left(x\over
1769 \lambda\right)^{n/4-1/2}I_{{n\over 2} - 1}\left(\sqrt{n \lambda}\right)
1777 bessel_i(- - 1, sqrt(ncp x)) (---) %e unit_step(x)
1779 ----------------------------------------------------------------------
1784 @opencatbox{Categories:}
1785 @category{Package distrib}
1791 @anchor{cdf_noncentral_chi2}
1792 @deffn {Function} cdf_noncentral_chi2 (@var{x},@var{n},@var{ncp})
1793 Returns the value at @var{x} of the cumulative distribution function of a
1794 noncentral Chi-square random variable
1795 m4_noncentral_chi2(n,ncp)
1797 @math{n>0} and noncentrality parameter
1798 m4_mathdot(<<<ncp \ge 0>>>, <<<ncp >= 0>>>)
1799 To make use of this function, write first @code{load("distrib")}.
1801 @opencatbox{Categories:}
1802 @category{Package distrib}
1808 @anchor{quantile_noncentral_chi2}
1809 @deffn {Function} quantile_noncentral_chi2 (@var{q},@var{n},@var{ncp})
1810 Returns the @var{q}-quantile of a noncentral Chi-square random
1812 m4_noncentral_chi2(n,ncp)
1813 , with @math{n>0} and noncentrality
1815 m4_math(<<<ncp \ge 0>>>, <<<ncp >= 0>>>)
1816 ; in other words, this is the inverse of @code{cdf_noncentral_chi2}. Argument @var{q} must be an element of @math{[0,1]}.
1818 This function has no closed form and it is numerically computed.
1820 @opencatbox{Categories:}
1821 @category{Package distrib}
1827 @anchor{mean_noncentral_chi2}
1828 @deffn {Function} mean_noncentral_chi2 (@var{n},@var{ncp})
1829 Returns the mean of a noncentral Chi-square random variable
1830 m4_noncentral_chi2(n,ncp)
1831 , with @math{n>0} and noncentrality parameter
1832 m4_mathdot(<<<ncp \ge 0>>>, <<<ncp >= 0>>>)
1836 <<<E[X] = n + \mu>>>,
1845 is the noncentrality parameter @var{ncp}.
1849 @opencatbox{Categories:}
1850 @category{Package distrib}
1856 @anchor{var_noncentral_chi2}
1857 @deffn {Function} var_noncentral_chi2 (@var{n},@var{ncp})
1858 Returns the variance of a noncentral Chi-square random variable
1859 m4_noncentral_chi2(n,ncp)
1860 , with @math{n>0} and noncentrality parameter
1861 m4_mathdot(<<<ncp \ge 0>>>, <<<ncp >= 0>>>)
1865 <<<V[X] = 2(n+2\mu)>>>,
1868 V[X] = 2 (2 ncp + n)
1874 is the noncentrality parameter @var{ncp}.
1877 @opencatbox{Categories:}
1878 @category{Package distrib}
1884 @anchor{std_noncentral_chi2}
1885 @deffn {Function} std_noncentral_chi2 (@var{n},@var{ncp})
1886 Returns the standard deviation of a noncentral Chi-square random
1888 m4_noncentral_chi2(n,ncp)
1889 , with @math{n>0} and noncentrality
1891 m4_mathdot(<<<ncp \ge 0>>>, <<<ncp >= 0>>>)
1893 The standard deviation is
1895 <<<D[X] = \sqrt{2(n+2\mu)}>>>,
1898 D[X] = sqrt(2) sqrt(2 ncp + n)
1904 is the noncentrality parameter @var{ncp}.
1906 @opencatbox{Categories:}
1907 @category{Package distrib}
1913 @anchor{skewness_noncentral_chi2}
1914 @deffn {Function} skewness_noncentral_chi2 (@var{n},@var{ncp})
1915 Returns the skewness coefficient of a noncentral Chi-square random
1917 m4_noncentral_chi2(n,ncp)
1918 , with @math{n>0} and noncentrality
1920 m4_mathdot(<<<ncp \ge 0>>>, <<<ncp >= 0>>>)
1922 The skewness coefficient is
1924 <<<SK[X] = {2^{3/2}(n+3\mu) \over (n+2\mu)^{3/2}}>>>,
1929 SK[X] = ---------------
1938 is the noncentrality parameter @var{ncp}.
1942 @opencatbox{Categories:}
1943 @category{Package distrib}
1949 @anchor{kurtosis_noncentral_chi2}
1950 @deffn {Function} kurtosis_noncentral_chi2 (@var{n},@var{ncp})
1951 Returns the kurtosis coefficient of a noncentral Chi-square random
1953 m4_noncentral_chi2(n,ncp)
1954 , with @math{n>0} and noncentrality
1956 m4_mathdot(<<<ncp \ge 0>>>, <<<ncp >= 0>>>)
1958 The kurtosis coefficient is
1960 <<<KU[X] = {12(n+4\mu)\over (2+2\mu)^2}>>>,
1964 KU[X] = -------------
1972 is the noncentrality parameter @var{ncp}.
1975 @opencatbox{Categories:}
1976 @category{Package distrib}
1982 @anchor{random_noncentral_chi2}
1983 @deffn {Function} random_noncentral_chi2 (@var{n},@var{ncp}) @
1984 @fname{random_noncentral_chi2} (@var{n},@var{ncp},@var{m})
1986 Returns a noncentral Chi-square random variate
1987 m4_noncentral_chi2(n,ncp)
1988 , with @math{n>0} and noncentrality parameter
1989 m4_mathdot(<<<ncp \ge 0>>>, <<<ncp >= 0>>>)
1990 Calling @code{random_noncentral_chi2} with a third argument @var{m}, a random sample of size @var{m} will be simulated.
1992 To make use of this function, write first @code{load("distrib")}.
1994 @opencatbox{Categories:}
1995 @category{Package distrib}
1996 @category{Random numbers}
2003 @node F Random Variable, Exponential Random Variable, Noncentral Chi-squared Random Variable, Functions and Variables for continuous distributions
2004 @subsection F Random Variable
2006 Let @math{S_1} and @math{S_2} be independent random variables with
2008 m4_math(\chi^2, chi-squared)
2009 distribution with degrees of freedom
2010 @math{n} and @math{m}, respectively. Then
2012 <<<F = {S_1/n \over S_2/m}>>>,
2013 <<<@math{F = (S_1/n)/(S_2/m)}>>>) has an @math{F} distribution with @math{n} and @math{m} degrees of
2017 @deffn {Function} pdf_f (@var{x},@var{m},@var{n})
2018 Returns the value at @var{x} of the density function of a F random variable @math{F(m,n)}, with @math{m,n>0}. To make use of this function, write first @code{load("distrib")}.
2024 B\left(\displaystyle{m\over 2}, \displaystyle{n\over 2}\right)^{-1}
2025 \left(\displaystyle{m\over n}\right)^{m/ 2}
2027 \left(1 + \displaystyle{m\over n}x\right)^{-\left(n+m\right)/2} & $x >
2037 n n/2 n + m n/2 - 1 n x 2
2038 (-) gamma(-----) x (--- + 1) unit_step(x)
2040 ------------------------------------------------------------
2047 @opencatbox{Categories:}
2048 @category{Package distrib}
2055 @deffn {Function} cdf_f (@var{x},@var{m},@var{n})
2056 Returns the value at @var{x} of the cumulative distribution function of a F random variable @math{F(m,n)}, with @math{m,n>0}.
2062 1 - I_z\left(\displaystyle{m\over 2}, {n\over 2}\right) & $x > 0$ \cr
2068 F(x, m, n) = (1 - beta_incomplete_regularized(-, -, -------))
2077 <<<z = {n\over mx+n}>>>,
2082 is the @ref{beta_incomplete_regularized}
2086 @c load ("distrib")$
2091 (%i1) load ("distrib")$
2093 (%i2) cdf_f(2,3,9/4);
2095 (%o2) 1 - beta_incomplete_regularized(-, -, --)
2100 (%o3) 0.6675672817900802
2104 @opencatbox{Categories:}
2105 @category{Package distrib}
2112 @deffn {Function} quantile_f (@var{q},@var{m},@var{n})
2113 Returns the @var{q}-quantile of a F random variable @math{F(m,n)}, with @math{m,n>0}; in other words, this is the inverse of @code{cdf_f}. Argument @var{q} must be an element of @math{[0,1]}.
2116 @c load ("distrib")$
2117 @c quantile_f(2/5,sqrt(3),5);
2120 (%i1) load ("distrib")$
2122 (%i2) quantile_f(2/5,sqrt(3),5);
2123 (%o2) 0.5189478385736904
2127 @opencatbox{Categories:}
2128 @category{Package distrib}
2135 @deffn {Function} mean_f (@var{m},@var{n})
2136 Returns the mean of a F random variable @math{F(m,n)}, with @math{m>0, n>2}. To make use of this function, write first @code{load("distrib")}.
2140 <<<E[X] = {n\over n-2}>>>,
2149 @opencatbox{Categories:}
2150 @category{Package distrib}
2157 @deffn {Function} var_f (@var{m},@var{n})
2158 Returns the variance of a F random variable @math{F(m,n)}, with @math{m>0, n>4}. To make use of this function, write first @code{load("distrib")}.
2162 <<<V[X] = {2n^2(n+m-2) \over m(n-4)(n-2)^2}>>>,
2167 V[X] = ------------------
2172 @opencatbox{Categories:}
2173 @category{Package distrib}
2180 @deffn {Function} std_f (@var{m},@var{n})
2181 Returns the standard deviation of a F random variable @math{F(m,n)}, with @math{m>0, n>4}. To make use of this function, write first @code{load("distrib")}.
2183 The standard deviation is
2185 <<<D[X] = {\sqrt{2}\, n \over n-2} \sqrt{n+m-2\over m(n-4)}>>>,
2189 D[X] = sqrt(2) sqrt(-----) sqrt(---------)
2193 @opencatbox{Categories:}
2194 @category{Package distrib}
2201 @deffn {Function} skewness_f (@var{m},@var{n})
2202 Returns the skewness coefficient of a F random variable @math{F(m,n)}, with @math{m>0, n>6}. To make use of this function, write first @code{load("distrib")}.
2204 The skewness coefficient is
2206 <<<SK[X] = {(n+2m-2)\sqrt{8(n-4)} \over (n-6)\sqrt{m(n+m-2)}}>>>,
2210 2 sqrt(n - 4) (n + 2 m - 2)
2211 SK[X] = ------------------------------
2212 (n - 6) sqrt(m (n + m - 2))
2216 @opencatbox{Categories:}
2217 @category{Package distrib}
2224 @deffn {Function} kurtosis_f (@var{m},@var{n})
2225 Returns the kurtosis coefficient of a F random variable @math{F(m,n)}, with @math{m>0, n>8}. To make use of this function, write first @code{load("distrib")}.
2227 The kurtosis coefficient is
2229 <<<KU[X] = 12{m(n+m-2)(5n-22) + (n-4)(n-2)^2 \over m(n-8)(n-6)(n+m-2)}>>>,
2233 12 (m (n + m - 2) (5 n - 22) + (n - 4) (n - 2) )
2234 KU[X] = ------------------------------------------------
2235 m (n - 8) (n - 6) (n + m - 2)
2239 @opencatbox{Categories:}
2240 @category{Package distrib}
2247 @deffn {Function} random_f (@var{m},@var{n}) @
2248 @fname{random_f} (@var{m},@var{n},@var{k})
2250 Returns a F random variate @math{F(m,n)}, with @math{m,n>0}. Calling @code{random_f} with a third argument @var{k}, a random sample of size @var{k} will be simulated.
2252 The simulation algorithm is based on the fact that if @var{X} is a
2253 @math{Chi^2(m)} random variable and @math{Y} is a
2255 random variable, then
2257 <<<F={{n X}\over{m Y}}>>>,
2265 is a F random variable with @var{m} and @var{n} degrees of freedom, @math{F(m,n)}.
2267 To make use of this function, write first @code{load("distrib")}.
2269 @opencatbox{Categories:}
2270 @category{Package distrib}
2271 @category{Random numbers}
2277 @node Exponential Random Variable, Lognormal Random Variable, F Random Variable, Functions and Variables for continuous distributions
2278 @subsection Exponential Random Variable
2280 The @emph{exponential distribution} is the probablity distribution of
2281 the time between events in a process where the events occur
2282 continuously and independently at a constant average rate.
2285 @deffn {Function} pdf_exp (@var{x},@var{m})
2286 Returns the value at @var{x} of the density function of an
2287 m4_Exponential_RV(m)
2288 random variable, with @math{m>0}.
2291 m4_Exponential_RV(m)
2292 random variable is equivalent to the
2293 m4_Weibull_RV(1,1/m)
2300 me^{-mx} & for $x \ge 0$ \cr
2305 [ m*exp(-m*x) for x >= 0
2312 @c load ("distrib")$
2316 (%i1) load ("distrib")$
2320 (%o2) m %e unit_step(x)
2324 @opencatbox{Categories:}
2325 @category{Package distrib}
2332 @deffn {Function} cdf_exp (@var{x},@var{m})
2333 Returns the value at @var{x} of the cumulative distribution function of an
2334 m4_Exponential_RV(m)
2335 random variable, with @math{m>0}.
2338 m4_Exponential_RV(m)
2339 random variable is equivalent to the
2340 m4_Weibull_RV(1,1/m)
2347 1 - e^{-mx} & $x \ge 0$ \cr
2352 [ 1 - exp(-m*x) for x >= 0
2358 @c load ("distrib")$
2362 (%i1) load ("distrib")$
2366 (%o2) (1 - %e ) unit_step(x)
2370 @opencatbox{Categories:}
2371 @category{Package distrib}
2377 @anchor{quantile_exp}
2378 @deffn {Function} quantile_exp (@var{q},@var{m})
2379 Returns the @var{q}-quantile of an
2380 m4_Exponential_RV(m)
2381 random variable, with @math{m>0}; in other words, this is the inverse of @code{cdf_exp}. Argument @var{q} must be an element of @math{[0,1]}.
2384 m4_Exponential_RV(m)
2385 random variable is equivalent to the
2386 m4_Weibull_RV(1,1/m)
2390 @c load ("distrib")$
2391 @c quantile_exp(0.56,5);
2392 @c quantile_exp(0.56,m);
2395 (%i1) load ("distrib")$
2397 (%i2) quantile_exp(0.56,5);
2398 (%o2) 0.1641961104139661
2401 (%i3) quantile_exp(0.56,m);
2403 (%o3) ------------------
2408 @opencatbox{Categories:}
2409 @category{Package distrib}
2416 @deffn {Function} mean_exp (@var{m})
2417 Returns the mean of an
2418 m4_Exponential_RV(m)
2419 random variable, with @math{m>0}.
2422 m4_Exponential_RV(m)
2423 random variable is equivalent to the
2424 m4_Weibull_RV(1,1/m)
2429 <<<E[X] = {1\over m}>>>,
2439 @c load ("distrib")$
2443 (%i1) load ("distrib")$
2452 @opencatbox{Categories:}
2453 @category{Package distrib}
2460 @deffn {Function} var_exp (@var{m})
2461 Returns the variance of an
2462 m4_Exponential_RV(m)
2463 random variable, with @math{m>0}.
2466 m4_Exponential_RV(m)
2467 random variable is equivalent to the
2468 m4_Weibull_RV(1,1/m)
2473 <<<V[X] = {1\over m^2}>>>,
2484 @c load ("distrib")$
2488 (%i1) load ("distrib")$
2498 @opencatbox{Categories:}
2499 @category{Package distrib}
2506 @deffn {Function} std_exp (@var{m})
2507 Returns the standard deviation of an
2508 m4_Exponential_RV(m)
2509 random variable, with @math{m>0}.
2512 m4_Exponential_RV(m)
2513 random variable is equivalent to the
2514 m4_Weibull_RV(1,1/m)
2517 The standard deviation is
2519 <<<D[X] = {1\over m}>>>,
2529 @c load ("distrib")$
2533 (%i1) load ("distrib")$
2542 @opencatbox{Categories:}
2543 @category{Package distrib}
2549 @anchor{skewness_exp}
2550 @deffn {Function} skewness_exp (@var{m})
2551 Returns the skewness coefficient of an
2552 m4_Exponential_RV(m)
2553 random variable, with @math{m>0}.
2556 m4_Exponential_RV(m)
2557 random variable is equivalent to the
2558 m4_Weibull_RV(1,1/m)
2561 The skewness coefficient is
2571 @c load ("distrib")$
2575 (%i1) load ("distrib")$
2577 (%i2) skewness_exp(m);
2582 @opencatbox{Categories:}
2583 @category{Package distrib}
2589 @anchor{kurtosis_exp}
2590 @deffn {Function} kurtosis_exp (@var{m})
2591 Returns the kurtosis coefficient of an
2592 m4_Exponential_RV(m)
2593 random variable, with @math{m>0}.
2596 m4_Exponential_RV(m)
2597 random variable is equivalent to the
2598 m4_Weibull_RV(1,1/m)
2601 The kurtosis coefficient is
2611 @c load ("distrib")$
2615 (%i1) load ("distrib")$
2617 (%i2) kurtosis_exp(m);
2622 @opencatbox{Categories:}
2623 @category{Package distrib}
2630 @deffn {Function} random_exp (@var{m}) @
2631 @fname{random_exp} (@var{m},@var{k})
2634 m4_Exponential_RV(m)
2635 random variate, with @math{m>0}. Calling @code{random_exp} with a second argument @var{k}, a random sample of size @var{k} will be simulated.
2637 The simulation algorithm is based on the general inverse method.
2639 To make use of this function, write first @code{load("distrib")}.
2641 @opencatbox{Categories:}
2642 @category{Package distrib}
2643 @category{Random numbers}
2649 @node Lognormal Random Variable, Gamma Random Variable, Exponential Random Variable, Functions and Variables for continuous distributions
2650 @subsection Lognormal Random Variable
2652 The @emph{lognormal} distribution is distribution for a random
2653 variable whose logarithm is normally distributed.
2655 @anchor{pdf_lognormal}
2656 @deffn {Function} pdf_lognormal (@var{x},@var{m},@var{s})
2657 Returns the value at @var{x} of the density function of a
2658 m4_Lognormal_RV(m,s)
2659 random variable, with @math{s>0}. To make use of this function, write first @code{load("distrib")}.
2665 \displaystyle{1\over x s \sqrt{2\pi}}
2666 \exp\left(-\displaystyle{\left(\log x - m\right)^2\over 2s^2}\right) & for $x \ge
2679 f(x, m, s) = [ --------------------- for x >= 0
2680 [ sqrt(2) sqrt(%pi) s x
2685 @opencatbox{Categories:}
2686 @category{Package distrib}
2692 @anchor{cdf_lognormal}
2693 @deffn {Function} cdf_lognormal (@var{x},@var{m},@var{s})
2694 Returns the value at @var{x} of the cumulative distribution function of a
2695 m4_Lognormal_RV(m,s)
2696 random variable, with @math{s>0}. This function is defined in terms of Maxima's built-in error function @code{erf}.
2702 \displaystyle{1\over 2}\left[1+{\rm erf}\left({\log x - m\over s\sqrt{2}}\right)\right] &
2712 F(x, m, s) = unit_step(x) (--------------- + -)
2718 @c load ("distrib")$
2719 @c cdf_lognormal(x,m,s);
2722 (%i1) load ("distrib")$
2724 (%i2) cdf_lognormal(x,m,s);
2728 (%o2) unit_step(x) (--------------- + -)
2733 See also @mrefdot{erf}
2735 @opencatbox{Categories:}
2736 @category{Package distrib}
2742 @anchor{quantile_lognormal}
2743 @deffn {Function} quantile_lognormal (@var{q},@var{m},@var{s})
2744 Returns the @var{q}-quantile of a
2745 m4_Lognormal_RV(m,s)
2746 random variable, with @math{s>0}; in other words, this is the inverse of @code{cdf_lognormal}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
2749 @c load ("distrib")$
2750 @c quantile_lognormal(95/100,0,1);
2754 (%i1) load ("distrib")$
2756 (%i2) quantile_lognormal(95/100,0,1);
2757 sqrt(2) inverse_erf(9/10)
2762 (%o3) 5.180251602233015
2766 @opencatbox{Categories:}
2767 @category{Package distrib}
2773 @anchor{mean_lognormal}
2774 @deffn {Function} mean_lognormal (@var{m},@var{s})
2775 Returns the mean of a
2776 m4_Lognormal_RV(m,s)
2777 random variable, with @math{s>0}. To make use of this function, write first @code{load("distrib")}.
2781 <<<E[X] = \exp\left(m+{s^2\over 2}\right)>>>,
2793 @opencatbox{Categories:}
2794 @category{Package distrib}
2800 @anchor{var_lognormal}
2801 @deffn {Function} var_lognormal (@var{m},@var{s})
2802 Returns the variance of a
2803 m4_Lognormal_RV(m,s)
2804 random variable, with @math{s>0}. To make use of this function, write first @code{load("distrib")}.
2808 <<<V[X] = \left(\exp\left(s^2\right) - 1\right) \exp\left(2m+s^2\right)>>>,
2818 @opencatbox{Categories:}
2819 @category{Package distrib}
2824 @anchor{std_lognormal}
2825 @deffn {Function} std_lognormal (@var{m},@var{s})
2826 Returns the standard deviation of a
2827 m4_Lognormal_RV(m,s)
2828 random variable, with @math{s>0}. To make use of this function, write first @code{load("distrib")}.
2830 The standard deviation is
2832 <<<D[X] = \sqrt{\left(\exp\left(s^2\right) - 1\right)}
2833 \exp\left(m+{s^2\over 2}\right)>>>,
2840 D[X] = sqrt(%e - 1) %e
2845 @opencatbox{Categories:}
2846 @category{Package distrib}
2852 @anchor{skewness_lognormal}
2853 @deffn {Function} skewness_lognormal (@var{m},@var{s})
2854 Returns the skewness coefficient of a
2855 m4_Lognormal_RV(m,s)
2856 random variable, with @math{s>0}. To make use of this function, write first @code{load("distrib")}.
2858 The skewness coefficient is
2860 <<<SK[X] = \left(\exp\left(s^2\right)+2\right)\sqrt{\exp\left(s^2\right)-1}>>>,
2865 SK[X] = sqrt(%e - 1) (%e + 2)
2869 @opencatbox{Categories:}
2870 @category{Package distrib}
2876 @anchor{kurtosis_lognormal}
2877 @deffn {Function} kurtosis_lognormal (@var{m},@var{s})
2878 Returns the kurtosis coefficient of a
2879 m4_Lognormal_RV(m,s)
2880 random variable, with @math{s>0}. To make use of this function, write first @code{load("distrib")}.
2882 The kurtosis coefficient is
2884 <<<KU[X] = \exp\left(4s^2\right)+2\exp\left(3s^2\right)+3\exp\left(2s^2\right)-3>>>,
2889 KU[X] = %e + 2 %e + 3 %e - 3
2895 @opencatbox{Categories:}
2896 @category{Package distrib}
2902 @anchor{random_lognormal}
2903 @deffn {Function} random_lognormal (@var{m},@var{s}) @
2904 @fname{random_lognormal} (@var{m},@var{s},@var{n})
2907 m4_Lognormal_RV(m,s)
2908 random variate, with @math{s>0}. Calling @code{random_lognormal} with a third argument @var{n}, a random sample of size @var{n} will be simulated.
2910 Log-normal variates are simulated by means of random normal variates. See @code{random_normal} for details.
2912 To make use of this function, write first @code{load("distrib")}.
2914 @opencatbox{Categories:}
2915 @category{Package distrib}
2916 @category{Random numbers}
2922 @node Gamma Random Variable, Beta Random Variable, Lognormal Random Variable, Functions and Variables for continuous distributions
2923 @subsection Gamma Random Variable
2925 The @emph{gamma distribution} is a two-parameter family of probability
2926 distributions. Maxima uses the parameterization using the shape and
2927 scale for the first and second parameters of the distribution.
2930 @deffn {Function} pdf_gamma (@var{x},@var{a},@var{b})
2931 Returns the value at @var{x} of the density function of a
2933 random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
2935 The shape parameter is @math{a}, and the scale parameter is @math{b}.
2939 <<<f(x; a, b) = {x^{a-1}e^{-x/b}\over b^a \Gamma(a)}>>>,
2944 f(x, a, b) = ---------------------------
2950 @opencatbox{Categories:}
2951 @category{Package distrib}
2958 @deffn {Function} cdf_gamma (@var{x},@var{a},@var{b})
2959 Returns the value at @var{x} of the cumulative distribution function of a
2961 random variable, with @math{a,b>0}.
2967 1-Q(a,{x\over b}) & for $x \ge 0$ \cr
2973 [ 1 - Q(a,x/b) for x>= 0
2978 where @math{Q(a,z)} is the @ref{gamma_incomplete_regularized} function.
2980 @c load ("distrib")$
2981 @c cdf_gamma(3,5,21);
2985 (%i1) load ("distrib")$
2987 (%i2) cdf_gamma(3,5,21);
2989 (%o2) 1 - gamma_incomplete_regularized(5, -)
2994 (%o3) 4.402663157376807e-7
2998 @opencatbox{Categories:}
2999 @category{Package distrib}
3005 @anchor{quantile_gamma}
3006 @deffn {Function} quantile_gamma (@var{q},@var{a},@var{b})
3007 Returns the @var{q}-quantile of a
3009 random variable, with @math{a,b>0}; in other words, this is the inverse of @code{cdf_gamma}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
3011 @opencatbox{Categories:}
3012 @category{Package distrib}
3019 @deffn {Function} mean_gamma (@var{a},@var{b})
3020 Returns the mean of a
3022 random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
3033 @opencatbox{Categories:}
3034 @category{Package distrib}
3041 @deffn {Function} var_gamma (@var{a},@var{b})
3042 Returns the variance of a
3044 random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
3056 @opencatbox{Categories:}
3057 @category{Package distrib}
3063 @deffn {Function} std_gamma (@var{a},@var{b})
3064 Returns the standard deviation of a
3066 random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
3068 The standard deviation is
3070 <<<D[X] = b\sqrt{a}>>>,
3077 @opencatbox{Categories:}
3078 @category{Package distrib}
3084 @anchor{skewness_gamma}
3085 @deffn {Function} skewness_gamma (@var{a},@var{b})
3086 Returns the skewness coefficient of a
3088 random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
3090 The skewness coefficient is
3092 <<<SK[X] = {2\over \sqrt{a}}>>>,
3101 @opencatbox{Categories:}
3102 @category{Package distrib}
3108 @anchor{kurtosis_gamma}
3109 @deffn {Function} kurtosis_gamma (@var{a},@var{b})
3110 Returns the kurtosis coefficient of a
3112 random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
3114 The kurtosis coefficient is
3116 <<<KU[X] = {6\over a}>>>,
3126 @opencatbox{Categories:}
3127 @category{Package distrib}
3133 @anchor{random_gamma}
3134 @deffn {Function} random_gamma (@var{a},@var{b}) @
3135 @fname{random_gamma} (@var{a},@var{b},@var{n})
3139 random variate, with @math{a,b>0}. Calling @code{random_gamma} with a third argument @var{n}, a random sample of size @var{n} will be simulated.
3141 The implemented algorithm is a combination of two procedures, depending on the value of parameter @var{a}:
3144 m4_mathcomma(<<<a \ge 1>>>, <<<a >= 1>>>)
3145 Cheng, R.C.H. and Feast, G.M. (1979). @var{Some simple gamma variate generators}. Appl. Stat., 28, 3, 290-295.
3148 m4_mathcomma(<<<0 \lt a \lt 1>>>, <<<0 < a < 1>>>, <<<0 < a < 1>>>)
3149 Ahrens, J.H. and Dieter, U. (1974). @var{Computer methods for sampling from gamma, , poisson and binomial distributions}. Computing, 12, 223-246.
3151 To make use of this function, write first @code{load("distrib")}.
3153 @opencatbox{Categories:}
3154 @category{Package distrib}
3155 @category{Random numbers}
3161 @node Beta Random Variable, Continuous Uniform Random Variable, Gamma Random Variable, Functions and Variables for continuous distributions
3162 @subsection Beta Random Variable
3164 The @emph{beta} distribution is a family of distributions defined over
3165 @math{[0,1]} parameterized by two positive shape parameters @math{a},
3169 @deffn {Function} pdf_beta (@var{x},@var{a},@var{b})
3170 Returns the value at @var{x} of the density function of a
3172 random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
3178 \displaystyle{x^{a-1}(1-x)^{b-1} \over B(a,b)} & for $0 \le x \le 1$
3187 f(x, a, b) = [ ------------------- for 0 <= x <= 1
3194 @opencatbox{Categories:}
3195 @category{Package distrib}
3203 @deffn {Function} cdf_beta (@var{x},@var{a},@var{b})
3204 Returns the value at @var{x} of the cumulative distribution function of a
3206 random variable, with @math{a,b>0}.
3213 I_x(a,b) & $0 \le x \le 1$ \cr
3220 F(x, a, b) = [ beta_incomplete_regularized(a, b, x) for 0 <= x <= 1
3226 @c load ("distrib")$
3227 @c cdf_beta(1/3,15,2);
3231 (%i1) load ("distrib")$
3233 (%i2) cdf_beta(1/3,15,2);
3240 (%o3) 7.666089131388195e-7
3244 @opencatbox{Categories:}
3245 @category{Package distrib}
3251 @anchor{quantile_beta}
3252 @deffn {Function} quantile_beta (@var{q},@var{a},@var{b})
3253 Returns the @var{q}-quantile of a
3255 random variable, with @math{a,b>0}; in other words, this is the inverse of @code{cdf_beta}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
3257 @opencatbox{Categories:}
3258 @category{Package distrib}
3265 @deffn {Function} mean_beta (@var{a},@var{b})
3266 Returns the mean of a
3268 random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
3272 <<<E[X] = {a\over a+b}>>>,
3281 @opencatbox{Categories:}
3282 @category{Package distrib}
3289 @deffn {Function} var_beta (@var{a},@var{b})
3290 Returns the variance of a
3292 random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
3296 <<<V[X] = {ab \over (a+b)^2(a+b+1)}>>>,
3300 V[X] = --------------------
3306 @opencatbox{Categories:}
3307 @category{Package distrib}
3313 @deffn {Function} std_beta (@var{a},@var{b})
3314 Returns the standard deviation of a
3316 random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
3318 The standard deviation is
3320 <<<D[X] = {1\over a+b}\sqrt{ab\over a+b+1}>>>,
3326 D[X] = ---------------
3331 @opencatbox{Categories:}
3332 @category{Package distrib}
3338 @anchor{skewness_beta}
3339 @deffn {Function} skewness_beta (@var{a},@var{b})
3340 Returns the skewness coefficient of a
3342 random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
3344 The skewness coefficient is
3346 <<<SK[X] = {2(b-a)\sqrt{a+b+1} \over (a+b+2)\sqrt{ab}}>>>,
3349 2 (b - a) sqrt(b + a + 1)
3350 SK[X] = -------------------------
3351 sqrt(a b) (b + a + 2)
3354 @opencatbox{Categories:}
3355 @category{Package distrib}
3361 @anchor{kurtosis_beta}
3362 @deffn {Function} kurtosis_beta (@var{a},@var{b})
3363 Returns the kurtosis coefficient of a
3365 random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
3367 The kurtosis coefficient is
3369 <<<KU[X] = {3(a+b+1)\left(2(a+b)^2+ab(a+b-6)\right) \over
3370 ab(a+b+2)(a+b+3)} - 3>>>,
3374 3 (b + a + 1) (2 (b + a) + a b (b + a - 6))
3375 KU[X] = -------------------------------------------- - 3
3376 a b (b + a + 2) (b + a + 3)
3380 @opencatbox{Categories:}
3381 @category{Package distrib}
3387 @anchor{random_beta}
3388 @deffn {Function} random_beta (@var{a},@var{b}) @
3389 @fname{random_beta} (@var{a},@var{b},@var{n})
3393 random variate, with @math{a,b>0}. Calling @code{random_beta} with a third argument @var{n}, a random sample of size @var{n} will be simulated.
3395 The implemented algorithm is defined in Cheng, R.C.H. (1978). @var{Generating Beta Variates with Nonintegral Shape Parameters}. Communications of the ACM, 21:317-322
3397 To make use of this function, write first @code{load("distrib")}.
3399 @opencatbox{Categories:}
3400 @category{Package distrib}
3401 @category{Random numbers}
3406 @node Continuous Uniform Random Variable, Logistic Random Variable, Beta Random Variable, Functions and Variables for continuous distributions
3407 @subsection Continuous Uniform Random Variable
3409 The @emph{continuous uniform} distribution is constant over the
3410 interval @math{[a,b]} and is zero elsewhere.
3412 @anchor{pdf_continuous_uniform}
3413 @deffn {Function} pdf_continuous_uniform (@var{x},@var{a},@var{b})
3414 Returns the value at @var{x} of the density function of a
3415 m4_Continuous_Uniform_RV(a,b)
3416 random variable, with
3417 m4_mathdot(<<<a \lt b>>>, <<<a < b>>>, <<<a < b>>>)
3418 To make use of this function, write first @code{load("distrib")}.
3424 \displaystyle{1\over b-a} & for $0 \le x \le 1$ \cr
3430 [ 1/(b-a) for 0 <= x <= 1
3437 @opencatbox{Categories:}
3438 @category{Package distrib}
3444 @anchor{cdf_continuous_uniform}
3445 @deffn {Function} cdf_continuous_uniform (@var{x},@var{a},@var{b})
3446 Returns the value at @var{x} of the cumulative distribution function of a
3447 m4_Continuous_Uniform_RV(a,b)
3448 random variable, with
3449 m4_mathdot(<<<a \lt b>>>, <<<a < b>>>, <<<a < b>>>)
3450 To make use of this function, write first @code{load("distrib")}.
3458 \displaystyle{x-a\over b-a} & for $a \le x \le b$ \cr
3465 F(x,a,b) = [ (x-a)/(b-a) for a <= x <= b
3469 @opencatbox{Categories:}
3470 @category{Package distrib}
3476 @anchor{quantile_continuous_uniform}
3477 @deffn {Function} quantile_continuous_uniform (@var{q},@var{a},@var{b})
3478 Returns the @var{q}-quantile of a
3479 m4_Continuous_Uniform_RV(a,b)
3482 m4_math(<<<a \lt b>>>, <<<a < b>>>, <<<a < b>>>)
3483 ; in other words, this is the inverse of @code{cdf_continuous_uniform}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
3485 @opencatbox{Categories:}
3486 @category{Package distrib}
3492 @anchor{mean_continuous_uniform}
3493 @deffn {Function} mean_continuous_uniform (@var{a},@var{b})
3494 Returns the mean of a
3495 m4_Continuous_Uniform_RV(a,b)
3498 m4_mathdot(<<<a \lt b>>>, <<<a < b>>>, <<<a < b>>>)
3499 To make use of this function, write first @code{load("distrib")}.
3503 <<<E[X] = {a+b\over 2}>>>,
3512 @opencatbox{Categories:}
3513 @category{Package distrib}
3519 @anchor{var_continuous_uniform}
3520 @deffn {Function} var_continuous_uniform (@var{a},@var{b})
3521 Returns the variance of a
3522 m4_Continuous_Uniform_RV(a,b)
3525 m4_mathdot(<<<a \lt b>>>, <<<a < b>>>, <<<a < b>>>)
3526 To make use of this function, write first @code{load("distrib")}.
3530 <<<V[X] = {(b-a)^2\over 12}>>>,
3540 @opencatbox{Categories:}
3541 @category{Package distrib}
3546 @anchor{std_continuous_uniform}
3547 @deffn {Function} std_continuous_uniform (@var{a},@var{b})
3548 Returns the standard deviation of a
3549 m4_Continuous_Uniform_RV(a,b)
3550 random variable, with
3551 m4_mathdot(<<<a \lt b>>>, <<<a < b>>>, <<<a < b>>>)
3552 To make use of this function, write first @code{load("distrib")}.
3554 The standard deviation is
3556 <<<D[X] = {b-a \over 2\sqrt{3}}>>>,
3566 @opencatbox{Categories:}
3567 @category{Package distrib}
3573 @anchor{skewness_continuous_uniform}
3574 @deffn {Function} skewness_continuous_uniform (@var{a},@var{b})
3575 Returns the skewness coefficient of a
3576 m4_Continuous_Uniform_RV(a,b)
3577 random variable, with
3578 m4_mathdot(<<<a \lt b>>>, <<<a < b>>>, <<<a < b>>>)
3579 To make use of this function, write first @code{load("distrib")}.
3581 The skewness coefficient is
3590 @opencatbox{Categories:}
3591 @category{Package distrib}
3597 @anchor{kurtosis_continuous_uniform}
3598 @deffn {Function} kurtosis_continuous_uniform (@var{a},@var{b})
3599 Returns the kurtosis coefficient of a
3600 m4_Continuous_Uniform_RV(a,b)
3601 random variable, with
3602 m4_mathdot(<<<a \lt b>>>, <<<a < b>>>, <<<a < b>>>)
3603 To make use of this function, write first @code{load("distrib")}.
3605 The kurtosis coefficient is
3607 <<<KU[X] = -{6\over5}>>>,
3614 @opencatbox{Categories:}
3615 @category{Package distrib}
3621 @anchor{random_continuous_uniform}
3622 @deffn {Function} random_continuous_uniform (@var{a},@var{b}) @
3623 @fname{random_continuous_uniform} (@var{a},@var{b},@var{n})
3626 m4_Continuous_Uniform_RV(a,b)
3627 random variate, with
3628 m4_mathdot(<<<a \lt b>>>, <<<a < b>>>, <<<a < b>>>)
3629 Calling @code{random_continuous_uniform} with a third argument @var{n}, a random sample of size @var{n} will be simulated.
3631 This is a direct application of the @code{random} built-in Maxima function.
3633 See also @mrefdot{random} To make use of this function, write first @code{load("distrib")}.
3635 @opencatbox{Categories:}
3636 @category{Package distrib}
3637 @category{Random numbers}
3643 @node Logistic Random Variable, Pareto Random Variable, Continuous Uniform Random Variable, Functions and Variables for continuous distributions
3644 @subsection Logistic Random Variable
3646 The @emph{logistic} distribution is a continuous distribution where
3647 its cumulative distribution function is the logistic function.
3649 @anchor{pdf_logistic}
3650 @deffn {Function} pdf_logistic (@var{x},@var{a},@var{b})
3651 Returns the value at @var{x} of the density function of a
3653 random variable , with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
3655 @math{a} is the location parameter and @math{b} is the scale
3660 <<<f(x; a, b) = {e^{-(x-a)/b} \over b\left(1 + e^{-(x-a)/b}\right)^2}>>>,
3667 f(x, a, b) = ----------------
3674 @opencatbox{Categories:}
3675 @category{Package distrib}
3681 @anchor{cdf_logistic}
3682 @deffn {Function} cdf_logistic (@var{x},@var{a},@var{b})
3683 Returns the value at @var{x} of the cumulative distribution function of a
3685 random variable , with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
3689 <<<F(x; a, b) = {1\over 1+e^{-(x-a)/b}}>>>,
3693 F(x, a, b) = -----------
3701 @opencatbox{Categories:}
3702 @category{Package distrib}
3708 @anchor{quantile_logistic}
3709 @deffn {Function} quantile_logistic (@var{q},@var{a},@var{b})
3710 Returns the @var{q}-quantile of a
3712 random variable , with @math{b>0}; in other words, this is the inverse of @code{cdf_logistic}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
3714 @opencatbox{Categories:}
3715 @category{Package distrib}
3721 @anchor{mean_logistic}
3722 @deffn {Function} mean_logistic (@var{a},@var{b})
3723 Returns the mean of a
3725 random variable , with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
3736 @opencatbox{Categories:}
3737 @category{Package distrib}
3743 @anchor{var_logistic}
3744 @deffn {Function} var_logistic (@var{a},@var{b})
3745 Returns the variance of a
3747 random variable , with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
3751 <<<V[X] = {\pi^2 b^2 \over 3}>>>,
3762 @opencatbox{Categories:}
3763 @category{Package distrib}
3769 @anchor{std_logistic}
3770 @deffn {Function} std_logistic (@var{a},@var{b})
3771 Returns the standard deviation of a
3773 random variable , with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
3775 The standard deviation is
3777 <<<D[X] = {\pi b\over \sqrt{3}}>>>,
3786 @opencatbox{Categories:}
3787 @category{Package distrib}
3793 @anchor{skewness_logistic}
3794 @deffn {Function} skewness_logistic (@var{a},@var{b})
3795 Returns the skewness coefficient of a
3797 random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
3799 The skewness coefficient is
3808 @opencatbox{Categories:}
3809 @category{Package distrib}
3815 @anchor{kurtosis_logistic}
3816 @deffn {Function} kurtosis_logistic (@var{a},@var{b})
3817 Returns the kurtosis coefficient of a
3819 random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
3821 The kurtosis coefficient is
3823 <<<KU[X] = {6\over 5}>>>,
3832 @opencatbox{Categories:}
3833 @category{Package distrib}
3839 @anchor{random_logistic}
3840 @deffn {Function} random_logistic (@var{a},@var{b}) @
3841 @fname{random_logistic} (@var{a},@var{b},@var{n})
3845 random variate, with @math{b>0}. Calling @code{random_logistic} with a third argument @var{n}, a random sample of size @var{n} will be simulated.
3847 The implemented algorithm is based on the general inverse method.
3849 To make use of this function, write first @code{load("distrib")}.
3851 @opencatbox{Categories:}
3852 @category{Package distrib}
3853 @category{Random numbers}
3859 @node Pareto Random Variable, Weibull Random Variable, Logistic Random Variable, Functions and Variables for continuous distributions
3860 @subsection Pareto Random Variable
3863 @deffn {Function} pdf_pareto (@var{x},@var{a},@var{b})
3864 Returns the value at @var{x} of the density function of a
3866 random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
3872 \displaystyle{a b^a \over x^{a+1}} & for $x \ge b$ \cr
3878 [ a*b^a/x^(a+1) for x >= b
3884 @opencatbox{Categories:}
3885 @category{Package distrib}
3892 @deffn {Function} cdf_pareto (@var{x},@var{a},@var{b})
3893 Returns the value at @var{x} of the cumulative distribution function of a
3895 random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
3901 1-\left(\displaystyle{b\over x}\right)^a & for $x \ge b$\cr
3906 [ 1 - (b/x)^a for x >= 0
3911 @opencatbox{Categories:}
3912 @category{Package distrib}
3918 @anchor{quantile_pareto}
3919 @deffn {Function} quantile_pareto (@var{q},@var{a},@var{b})
3920 Returns the @var{q}-quantile of a
3922 random variable, with @math{a,b>0}; in other words, this is the inverse of @code{cdf_pareto}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
3924 @opencatbox{Categories:}
3925 @category{Package distrib}
3931 @anchor{mean_pareto}
3932 @deffn {Function} mean_pareto (@var{a},@var{b})
3933 Returns the mean of a
3935 random variable, with @math{a>1,b>0}. To make use of this function, write first @code{load("distrib")}.
3939 <<<E[X] = {ab\over a-1}>>>,
3940 <<<@math{E[X] = a*b/(a-1)}>>>)
3942 @opencatbox{Categories:}
3943 @category{Package distrib}
3950 @deffn {Function} var_pareto (@var{a},@var{b})
3951 Returns the variance of a
3953 random variable, with @math{a>2,b>0}. To make use of this function, write first @code{load("distrib")}.
3957 <<<V[X] = {ab^2\over (a-2)(a-1)^2}>>>,
3962 V[X] = ----------------
3968 @opencatbox{Categories:}
3969 @category{Package distrib}
3975 @deffn {Function} std_pareto (@var{a},@var{b})
3976 Returns the standard deviation of a
3978 random variable, with @math{a>2,b>0}. To make use of this function, write first @code{load("distrib")}.
3980 The standard deviation is
3982 <<<D[X] = {b\over a-1} \sqrt{a\over a-2}>>>,
3988 D[X] = -------------
3993 @opencatbox{Categories:}
3994 @category{Package distrib}
4001 @anchor{skewness_pareto}
4002 @deffn {Function} skewness_pareto (@var{a},@var{b})
4003 Returns the skewness coefficient of a
4005 random variable, with @math{a>3,b>0}. To make use of this function, write first @code{load("distrib")}.
4007 The skewness coefficient is
4009 <<<SK[X] = {2(a+1)\over a-3} \sqrt{a-2\over a}>>>,
4012 2 sqrt(a - 2) (a + 1)
4013 SK[X] = ---------------------
4018 @opencatbox{Categories:}
4019 @category{Package distrib}
4025 @anchor{kurtosis_pareto}
4026 @deffn {Function} kurtosis_pareto (@var{a},@var{b})
4027 Returns the kurtosis coefficient of a
4029 random variable, with @math{a>4,b>0}. To make use of this function, write first @code{load("distrib")}.
4031 The kurtosis coefficient is
4033 <<<KU[X] = {6\left(a^3+a^2-6*a-2\right) \over a(a-3)(a-4)} - 3>>>,
4038 KU[X] = --------------------- - 3
4044 @opencatbox{Categories:}
4045 @category{Package distrib}
4051 @anchor{random_pareto}
4052 @deffn {Function} random_pareto (@var{a},@var{b}) @
4053 @fname{random_pareto} (@var{a},@var{b},@var{n})
4057 random variate, with @math{a>0,b>0}. Calling @code{random_pareto} with a third argument @var{n}, a random sample of size @var{n} will be simulated.
4059 The implemented algorithm is based on the general inverse method.
4061 To make use of this function, write first @code{load("distrib")}.
4063 @opencatbox{Categories:}
4064 @category{Package distrib}
4065 @category{Random numbers}
4071 @node Weibull Random Variable, Rayleigh Random Variable, Pareto Random Variable, Functions and Variables for continuous distributions
4072 @subsection Weibull Random Variable
4074 @anchor{pdf_weibull}
4075 @deffn {Function} pdf_weibull (@var{x},@var{a},@var{b})
4076 Returns the value at @var{x} of the density function of a
4078 random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
4084 \displaystyle{1\over b} \left({x\over b}\right)^{a-1} e^{-(x/b)^a} &
4093 [ a (-) %e unit_step(x)
4095 [ ---------------------------------- for x >= 0
4101 @opencatbox{Categories:}
4102 @category{Package distrib}
4108 @anchor{cdf_weibull}
4109 @deffn {Function} cdf_weibull (@var{x},@var{a},@var{b})
4110 Returns the value at @var{x} of the cumulative distribution function of a
4112 random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
4118 1 - e^{-(x/b)^a} & for $x \ge 0$ \cr
4123 [ 1 - exp(-(x/b)^a) for x >= 0
4128 @opencatbox{Categories:}
4129 @category{Package distrib}
4135 @anchor{quantile_weibull}
4136 @deffn {Function} quantile_weibull (@var{q},@var{a},@var{b})
4137 Returns the @var{q}-quantile of a
4139 random variable, with @math{a,b>0}; in other words, this is the inverse of @code{cdf_weibull}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
4141 @opencatbox{Categories:}
4142 @category{Package distrib}
4148 @anchor{mean_weibull}
4149 @deffn {Function} mean_weibull (@var{a},@var{b})
4150 Returns the mean of a
4152 random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
4156 <<<E[X] = b\Gamma\left(1+{1\over a}\right)>>>,
4160 E[X] = gamma(- + 1) b
4165 @opencatbox{Categories:}
4166 @category{Package distrib}
4172 @anchor{var_weibull}
4173 @deffn {Function} var_weibull (@var{a},@var{b})
4174 Returns the variance of a
4176 random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
4180 <<<V[X] = b^2\left[\Gamma\left(1+{2\over a}\right) -
4181 \Gamma\left(1+{1\over a}\right)^2\right]>>>,
4185 V[X] = (gamma(- + 1) - gamma (- + 1)) b
4190 @opencatbox{Categories:}
4191 @category{Package distrib}
4196 @anchor{std_weibull}
4197 @deffn {Function} std_weibull (@var{a},@var{b})
4198 Returns the standard deviation of a
4200 random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
4204 <<<D[X] = b\sqrt{\Gamma\left(1+{2\over a}\right) -
4205 \Gamma\left(1+{1\over a}\right)^2}>>>,
4209 D[X] = sqrt(gamma(- + 1) - gamma (- + 1)) b
4214 @opencatbox{Categories:}
4215 @category{Package distrib}
4222 @anchor{skewness_weibull}
4223 @deffn {Function} skewness_weibull (@var{a},@var{b})
4224 Returns the skewness coefficient of a
4226 random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
4228 The skewness coefficient is
4230 <<<SK[X] = {\displaystyle\Gamma\left(1+{3\over a}\right)
4231 -3\Gamma\left(1+{1\over a}\right)\Gamma\left(1+{2\over
4232 a}\right)+2\Gamma\left(1+{1\over a}\right)^3
4234 \displaystyle\left[\Gamma\left(1+{2\over a}\right)-\Gamma\left(1+{1\over
4235 a}\right)^2\right]^{3/2}
4241 gamma(- + 1) - 3 gamma(- + 1) gamma(- + 1) + 2 gamma (- + 1)
4243 SK[X] = ------------------------------------------------------------
4245 (gamma(- + 1) - gamma (- + 1))
4250 @opencatbox{Categories:}
4251 @category{Package distrib}
4257 @anchor{kurtosis_weibull}
4258 @deffn {Function} kurtosis_weibull (@var{a},@var{b})
4259 Returns the kurtosis coefficient of a
4261 random variable, with @math{a,b>0}. To make use of this function, write first @code{load("distrib")}.
4263 The kurtosis coefficient is
4267 - 4\Gamma_1 \Gamma_3
4268 + 6\Gamma_1^2 \Gamma_2
4271 \left[\Gamma_2 - \Gamma_1^2\right]^2
4276 KU[X] = (gamma(- + 1) - 4 gamma(- + 1) gamma(- + 1)
4279 + 6 gamma (- + 1) gamma(- + 1) - 3 gamma (- + 1))
4282 /(gamma(- + 1) - gamma (- + 1)) - 3
4288 m4_mathdot(\Gamma_k = \Gamma\left(1+k/a\right))
4291 @opencatbox{Categories:}
4292 @category{Package distrib}
4298 @anchor{random_weibull}
4299 @deffn {Function} random_weibull (@var{a},@var{b}) @
4300 @fname{random_weibull} (@var{a},@var{b},@var{n})
4304 random variate, with @math{a,b>0}. Calling @code{random_weibull} with a third argument @var{n}, a random sample of size @var{n} will be simulated.
4306 The implemented algorithm is based on the general inverse method.
4308 To make use of this function, write first @code{load("distrib")}.
4310 @opencatbox{Categories:}
4311 @category{Package distrib}
4312 @category{Random numbers}
4319 @node Rayleigh Random Variable, Laplace Random Variable, Weibull Random Variable, Functions and Variables for continuous distributions
4320 @subsection Rayleigh Random Variable
4322 The @emph{Rayleigh} distribution coincides with the
4325 distribution with two degrees of freedom.
4327 @anchor{pdf_rayleigh}
4328 @deffn {Function} pdf_rayleigh (@var{x},@var{b})
4329 Returns the value at @var{x} of the density function of a
4331 random variable, with @math{b>0}.
4335 random variable is equivalent to the
4336 m4_Weibull_RV(2,1/b)
4343 2b^2 x e^{-b^2 x^2} & for $x \ge 0$ \cr
4348 [ 2*b^2*x*exp(-b^2*x^2) for x>= 0
4354 @c load ("distrib")$
4355 @c pdf_rayleigh(x,b);
4358 (%i1) load ("distrib")$
4360 (%i2) pdf_rayleigh(x,b);
4363 (%o2) 2 b x %e unit_step(x)
4367 @opencatbox{Categories:}
4368 @category{Package distrib}
4374 @anchor{cdf_rayleigh}
4375 @deffn {Function} cdf_rayleigh (@var{x},@var{b})
4376 Returns the value at @var{x} of the cumulative distribution function of a
4378 random variable, with @math{b>0}.
4382 random variable is equivalent to the
4383 m4_Weibull_RV(2,1/b)
4390 1 - e^{-b^2 x^2} & for $x \ge 0$\cr
4395 [ 1 - exp(-b^2*x^2) for x >= 0
4401 @c load ("distrib")$
4402 @c cdf_rayleigh(x,b);
4405 (%i1) load ("distrib")$
4407 (%i2) cdf_rayleigh(x,b);
4410 (%o2) (1 - %e ) unit_step(x)
4414 @opencatbox{Categories:}
4415 @category{Package distrib}
4421 @anchor{quantile_rayleigh}
4422 @deffn {Function} quantile_rayleigh (@var{q},@var{b})
4423 Returns the @var{q}-quantile of a
4425 random variable, with @math{b>0}; in other words, this is the inverse of @code{cdf_rayleigh}. Argument @var{q} must be an element of @math{[0,1]}.
4429 random variable is equivalent to the
4430 m4_Weibull_RV(2,1/b)
4434 @c load ("distrib")$
4435 @c quantile_rayleigh(0.99,b);
4438 (%i1) load ("distrib")$
4440 (%i2) quantile_rayleigh(0.99,b);
4442 (%o2) -----------------
4447 @opencatbox{Categories:}
4448 @category{Package distrib}
4454 @anchor{mean_rayleigh}
4455 @deffn {Function} mean_rayleigh (@var{b})
4456 Returns the mean of a
4458 random variable, with @math{b>0}.
4462 random variable is equivalent to the
4463 m4_Weibull_RV(2,1/b)
4468 <<<E[X] = {\sqrt{\pi}\over 2b}>>>,
4478 @c load ("distrib")$
4479 @c mean_rayleigh(b);
4482 (%i1) load ("distrib")$
4484 (%i2) mean_rayleigh(b);
4491 @opencatbox{Categories:}
4492 @category{Package distrib}
4498 @anchor{var_rayleigh}
4499 @deffn {Function} var_rayleigh (@var{b})
4500 Returns the variance of a
4502 random variable, with @math{b>0}.
4506 random variable is equivalent to the
4507 m4_Weibull_RV(2,1/b)
4512 <<<V[X] = {1\over b^2}\left(1-{\pi \over 4}\right)>>>,
4525 @c load ("distrib")$
4529 (%i1) load ("distrib")$
4531 (%i2) var_rayleigh(b);
4541 @opencatbox{Categories:}
4542 @category{Package distrib}
4548 @anchor{std_rayleigh}
4549 @deffn {Function} std_rayleigh (@var{b})
4550 Returns the standard deviation of a
4552 random variable, with @math{b>0}.
4556 random variable is equivalent to the
4557 m4_Weibull_RV(2,1/b)
4560 The standard deviation is
4562 <<<D[X] = {1\over b}\sqrt{\displaystyle 1 - {\pi\over 4}}>>>,
4568 D[X] = -------------
4574 @c load ("distrib")$
4578 (%i1) load ("distrib")$
4580 (%i2) std_rayleigh(b);
4589 @opencatbox{Categories:}
4590 @category{Package distrib}
4596 @anchor{skewness_rayleigh}
4597 @deffn {Function} skewness_rayleigh (@var{b})
4598 Returns the skewness coefficient of a
4600 random variable, with @math{b>0}.
4604 random variable is equivalent to the
4605 m4_Weibull_RV(2,1/b)
4608 The skewness coefficient is
4610 <<<SK[X] = {2\sqrt{\pi}(\pi - 3)\over (4-\pi)^{3/2}}>>>,
4615 ------ - -----------
4617 SK[X] = --------------------
4625 @c load ("distrib")$
4626 @c skewness_rayleigh(b);
4629 (%i1) load ("distrib")$
4631 (%i2) skewness_rayleigh(b);
4634 ------ - -----------
4636 (%o2) --------------------
4643 @opencatbox{Categories:}
4644 @category{Package distrib}
4650 @anchor{kurtosis_rayleigh}
4651 @deffn {Function} kurtosis_rayleigh (@var{b})
4652 Returns the kurtosis coefficient of a
4654 random variable, with @math{b>0}.
4658 random variable is equivalent to the
4659 m4_Weibull_RV(2,1/b)
4662 The kurtosis coefficient is
4664 <<<KU[X] = {32-3\pi\over (4-\pi)^2} - 3>>>,
4671 KU[X] = ---------- - 3
4679 @c load ("distrib")$
4680 @c kurtosis_rayleigh(b);
4683 (%i1) load ("distrib")$
4685 (%i2) kurtosis_rayleigh(b);
4690 (%o2) ---------- - 3
4697 @opencatbox{Categories:}
4698 @category{Package distrib}
4704 @anchor{random_rayleigh}
4705 @deffn {Function} random_rayleigh (@var{b}) @
4706 @fname{random_rayleigh} (@var{b},@var{n})
4710 random variate, with @math{b>0}. Calling @code{random_rayleigh} with a second argument @var{n}, a random sample of size @var{n} will be simulated.
4712 The implemented algorithm is based on the general inverse method.
4714 To make use of this function, write first @code{load("distrib")}.
4716 @opencatbox{Categories:}
4717 @category{Package distrib}
4718 @category{Random numbers}
4725 @node Laplace Random Variable, Cauchy Random Variable, Rayleigh Random Variable, Functions and Variables for continuous distributions
4726 @subsection Laplace Random Variable
4728 The @emph{Laplace} distribution is a continuous probability
4729 distribution that is sometimes called the double exponential
4730 distribution because it can be thought of as two exponential
4731 distributions spliced back to back.
4733 @anchor{pdf_laplace}
4734 @deffn {Function} pdf_laplace (@var{x},@var{a},@var{b})
4735 Returns the value at @var{x} of the density function of a
4737 random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
4739 Here, @math{a} is the location parameter (or mean), and @math{b} is
4740 the scale parameter, related to the variance.
4744 <<<f(x; a, b) = {1\over 2b}\exp\left(-{|x-a|\over b}\right)>>>,
4751 f(x, a, b) = --------------
4754 @math{1/(2*b)*exp(-abs(x-a)/b)}>>>)
4756 @opencatbox{Categories:}
4757 @category{Package distrib}
4763 @anchor{cdf_laplace}
4764 @deffn {Function} cdf_laplace (@var{x},@var{a},@var{b})
4765 Returns the value at @var{x} of the cumulative distribution function of a
4767 random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
4773 \displaystyle{1\over 2} \exp\left({x-a\over b}\right) & for $x < a$\cr
4775 1-\displaystyle{1\over 2} \exp\left({x-a\over b}\right) & for $x \ge a$
4779 [ 1/2*exp((x-a)/b) for x < a
4781 [ 1-1/2*exp((x-a)/b) for x >= a
4784 @opencatbox{Categories:}
4785 @category{Package distrib}
4791 @anchor{quantile_laplace}
4792 @deffn {Function} quantile_laplace (@var{q},@var{a},@var{b})
4793 Returns the @var{q}-quantile of a
4795 random variable, with @math{b>0}; in other words, this is the inverse of @code{cdf_laplace}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
4797 @opencatbox{Categories:}
4798 @category{Package distrib}
4804 @anchor{mean_laplace}
4805 @deffn {Function} mean_laplace (@var{a},@var{b})
4806 Returns the mean of a
4808 random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
4819 @opencatbox{Categories:}
4820 @category{Package distrib}
4826 @anchor{var_laplace}
4827 @deffn {Function} var_laplace (@var{a},@var{b})
4828 Returns the variance of a
4830 random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
4842 @opencatbox{Categories:}
4843 @category{Package distrib}
4849 @anchor{std_laplace}
4850 @deffn {Function} std_laplace (@var{a},@var{b})
4851 Returns the standard deviation of a
4853 random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
4855 The standard deviation is
4857 <<<D[X] = \sqrt{2} b>>>,
4864 @opencatbox{Categories:}
4865 @category{Package distrib}
4871 @anchor{skewness_laplace}
4872 @deffn {Function} skewness_laplace (@var{a},@var{b})
4873 Returns the skewness coefficient of a
4875 random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
4877 The skewness coefficient is
4886 @opencatbox{Categories:}
4887 @category{Package distrib}
4893 @anchor{kurtosis_laplace}
4894 @deffn {Function} kurtosis_laplace (@var{a},@var{b})
4895 Returns the kurtosis coefficient of a
4897 random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
4899 The kurtosis coefficient is
4908 @opencatbox{Categories:}
4909 @category{Package distrib}
4915 @anchor{random_laplace}
4916 @deffn {Function} random_laplace (@var{a},@var{b}) @
4917 @fname{random_laplace} (@var{a},@var{b},@var{n})
4921 random variate, with @math{b>0}. Calling @code{random_laplace} with a third argument @var{n}, a random sample of size @var{n} will be simulated.
4923 The implemented algorithm is based on the general inverse method.
4925 To make use of this function, write first @code{load("distrib")}.
4927 @opencatbox{Categories:}
4928 @category{Package distrib}
4929 @category{Random numbers}
4936 @node Cauchy Random Variable, Gumbel Random Variable, Laplace Random Variable, Functions and Variables for continuous distributions
4937 @subsection Cauchy Random Variable
4939 The @emph{Cauchy} distribution (also known as the Lorentz
4940 distribution) is the distribution of of the ratio of two independent
4941 normally distributed random variables with mean zero.
4943 Note that the mean, variance, standard deviation, skewness
4944 coefficient, and kurtosis coefficient are all undefined for the Cauchy
4945 distribution. The integrals do not converge in this case.
4948 @deffn {Function} pdf_cauchy (@var{x},@var{a},@var{b})
4949 Returns the value at @var{x} of the density function of a
4951 random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
4955 <<<f(x; a, b) = {b\over \pi\left((x-a)^2+b^2\right)}>>>,
4959 f(x, a, b) = -------------------
4964 @opencatbox{Categories:}
4965 @category{Package distrib}
4972 @deffn {Function} cdf_cauchy (@var{x},@var{a},@var{b})
4973 Returns the value at @var{x} of the cumulative distribution function of a
4975 random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
4979 <<<F(x; a, b) = {1\over 2} + {1\over \pi} \tan^{-1} {x-a\over b}>>>,
4985 F(x, a, b) = ----------- + -
4989 @opencatbox{Categories:}
4990 @category{Package distrib}
4996 @anchor{quantile_cauchy}
4997 @deffn {Function} quantile_cauchy (@var{q},@var{a},@var{b})
4998 Returns the @var{q}-quantile of a
5000 random variable, with @math{b>0}; in other words, this is the inverse of @code{cdf_cauchy}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
5002 @opencatbox{Categories:}
5003 @category{Package distrib}
5009 @anchor{random_cauchy}
5010 @deffn {Function} random_cauchy (@var{a},@var{b}) @
5011 @fname{random_cauchy} (@var{a},@var{b},@var{n})
5015 random variate, with @math{b>0}. Calling @code{random_cauchy} with a third argument @var{n}, a random sample of size @var{n} will be simulated.
5017 The implemented algorithm is based on the general inverse method.
5019 To make use of this function, write first @code{load("distrib")}.
5021 @opencatbox{Categories:}
5022 @category{Package distrib}
5023 @category{Random numbers}
5030 @node Gumbel Random Variable, , Cauchy Random Variable, Functions and Variables for continuous distributions
5031 @subsection Gumbel Random Variable
5034 @deffn {Function} pdf_gumbel (@var{x},@var{a},@var{b})
5035 Returns the value at @var{x} of the density function of a
5037 random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
5041 <<<f(x; a, b) = {1\over b} \exp\left[{a-x\over b} - \exp\left({a-x\over b}\right)\right]>>>,
5050 f(x, a, b) = -----------------
5055 @opencatbox{Categories:}
5056 @category{Package distrib}
5063 @deffn {Function} cdf_gumbel (@var{x},@var{a},@var{b})
5064 Returns the value at @var{x} of the cumulative distribution function of a
5066 random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
5070 <<<F(x; a, b) = \exp\left[-\exp\left({a-x\over b}\right)\right]>>>,
5080 @opencatbox{Categories:}
5081 @category{Package distrib}
5087 @anchor{quantile_gumbel}
5088 @deffn {Function} quantile_gumbel (@var{q},@var{a},@var{b})
5089 Returns the @var{q}-quantile of a
5091 random variable, with @math{b>0}; in other words, this is the inverse of @code{cdf_gumbel}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
5093 @opencatbox{Categories:}
5094 @category{Package distrib}
5100 @anchor{mean_gumbel}
5101 @deffn {Function} mean_gumbel (@var{a},@var{b})
5102 Returns the mean of a
5104 random variable, with @math{b>0}.
5108 <<<E[X] = a+b\gamma>>>,
5116 @c load ("distrib")$
5117 @c mean_gumbel(a,b);
5120 (%i1) load ("distrib")$
5122 (%i2) mean_gumbel(a,b);
5126 where symbol @code{%gamma} stands for the Euler-Mascheroni constant. See also @mrefdot{%gamma}
5128 @opencatbox{Categories:}
5129 @category{Package distrib}
5136 @deffn {Function} var_gumbel (@var{a},@var{b})
5137 Returns the variance of a
5139 random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
5143 <<<V[X] = {\pi^2\over 6} b^2>>>,
5153 @opencatbox{Categories:}
5154 @category{Package distrib}
5161 @deffn {Function} std_gumbel (@var{a},@var{b})
5162 Returns the standard deviation of a
5164 random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
5166 The standard deviation is
5168 <<<D[X] = {\pi \over \sqrt{6}} b>>>,
5177 @opencatbox{Categories:}
5178 @category{Package distrib}
5184 @anchor{skewness_gumbel}
5185 @deffn {Function} skewness_gumbel (@var{a},@var{b})
5186 Returns the skewness coefficient of a
5188 random variable, with @math{b>0}.
5190 The skewness coefficient is
5192 <<<SK[X] = {12\sqrt{6}\over \pi^3} \zeta(3)>>>,
5197 SK[X] = --------------
5204 @c load ("distrib")$
5205 @c skewness_gumbel(a,b);
5208 (%i1) load ("distrib")$
5210 (%i2) skewness_gumbel(a,b);
5213 (%o2) --------------
5218 where @code{zeta} stands for the Riemann's zeta function.
5220 @opencatbox{Categories:}
5221 @category{Package distrib}
5227 @anchor{kurtosis_gumbel}
5228 @deffn {Function} kurtosis_gumbel (@var{a},@var{b})
5229 Returns the kurtosis coefficient of a
5231 random variable, with @math{b>0}. To make use of this function, write first @code{load("distrib")}.
5233 The kurtosis coefficient is
5235 <<<KU[X] = {12\over 5}>>>,
5244 @opencatbox{Categories:}
5245 @category{Package distrib}
5246 @category{Package distrib}
5252 @anchor{random_gumbel}
5253 @deffn {Function} random_gumbel (@var{a},@var{b}) @
5254 @fname{random_gumbel} (@var{a},@var{b},@var{n})
5258 random variate, with @math{b>0}. Calling @code{random_gumbel} with a third argument @var{n}, a random sample of size @var{n} will be simulated.
5260 The implemented algorithm is based on the general inverse method.
5262 To make use of this function, write first @code{load("distrib")}.
5264 @opencatbox{Categories:}
5265 @category{Package distrib}
5266 @category{Random numbers}
5272 @node Functions and Variables for discrete distributions, , Functions and Variables for continuous distributions, Package distrib
5273 @section Functions and Variables for discrete distributions
5275 Maxima knows the following kinds of discrete distributions
5279 * General Finite Discrete Random Variable::
5280 * Binomial Random Variable::
5281 * Poisson Random Variable::
5282 * Bernoulli Random Variable::
5283 * Geometric Random Variable::
5284 * Discrete Uniform Random Variable::
5285 * Hypergeometric Random Variable::
5286 * Negative Binomial Random Variable::
5289 @node General Finite Discrete Random Variable, Binomial Random Variable, Functions and Variables for discrete distributions, Functions and Variables for discrete distributions
5290 @subsection General Finite Discrete Random Variable
5292 @anchor{pdf_general_finite_discrete}
5293 @deffn {Function} pdf_general_finite_discrete (@var{x},@var{v})
5294 Returns the value at @var{x} of the probability function of a general finite discrete random variable, with vector probabilities @math{v}, such that @code{Pr(X=i) = v_i}. Vector @math{v} can be a list of nonnegative expressions, whose components will be normalized to get a vector of probabilities. To make use of this function, write first @code{load("distrib")}.
5297 @c load ("distrib")$
5298 @c pdf_general_finite_discrete(2, [1/7, 4/7, 2/7]);
5299 @c pdf_general_finite_discrete(2, [1, 4, 2]);
5302 (%i1) load ("distrib")$
5304 (%i2) pdf_general_finite_discrete(2, [1/7, 4/7, 2/7]);
5310 (%i3) pdf_general_finite_discrete(2, [1, 4, 2]);
5317 @opencatbox{Categories:}
5318 @category{Package distrib}
5324 @anchor{cdf_general_finite_discrete}
5325 @deffn {Function} cdf_general_finite_discrete (@var{x},@var{v})
5326 Returns the value at @var{x} of the cumulative distribution function of a general finite discrete random variable, with vector probabilities @math{v}.
5328 See @code{pdf_general_finite_discrete} for more details.
5331 @c load ("distrib")$
5332 @c cdf_general_finite_discrete(2, [1/7, 4/7, 2/7]);
5333 @c cdf_general_finite_discrete(2, [1, 4, 2]);
5334 @c cdf_general_finite_discrete(2+1/2, [1, 4, 2]);
5337 (%i1) load ("distrib")$
5339 (%i2) cdf_general_finite_discrete(2, [1/7, 4/7, 2/7]);
5345 (%i3) cdf_general_finite_discrete(2, [1, 4, 2]);
5351 (%i4) cdf_general_finite_discrete(2+1/2, [1, 4, 2]);
5358 @opencatbox{Categories:}
5359 @category{Package distrib}
5365 @anchor{quantile_general_finite_discrete}
5366 @deffn {Function} quantile_general_finite_discrete (@var{q},@var{v})
5367 Returns the @var{q}-quantile of a general finite discrete random variable, with vector probabilities @math{v}.
5369 See @code{pdf_general_finite_discrete} for more details.
5371 @opencatbox{Categories:}
5372 @category{Package distrib}
5378 @anchor{mean_general_finite_discrete}
5379 @deffn {Function} mean_general_finite_discrete (@var{v})
5380 Returns the mean of a general finite discrete random variable, with vector probabilities @math{v}.
5382 See @code{pdf_general_finite_discrete} for more details.
5384 @opencatbox{Categories:}
5385 @category{Package distrib}
5391 @anchor{var_general_finite_discrete}
5392 @deffn {Function} var_general_finite_discrete (@var{v})
5393 Returns the variance of a general finite discrete random variable, with vector probabilities @math{v}.
5395 See @code{pdf_general_finite_discrete} for more details.
5397 @opencatbox{Categories:}
5398 @category{Package distrib}
5404 @anchor{std_general_finite_discrete}
5405 @deffn {Function} std_general_finite_discrete (@var{v})
5406 Returns the standard deviation of a general finite discrete random variable, with vector probabilities @math{v}.
5408 See @code{pdf_general_finite_discrete} for more details.
5410 @opencatbox{Categories:}
5411 @category{Package distrib}
5417 @anchor{skewness_general_finite_discrete}
5418 @deffn {Function} skewness_general_finite_discrete (@var{v})
5419 Returns the skewness coefficient of a general finite discrete random variable, with vector probabilities @math{v}.
5421 See @code{pdf_general_finite_discrete} for more details.
5423 @opencatbox{Categories:}
5424 @category{Package distrib}
5430 @anchor{kurtosis_general_finite_discrete}
5431 @deffn {Function} kurtosis_general_finite_discrete (@var{v})
5432 Returns the kurtosis coefficient of a general finite discrete random variable, with vector probabilities @math{v}.
5434 See @code{pdf_general_finite_discrete} for more details.
5436 @opencatbox{Categories:}
5437 @category{Package distrib}
5443 @anchor{random_general_finite_discrete}
5444 @deffn {Function} random_general_finite_discrete (@var{v}) @
5445 @fname{random_general_finite_discrete} (@var{v},@var{m})
5447 Returns a general finite discrete random variate, with vector probabilities @math{v}. Calling @code{random_general_finite_discrete} with a second argument @var{m}, a random sample of size @var{m} will be simulated.
5449 See @code{pdf_general_finite_discrete} for more details.
5452 @c load ("distrib")$
5453 @c random_general_finite_discrete([1,3,1,5]);
5454 @c random_general_finite_discrete([1,3,1,5], 10);
5457 (%i1) load ("distrib")$
5459 (%i2) random_general_finite_discrete([1,3,1,5]);
5463 (%i3) random_general_finite_discrete([1,3,1,5], 10);
5464 (%o3) [3, 4, 3, 4, 4, 4, 4, 2, 4, 4]
5468 @opencatbox{Categories:}
5469 @category{Package distrib}
5470 @category{Random numbers}
5475 @node Binomial Random Variable, Poisson Random Variable, General Finite Discrete Random Variable, Functions and Variables for discrete distributions
5476 @subsection Binomial Random Variable
5478 The @emph{binomial distribution} with parameters @math{n} and @math{p}
5479 is a discrete probability distribution. It consists of @math{n}
5480 independent experiments where each experiment consists of a
5481 Boolean-valued outcome where a success occurs with a probablity
5484 For example, a biased coin that comes up heads with probablity
5485 @math{p} is tossed @math{n} times. Then the probability of exactly
5486 @math{k} heads in @math{n} tosses is given by the binomial
5489 @anchor{pdf_binomial}
5490 @deffn {Function} pdf_binomial (@var{x},@var{n},@var{p})
5491 Returns the value at @var{x} of the probability function of a
5493 random variable, with @math{0 \leq p \leq 1} and @math{n} a positive integer. To make use of this function, write first @code{load("distrib")}.
5497 <<<f(x; n, p) = {n\choose x} (1-p)^{n-x}p^x>>>,
5501 f(x, n, p) = binomial(n, x) (1 - p) p
5505 @opencatbox{Categories:}
5506 @category{Package distrib}
5512 @anchor{cdf_binomial}
5513 @deffn {Function} cdf_binomial (@var{x},@var{n},@var{p})
5514 Returns the value at @var{x} of the cumulative distribution function of a
5516 random variable, with @math{0 \leq p \leq 1} and @math{n} a positive integer.
5520 <<<F(x; n, p) = I_{1-p}(n-\lfloor x \rfloor, \lfloor x \rfloor + 1)>>>,
5523 F(x, n, p) = beta_incomplete_regularized(n - floor(x), floor(x) + 1,
5530 is the @ref{beta_incomplete_regularized}
5536 @c load ("distrib")$
5537 @c cdf_binomial(5,7,1/6);
5541 (%i1) load ("distrib")$
5543 (%i2) cdf_binomial(5,7,1/6);
5550 (%o3) 0.9998713991769548
5554 @opencatbox{Categories:}
5555 @category{Package distrib}
5561 @anchor{quantile_binomial}
5562 @deffn {Function} quantile_binomial (@var{q},@var{n},@var{p})
5563 Returns the @var{q}-quantile of a
5565 random variable, with @math{0 \leq p \leq 1} and @math{n} a positive integer; in other words, this is the inverse of @code{cdf_binomial}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
5567 @opencatbox{Categories:}
5568 @category{Package distrib}
5574 @anchor{mean_binomial}
5575 @deffn {Function} mean_binomial (@var{n},@var{p})
5576 Returns the mean of a
5578 random variable, with @math{0 \leq p \leq 1} and @math{n} a positive integer. To make use of this function, write first @code{load("distrib")}.
5590 @opencatbox{Categories:}
5591 @category{Package distrib}
5597 @anchor{var_binomial}
5598 @deffn {Function} var_binomial (@var{n},@var{p})
5599 Returns the variance of a
5601 random variable, with @math{0 \leq p \leq 1} and @math{n} a positive integer. To make use of this function, write first @code{load("distrib")}.
5605 <<<V[X] = np(1-p)>>>,
5612 @opencatbox{Categories:}
5613 @category{Package distrib}
5619 @anchor{std_binomial}
5620 @deffn {Function} std_binomial (@var{n},@var{p})
5621 Returns the standard deviation of a
5623 random variable, with @math{0 \leq p \leq 1} and @math{n} a positive integer. To make use of this function, write first @code{load("distrib")}.
5625 The standard deviation is
5627 <<<D[X] = \sqrt{np(1-p)}>>>,
5630 D[X] = sqrt(n (1 - p) p)
5634 @opencatbox{Categories:}
5635 @category{Package distrib}
5641 @anchor{skewness_binomial}
5642 @deffn {Function} skewness_binomial (@var{n},@var{p})
5643 Returns the skewness coefficient of a
5645 random variable, with @math{0 \leq p \leq 1} and @math{n} a positive integer. To make use of this function, write first @code{load("distrib")}.
5647 The skewness coefficient is
5649 <<<SK[X] = {1-2p\over \sqrt{np(1-p)}}>>>,
5653 SK[X] = -----------------
5659 @opencatbox{Categories:}
5660 @category{Package distrib}
5666 @anchor{kurtosis_binomial}
5667 @deffn {Function} kurtosis_binomial (@var{n},@var{p})
5668 Returns the kurtosis coefficient of a
5670 random variable, with @math{0 \leq p \leq 1} and @math{n} a positive integer. To make use of this function, write first @code{load("distrib")}.
5672 The kurtosis coefficient is
5674 <<<KU[X] = {1-6p(1-p)\over np(1-p)}>>>,
5678 KU[X] = ---------------
5684 @opencatbox{Categories:}
5685 @category{Package distrib}
5691 @anchor{random_binomial}
5692 @deffn {Function} random_binomial (@var{n},@var{p}) @
5693 @fname{random_binomial} (@var{n},@var{p},@var{m})
5697 random variate, with @math{0 \leq p \leq 1} and @math{n} a positive integer. Calling @code{random_binomial} with a third argument @var{m}, a random sample of size @var{m} will be simulated.
5699 The implemented algorithm is based on the one described in Kachitvichyanukul, V. and Schmeiser, B.W. (1988) @var{Binomial Random Variate Generation}. Communications of the ACM, 31, Feb., 216.
5701 To make use of this function, write first @code{load("distrib")}.
5703 @opencatbox{Categories:}
5704 @category{Package distrib}
5705 @category{Random numbers}
5710 @node Poisson Random Variable, Bernoulli Random Variable, Binomial Random Variable, Functions and Variables for discrete distributions
5711 @subsection Poisson Random Variable
5713 The @emph{Poisson distribution} is a discrete probability
5714 distribution. It is the probability that a given number of events
5715 occur in a fixed interval when the events occur independently of the
5716 time of the last event, and the events occur with a known constant
5719 @anchor{pdf_poisson}
5720 @deffn {Function} pdf_poisson (@var{x},@var{m})
5721 Returns the value at @var{x} of the probability function of a
5723 random variable, with @math{m>0}. To make use of this function, write first @code{load("distrib")}.
5727 <<<f(x; m) = {m^x e^{-m}\over x!}>>>,
5738 @opencatbox{Categories:}
5739 @category{Package distrib}
5745 @anchor{cdf_poisson}
5746 @deffn {Function} cdf_poisson (@var{x},@var{m})
5747 Returns the value at @var{x} of the cumulative distribution function of a
5749 random variable, with @math{m>0}.
5753 <<<F(x; m) = Q(\lfloor x \rfloor + 1, m)>>>,
5756 F(x, m) = gamma_incomplete_regularized(floor(x) + 1, m)
5760 where @math{Q(x,m)} is the @ref{gamma_incomplete_regularized}
5765 @c load ("distrib")$
5766 @c cdf_poisson(3,5);
5770 (%i1) load ("distrib")$
5772 (%i2) cdf_poisson(3,5);
5773 (%o2) gamma_incomplete_regularized(4, 5)
5777 (%o3) 0.2650259152973619
5781 @opencatbox{Categories:}
5782 @category{Package distrib}
5788 @anchor{quantile_poisson}
5789 @deffn {Function} quantile_poisson (@var{q},@var{m})
5790 Returns the @var{q}-quantile of a
5792 random variable, with @math{m>0}; in other words, this is the inverse of @code{cdf_poisson}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
5794 @opencatbox{Categories:}
5795 @category{Package distrib}
5801 @anchor{mean_poisson}
5802 @deffn {Function} mean_poisson (@var{m})
5803 Returns the mean of a
5805 random variable, with @math{m>0}. To make use of this function, write first @code{load("distrib")}.
5816 @opencatbox{Categories:}
5817 @category{Package distrib}
5823 @anchor{var_poisson}
5824 @deffn {Function} var_poisson (@var{m})
5825 Returns the variance of a
5827 random variable, with @math{m>0}. To make use of this function, write first @code{load("distrib")}.
5838 @opencatbox{Categories:}
5839 @category{Package distrib}
5845 @anchor{std_poisson}
5846 @deffn {Function} std_poisson (@var{m})
5847 Returns the standard deviation of a
5849 random variable, with @math{m>0}. To make use of this function, write first @code{load("distrib")}.
5851 The standard deviation is
5853 <<<V[X] = \sqrt{m}>>>,
5860 @opencatbox{Categories:}
5861 @category{Package distrib}
5867 @anchor{skewness_poisson}
5868 @deffn {Function} skewness_poisson (@var{m})
5869 Returns the skewness coefficient of a
5871 random variable, with @math{m>0}. To make use of this function, write first @code{load("distrib")}.
5875 <<<SK[X] = {1\over \sqrt{m}}>>>,
5885 @opencatbox{Categories:}
5886 @category{Package distrib}
5892 @anchor{kurtosis_poisson}
5893 @deffn {Function} kurtosis_poisson (@var{m})
5894 Returns the kurtosis coefficient of a Poisson random variable @math{Poi(m)}, with @math{m>0}. To make use of this function, write first @code{load("distrib")}.
5896 The kurtosis coefficient is
5898 <<<KU[X] = {1\over m}>>>,
5907 @opencatbox{Categories:}
5908 @category{Package distrib}
5914 @anchor{random_poisson}
5915 @deffn {Function} random_poisson (@var{m}) @
5916 @fname{random_poisson} (@var{m},@var{n})
5920 random variate, with @math{m>0}. Calling @code{random_poisson} with a second argument @var{n}, a random sample of size @var{n} will be simulated.
5922 The implemented algorithm is the one described in Ahrens, J.H. and Dieter, U. (1982) @var{Computer Generation of Poisson Deviates From Modified Normal Distributions}. ACM Trans. Math. Software, 8, 2, June,163-179.
5924 To make use of this function, write first @code{load("distrib")}.
5926 @opencatbox{Categories:}
5927 @category{Package distrib}
5928 @category{Random numbers}
5933 @node Bernoulli Random Variable, Geometric Random Variable, Poisson Random Variable, Functions and Variables for discrete distributions
5934 @subsection Bernoulli Random Variable
5936 The @emph{Bernoulli distribution} is a discrete probability
5937 distribution which takes on two values, 0 and 1. The value 1 occurs
5938 with probability @math{p}, and 0 occurs with probabilty @math{1-p}.
5940 It is equivalent to the
5942 distribution (@pxref{Binomial Random Variable})
5944 @anchor{pdf_bernoulli}
5945 @deffn {Function} pdf_bernoulli (@var{x},@var{p})
5946 Returns the value at @var{x} of the probability function of a
5948 random variable, with @math{0 \leq p \leq 1}.
5952 random variable is equivalent to the
5958 <<<f(x; p) = p^x (1-p)^{1-x}>>>,
5968 @c load ("distrib")$
5969 @c pdf_bernoulli(1,p);
5972 (%i1) load ("distrib")$
5974 (%i2) pdf_bernoulli(1,p);
5979 @opencatbox{Categories:}
5980 @category{Package distrib}
5986 @anchor{cdf_bernoulli}
5987 @deffn {Function} cdf_bernoulli (@var{x},@var{p})
5988 Returns the value at @var{x} of the cumulative distribution function of a
5990 random variable, with @math{0 \leq p \leq 1}. To make use of this function, write first @code{load("distrib")}.
5994 <<<F(x; p) = I_{1-p}(1-\lfloor x \rfloor, \lfloor x \rfloor + 1)>>>,
5997 F(x, n, p) = beta_incomplete_regularized(n - floor(x), floor(x) + 1,
6003 @opencatbox{Categories:}
6004 @category{Package distrib}
6010 @anchor{quantile_bernoulli}
6011 @deffn {Function} quantile_bernoulli (@var{q},@var{p})
6012 Returns the @var{q}-quantile of a
6014 random variable, with @math{0 \leq p \leq 1}; in other words, this is the inverse of @code{cdf_bernoulli}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
6016 @opencatbox{Categories:}
6017 @category{Package distrib}
6023 @anchor{mean_bernoulli}
6024 @deffn {Function} mean_bernoulli (@var{p})
6025 Returns the mean of a
6027 random variable, with @math{0 \leq p \leq 1}.
6031 random variable is equivalent to the
6045 @c load ("distrib")$
6046 @c mean_bernoulli(p);
6049 (%i1) load ("distrib")$
6051 (%i2) mean_bernoulli(p);
6056 @opencatbox{Categories:}
6057 @category{Package distrib}
6063 @anchor{var_bernoulli}
6064 @deffn {Function} var_bernoulli (@var{p})
6065 Returns the variance of a
6067 random variable, with @math{0 \leq p \leq 1}.
6071 random variable is equivalent to the
6077 <<<V[X] = p(1-p)>>>,
6085 @c load ("distrib")$
6086 @c var_bernoulli(p);
6089 (%i1) load ("distrib")$
6091 (%i2) var_bernoulli(p);
6096 @opencatbox{Categories:}
6097 @category{Package distrib}
6103 @anchor{std_bernoulli}
6104 @deffn {Function} std_bernoulli (@var{p})
6105 Returns the standard deviation of a
6107 random variable, with @math{0 \leq p \leq 1}.
6111 random variable is equivalent to the
6115 The standard deviation is
6117 <<<D[X] = \sqrt{p(1-p)}>>>,
6120 D[X] = sqrt((1 - p) p)
6126 @c load ("distrib")$
6127 @c std_bernoulli(p);
6130 (%i1) load ("distrib")$
6132 (%i2) std_bernoulli(p);
6133 (%o2) sqrt((1 - p) p)
6137 @opencatbox{Categories:}
6138 @category{Package distrib}
6144 @anchor{skewness_bernoulli}
6145 @deffn {Function} skewness_bernoulli (@var{p})
6146 Returns the skewness coefficient of a
6148 random variable, with @math{0 \leq p \leq 1}.
6152 random variable is equivalent to the
6156 The skewness coefficient is
6158 <<<SK[X] = {1-2p \over \sqrt{p(1-p)}}>>>,
6162 SK[X] = ---------------
6169 @c load ("distrib")$
6170 @c skewness_bernoulli(p);
6173 (%i1) load ("distrib")$
6175 (%i2) skewness_bernoulli(p);
6177 (%o2) ---------------
6182 @opencatbox{Categories:}
6183 @category{Package distrib}
6189 @anchor{kurtosis_bernoulli}
6190 @deffn {Function} kurtosis_bernoulli (@var{p})
6191 Returns the kurtosis coefficient of a
6193 random variable, with @math{0 \leq p \leq 1}.
6197 random variable is equivalent to the
6201 The kurtosis coefficient is
6203 <<<KU[X] = {1-6p(1-p) \over p(1-p)}>>>,
6207 KU[X] = ---------------
6214 @c load ("distrib")$
6215 @c kurtosis_bernoulli(p);
6218 (%i1) load ("distrib")$
6220 (%i2) kurtosis_bernoulli(p);
6222 (%o2) ---------------
6227 @opencatbox{Categories:}
6228 @category{Package distrib}
6234 @anchor{random_bernoulli}
6235 @deffn {Function} random_bernoulli (@var{p}) @
6236 @fname{random_bernoulli} (@var{p},@var{n})
6240 random variate, with @math{0 \leq p \leq 1}. Calling @code{random_bernoulli} with a second argument @var{n}, a random sample of size @var{n} will be simulated.
6242 This is a direct application of the @code{random} built-in Maxima function.
6244 See also @mrefdot{random} To make use of this function, write first @code{load("distrib")}.
6246 @opencatbox{Categories:}
6247 @category{Package distrib}
6248 @category{Random numbers}
6253 @node Geometric Random Variable, Discrete Uniform Random Variable, Bernoulli Random Variable, Functions and Variables for discrete distributions
6254 @subsection Geometric Random Variable
6256 The @emph{Geometric distibution} is a discrete probability
6257 distribution. It is the distribution of the number
6258 Bernoulli trials that fail before the first success.
6260 Consider flipping a biased coin where heads occurs with probablity
6261 @math{p}. Then the probability of @math{k-1} tails in a row followed
6262 by heads is given by the
6266 @anchor{pdf_geometric}
6267 @deffn {Function} pdf_geometric (@var{x},@var{p})
6268 Returns the value at @var{x} of the probability function of a
6270 random variable, with
6275 <<<f(x; p) = p(1-p)^x>>>,
6284 This is interpreted as the probability of @math{x} failures before the first success.
6286 @code{load("distrib")} loads this function.
6288 @opencatbox{Categories:}
6289 @category{Package distrib}
6295 @anchor{cdf_geometric}
6296 @deffn {Function} cdf_geometric (@var{x},@var{p})
6297 Returns the value at @var{x} of the cumulative distribution function of a
6299 random variable, with
6304 <<<1-(1-p)^{1 + \lfloor x \rfloor}>>>,
6308 F(x, p) = 1 - (1 - p)
6313 @code{load("distrib")} loads this function.
6315 @opencatbox{Categories:}
6316 @category{Package distrib}
6322 @anchor{quantile_geometric}
6323 @deffn {Function} quantile_geometric (@var{q},@var{p})
6324 Returns the @var{q}-quantile of a
6328 m4_math(<<<0 \lt p \le 1>>>, <<<0 < p <= 1>>>, <<<0 < p <= 1>>>)
6330 in other words, this is the inverse of @code{cdf_geometric}.
6331 Argument @var{q} must be an element of @math{[0,1]}.
6333 The probability from which the quantile is derived is defined as @math{p (1 - p)^x}.
6334 This is interpreted as the probability of @math{x} failures before the first success.
6336 @code{load("distrib")} loads this function.
6338 @opencatbox{Categories:}
6339 @category{Package distrib}
6345 @anchor{mean_geometric}
6346 @deffn {Function} mean_geometric (@var{p})
6347 Returns the mean of a
6349 random variable, with
6350 @math{0 < p \leq 1}.
6354 <<<E[X] = {1\over p} - 1>>>,
6364 The probability from which the mean is derived is defined as @math{p (1 - p)^x}.
6365 This is interpreted as the probability of @math{x} failures before the first success.
6367 @code{load("distrib")} loads this function.
6369 @opencatbox{Categories:}
6370 @category{Package distrib}
6376 @anchor{var_geometric}
6377 @deffn {Function} var_geometric (@var{p})
6378 Returns the variance of a
6380 random variable, with
6381 @math{0 < p \leq 1}.
6385 <<<V[X] = {1-p\over p^2}>>>,
6396 @code{load("distrib")} loads this function.
6398 @opencatbox{Categories:}
6399 @category{Package distrib}
6405 @anchor{std_geometric}
6406 @deffn {Function} std_geometric (@var{p})
6407 Returns the standard deviation of a
6409 random variable, with
6410 @math{0 < p \leq 1}.
6413 <<<D[X] = {\sqrt{1-p} \over p}>>>,
6423 @code{load("distrib")} loads this function.
6425 @opencatbox{Categories:}
6426 @category{Package distrib}
6432 @anchor{skewness_geometric}
6433 @deffn {Function} skewness_geometric (@var{p})
6434 Returns the skewness coefficient of a
6436 random variable, with
6437 @math{0 < p \leq 1}.
6439 The skewness coefficient is
6441 <<<SK[X] = {2-p \over \sqrt{1-p}}>>>,
6451 @code{load("distrib")} loads this function.
6453 @opencatbox{Categories:}
6454 @category{Package distrib}
6460 @anchor{kurtosis_geometric}
6461 @deffn {Function} kurtosis_geometric (@var{p})
6462 Returns the kurtosis coefficient of a geometric random variable
6465 @math{0 < p \leq 1}.
6467 The kurtosis coefficient is
6469 <<<KU[X] = {p^2-6p+6 \over 1-p}>>>,
6474 KU[X] = ------------
6480 @code{load("distrib")} loads this function.
6482 @opencatbox{Categories:}
6483 @category{Package distrib}
6489 @anchor{random_geometric}
6490 @deffn {Function} random_geometric (@var{p}) @
6491 @fname{random_geometric} (@var{p},@var{n})
6493 @code{random_geometric(@var{p})} returns one random sample from a
6497 m4_mathdot(<<<0 \lt p \le 1>>>, <<<0 < p <= 1>>>, <<<0 < p \le 1>>>)
6499 @code{random_geometric(@var{p}, @var{n})} returns a list of @var{n} random samples.
6501 The algorithm is based on simulation of Bernoulli trials.
6503 The probability from which the random sample is derived is defined as @math{p (1 - p)^x}.
6504 This is interpreted as the probability of @math{x} failures before the first success.
6506 @code{load("distrib")} loads this function.
6509 @opencatbox{Categories:}
6510 @category{Package distrib}
6511 @category{Random numbers}
6516 @node Discrete Uniform Random Variable, Hypergeometric Random Variable, Geometric Random Variable, Functions and Variables for discrete distributions
6517 @subsection Discrete Uniform Random Variable
6519 The @emph{Discrete uniform distribution} is a discrete probablity
6520 distribution where a finite number of values are equally likely to
6521 occur. The values are @math{1,2,3,...,n}.
6523 For example throwing a fair die of 6 sides numbered 1 through 6
6525 m4_DiscreteUniform_RV(1/6)
6528 @anchor{pdf_discrete_uniform}
6529 @deffn {Function} pdf_discrete_uniform (@var{x},@var{n})
6530 Returns the value at @var{x} of the probability function of a
6531 m4_DiscreteUniform_RV(n)
6532 random variable, with @math{n} a strictly positive integer. To make use of this function, write first @code{load("distrib")}.
6536 <<<f(x,n) = {1\over n}>>>,
6546 @opencatbox{Categories:}
6547 @category{Package distrib}
6553 @anchor{cdf_discrete_uniform}
6554 @deffn {Function} cdf_discrete_uniform (@var{x},@var{n})
6555 Returns the value at @var{x} of the cumulative distribution function of a
6556 m4_DiscreteUniform_RV(n)
6557 random variable, with @math{n} a strictly positive integer. To make use of this function, write first @code{load("distrib")}.
6561 <<<F(x; n) = {\lfloor x \rfloor \over n}>>>,
6571 @opencatbox{Categories:}
6572 @category{Package distrib}
6578 @anchor{quantile_discrete_uniform}
6579 @deffn {Function} quantile_discrete_uniform (@var{q},@var{n})
6580 Returns the @var{q}-quantile of a
6581 m4_DiscreteUniform_RV(n)
6582 random variable, with @math{n} a strictly positive integer; in other words, this is the inverse of @code{cdf_discrete_uniform}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
6584 @opencatbox{Categories:}
6585 @category{Package distrib}
6591 @anchor{mean_discrete_uniform}
6592 @deffn {Function} mean_discrete_uniform (@var{n})
6593 Returns the mean of a
6594 m4_DiscreteUniform_RV(n)
6595 random variable, with @math{n} a strictly positive integer. To make use of this function, write first @code{load("distrib")}.
6599 <<<E[X] = {n+1\over 2}>>>,
6609 @opencatbox{Categories:}
6610 @category{Package distrib}
6616 @anchor{var_discrete_uniform}
6617 @deffn {Function} var_discrete_uniform (@var{n})
6618 Returns the variance of a
6619 m4_DiscreteUniform_RV(n)
6620 random variable, with @math{n} a strictly positive integer. To make use of this function, write first @code{load("distrib")}.
6624 <<<V[X] = {n^2-1 \over 12}>>>,
6635 @opencatbox{Categories:}
6636 @category{Package distrib}
6642 @anchor{std_discrete_uniform}
6643 @deffn {Function} std_discrete_uniform (@var{n})
6644 Returns the standard deviation of a
6645 m4_DiscreteUniform_RV(n)
6646 random variable, with @math{n} a strictly positive integer. To make use of this function, write first @code{load("distrib")}.
6648 The standard deviation is
6650 <<<D[X] = {\sqrt{n^2-1} \over 2\sqrt{3}}>>>,
6661 @opencatbox{Categories:}
6662 @category{Package distrib}
6668 @anchor{skewness_discrete_uniform}
6669 @deffn {Function} skewness_discrete_uniform (@var{n})
6670 Returns the skewness coefficient of a
6671 m4_DiscreteUniform_RV(n)
6672 random variable, with @math{n} a strictly positive integer. To make use of this function, write first @code{load("distrib")}.
6674 The skewness coefficient is
6683 @opencatbox{Categories:}
6684 @category{Package distrib}
6690 @anchor{kurtosis_discrete_uniform}
6691 @deffn {Function} kurtosis_discrete_uniform (@var{n})
6692 Returns the kurtosis coefficient of a
6693 m4_DiscreteUniform_RV(n)
6694 random variable, with @math{n} a strictly positive integer. To make use of this function, write first @code{load("distrib")}.
6696 The kurtosis coefficient is
6698 <<<KU[X] = - {6(n^2+1)\over 5 (n^2-1)}>>>,
6703 KU[X] = - -----------------
6709 @opencatbox{Categories:}
6710 @category{Package distrib}
6716 @anchor{random_discrete_uniform}
6717 @deffn {Function} random_discrete_uniform (@var{n}) @
6718 @fname{random_discrete_uniform} (@var{n},@var{m})
6721 m4_DiscreteUniform_RV(n)
6722 random variate, with @math{n} a strictly positive integer. Calling @code{random_discrete_uniform} with a second argument @var{m}, a random sample of size @var{m} will be simulated.
6724 This is a direct application of the @code{random} built-in Maxima function.
6726 See also @mrefdot{random} To make use of this function, write first @code{load("distrib")}.
6728 @opencatbox{Categories:}
6729 @category{Package distrib}
6730 @category{Random numbers}
6735 @node Hypergeometric Random Variable, Negative Binomial Random Variable, Discrete Uniform Random Variable, Functions and Variables for discrete distributions
6736 @subsection Hypergeometric Random Variable
6738 The @emph{hypergeometric distribution} is a discrete probability
6741 Let @math{n_1} be the number of objects of a class
6742 @math{A} and @math{n_2} be the number of objects of class @math{B}.
6743 We take out @math{n} objects, @emph{without} replacment. Then the
6744 hypergeometric distribution is the probability that exactly @math{k}
6745 objects are from class @math{A}. Of course @math{n \leq n_1 + n_2}.
6747 @anchor{pdf_hypergeometric}
6748 @deffn {Function} pdf_hypergeometric (@var{x},@var{n_1},@var{n_2},@var{n})
6749 Returns the value at @var{x} of the probability function of a
6750 m4_Hypergeometric_RV(n1,n2,n)
6751 random variable, with @math{n_1}, @math{n_2} and @math{n} non negative
6752 integers and @math{n\leq n_1+n_2}.
6753 Being @math{n_1} the number of objects of class A, @math{n_2} the number of objects of class B, and
6754 @math{n} the size of the sample without replacement, this function returns the probability of
6755 event "exactly @var{x} objects are of class A".
6757 To make use of this function, write first @code{load("distrib")}.
6761 <<<f(x; n_1, n_2, n) = {\displaystyle{n_1\choose x} {n_2 \choose n-x}
6762 \over \displaystyle{n_2+n_1 \choose n}}>>>,
6765 binomial(n_1, x) binomial(n_2, n - x)
6766 f(x, n_1, n_2, n) = -----------------------------------
6767 binomial(n_2 + n_1, n)
6772 @opencatbox{Categories:}
6773 @category{Package distrib}
6779 @anchor{cdf_hypergeometric}
6780 @deffn {Function} cdf_hypergeometric (@var{x},@var{n_1},@var{n_2},@var{n})
6781 Returns the value at @var{x} of the cumulative distribution function of a
6782 m4_Hypergeometric_RV(n1,n2,n)
6783 random variable, with @math{n_1}, @math{n_2} and @math{n} non negative
6784 integers and @math{n\leq n_1+n_2}.
6785 See @code{pdf_hypergeometric} for a more complete description.
6787 To make use of this function, write first @code{load("distrib")}.
6791 <<<F(x; n_1, n_2, n) = {n_2+n_1\choose n}^{-1}
6792 \sum_{k=0}^{\lfloor x \rfloor} {n_1 \choose k} {n_2 \choose n - k}>>>,
6798 > binomial(n_1, k) binomial(n_2, n - k)
6802 F(x, n_1, n_2, n) = --------------------------------------------
6803 binomial(n_2 + n_1, n)
6808 @opencatbox{Categories:}
6809 @category{Package distrib}
6815 @anchor{quantile_hypergeometric}
6816 @deffn {Function} quantile_hypergeometric (@var{q},@var{n1},@var{n2},@var{n})
6817 Returns the @var{q}-quantile of a
6818 m4_Hypergeometric_RV(n1,n2,n)
6820 variable, with @var{n1}, @var{n2} and @var{n} non negative integers
6821 and @math{n\leq n1+n2}; in other words, this is the inverse of @code{cdf_hypergeometric}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
6823 @opencatbox{Categories:}
6824 @category{Package distrib}
6830 @anchor{mean_hypergeometric}
6831 @deffn {Function} mean_hypergeometric (@var{n_1},@var{n_2},@var{n})
6832 Returns the mean of a discrete uniform random variable
6833 m4_Hypergeometric_RV(n_1,n_2,n)
6834 , with @math{n_1}, @math{n_2} and @math{n} non negative integers and @math{n\leq n_1+n_2}. To make use of this function, write first @code{load("distrib")}.
6838 <<<E[X] = {n n_1\over n_2+n_1}>>>,
6849 @opencatbox{Categories:}
6850 @category{Package distrib}
6856 @anchor{var_hypergeometric}
6857 @deffn {Function} var_hypergeometric (@var{n1},@var{n2},@var{n})
6858 Returns the variance of a hypergeometric random variable
6859 m4_Hypergeometric_RV(n_1,n_2,n)
6861 with @math{n_1}, @math{n_2} and @math{n} non negative integers and
6862 m4_mathdot(<<<n \le n_1 + n_2>>>, <<<n <= n_1 + n_2>>>)
6863 To make use of this function, write first @code{load("distrib")}.
6867 <<<V[X] = {n n_1 n_2 (n_1 + n_2 - n)
6869 (n_1 + n_2 - 1) (n_1 + n_2)^2}>>>,
6872 n n_1 n_2 (n_2 + n_1 - n)
6873 V[X] = ----------------------------
6875 (n_2 + n_1 - 1) (n_2 + n_1)
6880 @opencatbox{Categories:}
6881 @category{Package distrib}
6887 @anchor{std_hypergeometric}
6888 @deffn {Function} std_hypergeometric (@var{n_1},@var{n_2},@var{n})
6889 Returns the standard deviation of a
6890 m4_Hypergeometric_RV(n_1,n_2,n)
6891 random variable, with @math{n_1}, @math{n_2} and @math{n} non negative integers and @math{n\leq n_1+n_2}. To make use of this function, write first @code{load("distrib")}.
6893 The standard deviation is
6895 <<<D[X] = {1\over n_1+n_2}\sqrt{n n_1 n_2 (n_1 + n_2 - n) \over n_1+n_2-1}>>>,
6898 n n_1 n_2 (n_2 + n_1 - n)
6899 sqrt(-------------------------)
6901 D[X] = -------------------------------
6907 @opencatbox{Categories:}
6908 @category{Package distrib}
6914 @anchor{skewness_hypergeometric}
6915 @deffn {Function} skewness_hypergeometric (@var{n_1},@var{n_2},@var{n})
6916 Returns the skewness coefficient of a
6917 m4_Hypergeometric_RV(n1,n2,n)
6918 random variable, with @math{n_1}, @math{n_2} and @math{n} non negative integers and @math{n\leq n1+n2}. To make use of this function, write first @code{load("distrib")}.
6920 The skewness coefficient is
6922 <<<SK[X] = {(n_2-n_2)(n_1+n_2-2n)\over n_1+n_2-2}
6923 \sqrt{n_1+n_2-1 \over n n_1 n_2 (n_1+n_2-n)}>>>,
6927 (n_2 - n_1) (n_2 + n_1 - 2 n) sqrt(-------------------------)
6928 n n_1 n_2 (n_2 + n_1 - n)
6929 SK[X] = -------------------------------------------------------------
6936 @opencatbox{Categories:}
6937 @category{Package distrib}
6943 @anchor{kurtosis_hypergeometric}
6944 @deffn {Function} kurtosis_hypergeometric (@var{n_1},@var{n_2},@var{n})
6945 Returns the kurtosis coefficient of a
6946 m4_Hypergeometric_RV(n_1,n_2,n)
6947 random variable, with @math{n_1}, @math{n_2} and @math{n} non negative integers and @math{n\leq n1+n2}. To make use of this function, write first @code{load("distrib")}.
6949 The kurtosis coefficient is
6956 n n_1 n_2 C(3)C(2)C(n)}\right. \cr
6959 {3n_1n_2\left((n-2)C(0)^2+6nC(n)-n^2C(0)\right)
6970 KU[X] = ((n_2 + n_1 - 1) (n_2 + n_1)
6972 3 n_1 n_2 ((n - 2) (n_2 + n_1) + 6 n (n_2 + n_1 - n) - n (n_2 + n_1))
6973 (-----------------------------------------------------------------------
6976 - 6 n (n_2 + n_1 - n) + (n_2 + n_1) (n_2 + n_1 + 1)))
6977 /(n n_1 n_2 (n_2 + n_1 - 3) (n_2 + n_1 - 2) (n_2 + n_1 - n)) - 3
6982 m4_mathdot(C(k) = n_1+n_2-k)
6985 @opencatbox{Categories:}
6986 @category{Package distrib}
6992 @anchor{random_hypergeometric}
6993 @deffn {Function} random_hypergeometric (@var{n1},@var{n2},@var{n}) @
6994 @fname{random_hypergeometric} (@var{n1},@var{n2},@var{n},@var{m})
6997 m4_Hypergeometric_RV(n1,n2,n)
6999 with @var{n1}, @var{n2} and @var{n} non negative integers and
7000 m4_mathdot(<<<n \le n_1 + n_2>>>, <<<n <= n_1 + n_2>>>)
7001 Calling @code{random_hypergeometric} with a fourth argument @var{m}, a random sample of size @var{m} will be simulated.
7003 Algorithm described in Kachitvichyanukul, V., Schmeiser, B.W. (1985) @var{Computer generation of hypergeometric random variates.} Journal of Statistical Computation and Simulation 22, 127-145.
7005 To make use of this function, write first @code{load("distrib")}.
7007 @opencatbox{Categories:}
7008 @category{Package distrib}
7009 @category{Random numbers}
7014 @node Negative Binomial Random Variable, , Hypergeometric Random Variable, Functions and Variables for discrete distributions
7015 @subsection Negative Binomial Random Variable
7017 The @emph{negative binomial distribution} is a discrete probability
7018 distribution. Suppose we have a sequence of Bernoulli trials where
7019 each trial has two outcomes called ``success'' and ``failure'' where
7020 ``success'' occurs with probablity @math{p} and ``failure'' with
7021 probability @math{1-p}. We observe the sequence until a predefined
7022 number @math{r} of sucesses have occurred. Then the number of
7023 failures seen will have a
7024 m4_NegativeBinomial_RV(r, p)
7027 @anchor{pdf_negative_binomial}
7028 @deffn {Function} pdf_negative_binomial (@var{x},@var{n},@var{p})
7029 Returns the value at @var{x} of the probability function of a
7030 m4_NegativeBinomial_RV(n,p)
7031 random variable, with @math{0 < p \leq 1} and @math{n} a positive number. To make use of this function, write first @code{load("distrib")}.
7035 <<<f(x; n, p) = {x+n-1 \choose n-1} (1-p)^xp^n>>>,
7039 (1 - p) p gamma(x + n)
7040 f(x, n, p) = ------------------------
7046 @opencatbox{Categories:}
7047 @category{Package distrib}
7053 @anchor{cdf_negative_binomial}
7054 @deffn {Function} cdf_negative_binomial (@var{x},@var{n},@var{p})
7055 Returns the value at @var{x} of the cumulative distribution function of a
7056 m4_NegativeBinomial_RV(n,p)
7057 random variable, with @math{0 < p \leq 1} and @math{n} a positive number.
7061 <<<F(x; n, p) = I_p(n,\lfloor x \rfloor + 1)>>>,
7064 F(x, n, p) = beta_incomplete_regularized(n, floor(x) + 1, p)
7070 is the @ref{beta_incomplete_regularized} function.
7074 @c load ("distrib")$
7075 @c cdf_negative_binomial(3,4,1/8);
7078 (%i1) load ("distrib")$
7080 (%i2) cdf_negative_binomial(3,4,1/8);
7087 @opencatbox{Categories:}
7088 @category{Package distrib}
7094 @anchor{quantile_negative_binomial}
7095 @deffn {Function} quantile_negative_binomial (@var{q},@var{n},@var{p})
7096 Returns the @var{q}-quantile of a
7097 m4_NegativeBinomial_RV(n,p)
7098 random variable, with @math{0 < p \leq 1} and @math{n} a positive number; in other words, this is the inverse of @code{cdf_negative_binomial}. Argument @var{q} must be an element of @math{[0,1]}. To make use of this function, write first @code{load("distrib")}.
7100 @opencatbox{Categories:}
7101 @category{Package distrib}
7107 @anchor{mean_negative_binomial}
7108 @deffn {Function} mean_negative_binomial (@var{n},@var{p})
7109 Returns the mean of a
7110 m4_NegativeBinomial_RV(n,p)
7111 random variable, with @math{0 < p \leq 1} and @math{n} a positive number. To make use of this function, write first @code{load("distrib")}.
7115 <<<E[X] = {n(1-p)\over p}>>>,
7124 @opencatbox{Categories:}
7125 @category{Package distrib}
7131 @anchor{var_negative_binomial}
7132 @deffn {Function} var_negative_binomial (@var{n},@var{p})
7133 Returns the variance of a
7134 m4_NegativeBinomial_RV(n,p)
7135 random variable, with @math{0 < p \leq 1} and @math{n} a positive number. To make use of this function, write first @code{load("distrib")}.
7139 <<<V[X] = {n(1-p)\over p^2}>>>,
7149 @opencatbox{Categories:}
7150 @category{Package distrib}
7156 @anchor{std_negative_binomial}
7157 @deffn {Function} std_negative_binomial (@var{n},@var{p})
7158 Returns the standard deviation of a
7159 m4_NegativeBinomial_RV(n,p)
7160 random variable, with @math{0 < p \leq 1} and @math{n} a positive number. To make use of this function, write first @code{load("distrib")}.
7162 The standard deviation is
7164 <<<D[X] = {\sqrt{n(1-p)}\over p}>>>,
7168 D[X] = ---------------
7173 @opencatbox{Categories:}
7174 @category{Package distrib}
7180 @anchor{skewness_negative_binomial}
7181 @deffn {Function} skewness_negative_binomial (@var{n},@var{p})
7182 Returns the skewness coefficient of a
7183 m4_NegativeBinomial_RV(n,p)
7184 random variable, with @math{0 < p \leq 1} and @math{n} a positive number. To make use of this function, write first @code{load("distrib")}.
7186 The skewness coefficient is
7188 <<<SK[X] = {2-p \over \sqrt{n(1-p)}}>>>,
7192 SK[X] = ---------------
7197 @opencatbox{Categories:}
7198 @category{Package distrib}
7204 @anchor{kurtosis_negative_binomial}
7205 @deffn {Function} kurtosis_negative_binomial (@var{n},@var{p})
7206 Returns the kurtosis coefficient of a
7207 m4_NegativeBinomial_RV(n,p)
7208 random variable, with @math{0 < p \leq 1} and @math{n} a positive number. To make use of this function, write first @code{load("distrib")}.
7210 The kurtosis coefficient is
7212 <<<KU[X] = {p^2-6p+6 \over n(1-p)}>>>,
7217 KU[X] = ------------
7223 @opencatbox{Categories:}
7224 @category{Package distrib}
7230 @anchor{random_negative_binomial}
7231 @deffn {Function} random_negative_binomial (@var{n},@var{p}) @
7232 @fname{random_negative_binomial} (@var{n},@var{p},@var{m})
7235 m4_NegativeBinomial_RV(n,p)
7236 random variate, with @math{0 < p \leq 1} and @math{n} a positive number. Calling @code{random_negative_binomial} with a third argument @var{m}, a random sample of size @var{m} will be simulated.
7238 Algorithm described in Devroye, L. (1986) @var{Non-Uniform Random Variate Generation}. Springer Verlag, p. 480.
7240 To make use of this function, write first @code{load("distrib")}.
7242 @opencatbox{Categories:}
7243 @category{Package distrib}
7244 @category{Random numbers}
7248 @c Undefine all the m4 macros we defined in this file.
7249 m4_undefine(<<<m4_Normal_RV>>>)