Calculate cumulative binomial probability in R -
i calculate cumulative probability of binomial series:
a=choose(5,0)*0.5^0*0.5^5 b=choose(5,1)*0.5^1*0.5^4 c=choose(5,2)*0.5^2*0.5^3 d=choose(5,3)*0.5^3*0.5^2 e=choose(5,4)*0.5^4*0.5^1 f=choose(5,5)*0.5^5*0.5^0 cumulative=sum(a,b,c,d,e,f) is there way single command?
for cumulative probability use pbinom:
pbinom(0:5,5,0.5) [1] 0.03125 0.18750 0.50000 0.81250 0.96875 1.00000 for individual values, dbinom:
dbinom(0:5,5,0.5) [1] 0.03125 0.15625 0.31250 0.31250 0.15625 0.03125 and summing cumulatively use cumsum:
cumsum(dbinom(0:5,5,0.5)) [1] 0.03125 0.18750 0.50000 0.81250 0.96875 1.00000
Comments
Post a Comment