[R] binom calculation with range

Richard M. Heiberger rmh at temple.edu
Thu Oct 12 18:24:00 CEST 2006


> dbinom(1:5,size=1000,prob=0.0005)
[1] 0.3033791010 0.0758068339 0.0126155111 0.0015729946 0.0001567486
> sum(dbinom(1:5,size=1000,prob=0.0005))
[1] 0.3935312
> diff(pbinom(q=c(0,5),size=1000,prob=0.0005))
[1] 0.3935312
> diff(pbinom(q=c(5,0),size=1000,prob=0.0005, lower=FALSE))
[1] 0.3935312


All the distribution functions have variants:
p probability
d density
q quantile
r random numbers

See the help files, for example ?pbinom



More information about the R-help mailing list