Beta                  package:stats                  R Documentation

The Beta Distribution

Description:

     Density, distribution function, quantile function and random
     generation for the Beta distribution with parameters 'shape1' and
     'shape2' (and optional non-centrality parameter 'ncp').

Usage:

     dbeta(x, shape1, shape2, ncp = 0, log = FALSE)
     pbeta(q, shape1, shape2, ncp = 0, lower.tail = TRUE, log.p = FALSE)
     qbeta(p, shape1, shape2, ncp = 0, lower.tail = TRUE, log.p = FALSE)
     rbeta(n, shape1, shape2, ncp = 0)

Arguments:

    x, q: vector of quantiles.

       p: vector of probabilities.

       n: number of observations. If 'length(n) > 1', the length is
          taken to be the number required.

shape1, shape2: positive parameters of the Beta distribution.

     ncp: non-centrality parameter.

log, log.p: logical; if TRUE, probabilities p are given as log(p).

lower.tail: logical; if TRUE (default), probabilities are P[X <= x],
          otherwise, P[X > x].

Details:

     The Beta distribution with parameters 'shape1' = a and 'shape2' =
     b has density

           Gamma(a+b)/(Gamma(a)Gamma(b))x^(a-1)(1-x)^(b-1)

     for a > 0, b > 0 and 0 <= x <= 1 where the boundary values at x=0
     or x=1 are defined as by continuity (as limits). 
      The mean is a/(a+b) and the variance is ab/((a+b)^2 (a+b+1)).

     'pbeta' is closely related to the incomplete beta function.  As
     defined by Abramowitz and Stegun 6.6.1

           B_x(a,b) = integral_0^x t^(a-1) (1-t)^(b-1) dt,

     and 6.6.2 I_x(a,b) = B_x(a,b) / B(a,b) where B(a,b) = B_1(a,b) is
     the Beta function ('beta').

     I_x(a,b) is 'pbeta(x,a,b)'.

     The noncentral Beta distribution (with 'ncp'  = lambda) is defined
     (Johnson et al, 1995, pp. 502) as the distribution of X/(X+Y)
     where X ~ chi^2_2a(lambda) and Y ~ chi^2_2b.

Value:

     'dbeta' gives the density, 'pbeta' the distribution function,
     'qbeta' the quantile function, and 'rbeta' generates random
     deviates.

     Invalid arguments will result in return value 'NaN', with a
     warning.

Source:

     The central 'dbeta' is based on a binomial probability, using code
     contributed by Catherine Loader (see 'dbinom') if either shape
     parameter is larger than one, otherwise directly from the
     definition. The non-central case is based on the derivation as a
     Poisson mixture of betas (Johnson _et al_, 1995, pp. 502-3).

     The central 'pbeta' uses a C translation (and enhancement for
     'log_p=TRUE') of

     Didonato, A. and Morris, A., Jr, (1992) Algorithm 708: Significant
     digit computation of the incomplete beta function ratios, _ACM
     Transactions on Mathematical Software_, *18*, 360-373. (See also
       Brown, B. and Lawrence Levy, L. (1994) Certification of
     algorithm 708: Significant digit computation of the incomplete
     beta, _ACM Transactions on Mathematical Software_, *20*, 393-397.)

     The non-central 'pbeta' uses a C translation of

     Lenth, R. V. (1987) Algorithm AS226: Computing noncentral beta
     probabilities. _Appl. Statist_, *36*, 241-244, incorporating
      Frick, H. (1990)'s AS R84, _Appl. Statist_, *39*, 311-2, and
      Lam, M.L. (1995)'s AS R95, _Appl. Statist_, *44*, 551-2.

     'qbeta' is based on a C translation of

     Cran, G. W., K. J. Martin and G. E. Thomas (1977). Remark AS R19
     and Algorithm AS 109, _Applied Statistics_,  *26*, 111-114, and
     subsequent remarks (AS83 and correction).

     'rbeta' is based on a C translation of

     R. C. H. Cheng (1978). Generating beta variates with nonintegral
     shape parameters. _Communications of the ACM_, *21*, 317-322.

References:

     Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
     Language_. Wadsworth & Brooks/Cole.

     Abramowitz, M. and Stegun, I. A. (1972) _Handbook of Mathematical
     Functions._ New York: Dover. Chapter 6: Gamma and Related
     Functions.

     Johnson, N. L., Kotz, S. and Balakrishnan, N. (1995) _Continuous
     Univariate Distributions_, volume 2, especially chapter 25. Wiley,
     New York.

See Also:

     'beta' for the Beta function, and 'dgamma' for the Gamma
     distribution.

Examples:

     x <- seq(0, 1, length=21)
     dbeta(x, 1, 1)
     pbeta(x, 1, 1)

