binomcdf

The binomcdf function calculates the binomial cumulative distribution (CDF).

Synopsis

binomcdf(x,n,p)

Summary

The binomial distribution represents a trial where there are exactly two mutually exclusive outcomes. These outcomes are labeled success and failure. The binomial CDF gives the probability of obtaining x or fewer successes from n trials with probability of success p. The binomial CDF is:

where I is the indicator function:

Example

Find the Likelihood of Heads-up Coin Tosses

This example finds the likelihood of having a given number of coin tosses turn up heads after 40 coin tosses. The coin is considered fair, that is, the probability of heads in any given toss is 0.5.

  1. Create a 5-by-4 array called heads_array with a double attribute called heads:

    AFL% CREATE ARRAY heads_array<heads:double>[i=0:4; j=0:3];
  2. Put numerical values of 1-20 into the cells of the array:

    AFL% store(build(heads_array, (i*4+j)/1.0 + 1.0), heads_array);
  3. Apply the function binomcdf to the values in the attribute heads and store the result in target_array:

    AFL% store(apply(heads_array, probability, binomcdf(heads, 20.0, 0.5)), target_array);


    The output shows the number of heads along with the cumulative probability of achieving that number of heads:

    {i,j} heads,probability
    {0,0} 1,2.00272e-05
    {0,1} 2,0.000201225
    {0,2} 3,0.00128841
    {0,3} 4,0.00590897
    {1,0} 5,0.0206947
    {1,1} 6,0.0576591
    {1,2} 7,0.131588
    {1,3} 8,0.251722
    {2,0} 9,0.411901
    {2,1} 10,0.588099
    {2,2} 11,0.748278
    {2,3} 12,0.868412
    {3,0} 13,0.942341
    {3,1} 14,0.979305
    {3,2} 15,0.994091
    {3,3} 16,0.998712
    {4,0} 17,0.999799
    {4,1} 18,0.99998
    {4,2} 19,0.999999
    {4,3} 20,1

    Thus the chances of getting nine or fewer heads-up results is approximately 41.19%, and of getting 10 or fewer heads-up is about 58.81%. Subtract to compute that the chance of tossing exactly 10 heads is about 17.62%.

  4. Remove the example arrays:

    AFL% remove(heads_array); remove(target_array);


Inverse

ibinomcdf: Inverse binomial CDF.