Binomial                package:base                R Documentation

_T_h_e _B_i_n_o_m_i_a_l _D_i_s_t_r_i_b_u_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     Density, distribution function, quantile function and random
     generation for the binomial distribution with parameters `size'
     and `prob'.

_U_s_a_g_e:

     dbinom(x, size, prob, log = FALSE)
     pbinom(q, size, prob, lower.tail = TRUE, log.p = FALSE)
     qbinom(p, size, prob, lower.tail = TRUE, log.p = FALSE)
     rbinom(n, size, prob)

_A_r_g_u_m_e_n_t_s:

    x, q: vector of quantiles.

       p: vector of probabilities.

       n: number of observations to generate.

    size: number of trials.

    prob: probability of success on each trial.

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].

_D_e_t_a_i_l_s:

     The binomial distribution with `size' = n and `prob' = p has
     density

                  p(x) = Choose(n,x) p^x (1-p)^(n-x)

     for x = 0, ..., n.

     If an element of `x' is not integer, the result of `dbinom' is
     zero, with a warning.

     The quantile is defined as the smallest value x such that F(x) >=
     p, where F is the distribution function.

_V_a_l_u_e:

     `dbinom' gives the density, `pbinom' gives the distribution
     function, `qbinom' gives the quantile function and `rbinom'
     generates random deviates.

_S_e_e _A_l_s_o:

     `dnbinom' for the negative binomial, and `dpois' for the Poisson
     distribution.

_E_x_a_m_p_l_e_s:

     # Compute P(45 < X < 55) for X Binomial(100,0.5)
     sum(dbinom(46:54, 100, 0.5))

     ## Using "log = TRUE" for an extended range :
     n <- 2000
     plot (0:n,     dbinom(0:n, n, pi/10, log=TRUE), type='l',
           main = "dbinom(*, log=TRUE) is better than  log(dbinom(*))")
     lines(0:n, log(dbinom(0:n, n, pi/10)), col='red', lwd=2)
     mtext("dbinom(k, log=TRUE)", adj=0)
     mtext("extended range", adj=0, line = -1, font=4)
     mtext("log(dbinom(k))", col="red", adj=1)

