Download or view plotBinomial.frink in plain text format
/** Plot the binomial function's density function and cumulative
distribution function.
*/
use statistics.frink
println[binomialProbability[55,100,1/2]-binomialProbability[45,100,1/2]]
/** n is number of trials, p is probability of success on a single trial. */
plotBinomial[g is graphics, n, p] :=
{
for k=0 to n
{
d = binomialDensity[k,n,p]
pp = binomialProbability[k,n,p]
g.fillRectSides[k/n,-d,(k+1)/n,0]
g.line[k/n,-pp,(k+1)/n,-pp]
}
}
g = new graphics
plotBinomial[g, 800, 1/2]
g.show[]
Download or view plotBinomial.frink in plain text format
This is a program written in the programming language Frink.
For more information, view the Frink
Documentation or see More Sample Frink Programs.
Alan Eliasen, eliasen@mindspring.com