Brighton Webs Ltd.
Data & Analysis services for Industry & Education

Home
Index
Feedback

Binomial Distribution

The binomial distribution describes the outcome of a series of trials, the outcome of which can only be a success or failure.  The classic example is the number of  "heads" that will occur in a given number of coin tosses.  One of its applications is as part of QA/QC procedures to accept or reject batches of components.

As the average for the distribution increases, the profile of the binomial approaches that of the normal distribution and under some conditions it is possible to use the normal distribution as an approximation.

Profile

Binomial Distributon - Variation in probability function with changing values of N and P

Parameters

Parameter Description Characteristics
n Number of trials An integer > 0
p The probability of a successful trial A float greater than 0 and less than 1

Range

Integer values between 0 and n.

Functions

Binomial Distribution - Probability and Cumulative Probability Functions

Depending on the system being used, the calculation of the factorial of large numbers may be difficult.  An alternative is to use the gamma function:

Gamma function as a means of calculating Factorial

In which case the formula for the probability function P(x) becomes:

Properties

Binomial Distribution - formula for properties

If p * (n+1) is an integer, the distribution is bimodal with modes at p * (n+1)-1 and p * (n+1).

Normal Approximation

The Binomial distribution can be approximated by a normal distribution with the same mean and standard deviation.  The rules used to determine if the approximation is appropriate are:

P 0.1 ≤ P ≤ 0.9
N and P N*P > 5 and N*(1-P) > 5
Mean and Standard Deviation mean-3*stdev >0

The latter condition prevents the return of negative numbers.

The probability function for the approximation can be obtained from the cumulative probability functions of the normal distribution:

Spreadsheets

Both MS Excel and the Google Docs Spreadsheet have the BinomDist function which can return either the probability or cumulative probability functions.

BinomDist(x,N,P,cum)

x is the number of successes to which the return value relates.  If the cum flag is false (i.e. zero), the return value will be the probability of x successes, whilst if it is set to true (i.e. a non zero value), the return value will be the probability of there being less than or equal to x success.

N is the number of trials

P is the probability of success, the range of values being 0<=x<=1

cum is a boolean value which determines if the return value is the probability or cumulative probability function.  If it is false, the probability function is returned, if it is true, the cumulative probability function is returned.

Example

The binomial distribution is often used to model processes which can described as a series of independent Bernouli trials.  The example is based on a simple model of an R&D budget.  A company undertakes 10 projects.  Historically only 15%  of projects succeed.  Of those that do, the NPV is between zero and $15m which is described by a triangular distribution.  A Monte-carlo process is used, first to estimate the number of successful projects in a programme, then to estimate the total NPV of those projects.  The two inputs and the output are shown in the graph below:

Binomial Distribution - Example showing use in modelling

This model can be adapted to a range of sectors a diverse as book and music publishing to oil and gas exploration.

Random Number Generation

Follow the link to the section on random number generation which describes a general method for deriving random numbers from discrete distributions.

Psuedo Code

VB style Psuedo Code for Probability and Cumulative Probability functions is shown below.

Probability Function

Private Function Bin_P(ByVal N As Long, _
                                  ByVal X As Long, _
                                  ByVal P As Double) As Double

'Description

'Returns the probability of X success from a Binomial
'Distibution of N Trials and P Probability of success.

'Requires a function to calculate factorials.

'No validation is performed on the inputs

'Declarations

Dim R As Double        'Return value

'Calculation

R = Factorial(N) / Factorial(X) / Factorial(N - X)

R = R * P ^ X
R = R * (1 - P) ^ (N - X)

'Return

Bin_P = R

End Function
 

Cumulative Probability Function

Private Function Bin_F(ByVal N As Long, _
                                  ByVal X As Long, _
                                  ByVal P As Double) As Double

'Description

'Returns the probability of a value being less than
'or equal to X from a Binomial Distibution of N Trials
'and P Probability of success. The methodology
'cumulates values from the Bin_P function.

'Declarations

Dim I As Long         'Loop Counter
Dim R As Double    'Return value

'Calculation

  For I = 0 To X
    R = R + Bin_P(N, I, P)
  Next I

'Return

Bin_F = R

End Function

Page updated: 12-Aug-2006

 

For more information: info@brighton-webs.co.uk