Keywords: Binomial distribution cdf.svg Binomial distribution cumulative distribution function Own 2008-03-02 Tayste R source code <source lang rsplus > R source code for Wikipedia SVG plot of Binomial CDF by de User Sigbert Feb 2010 require RSvgDevice create binomial cdf <- function N p colour black pch 16 n <- max length N length p length colour length pch N <- rep N length n ; p <- rep p length n colour <- rep colour length n ; pch <- rep pch length n add one series <- function N p colour pch maxN cdf <- pbinom 0 N N p lines 0 N cdf type s col colour for i in 1 N lines c i-1 i c cdfi cdfi type s col colour lines c N maxN c 1 1 type s col colour points 0 N cdf col colour pch pch par lwd 1 5 cex 1 mar c 3 1 2 5 0 5 0 5 plot 1 xlim c 0 max N ylim c 0 1 type n xlab ylab for i in 1 n add one series Ni pi colouri pchi max N text paste p rev p and N rev N sep legend max N 0 legend text xjust 1 yjust 0 pch rev pch lwd rep par lwd 3 col rev colour y intersp 1 5 bty n devSVG Binomial_distribution_cdf svg width 4 height 3 create binomial cdf c 40 20 20 c 0 5 0 7 0 5 c red green blue c 20 15 18 dev off </source> Binomial distributions Images with R source code |