The Binomial distribution is a discrete probability distribution closely related to the Bernoulli Distribution. It models the number of successes in a series of independent Bernoulli trials. Furthermore, if , i.e. we have a single trial, which means that the Binomial and Bernoulli are the same. Next, letting be the number of successes in the independent Bernoulli trials, the Probability Mass Function distribution is
If a stochastic variable follows a Binomial distribution with parameters and , we write . Breaking the above formula down, is the probability that successes occur. is the probability that failures occur. Finally, expresses the number of ways you can choose distinct elements from a larger set of elements. As a result, multiplying these gives the probability of observing exactly successes in Bernoulli trials with success probability . The key to understanding the Binomial PMF is to understand the Binomial coefficient. Therefore, you should take the time to understand it. For a great explanation of the coefficient, go to Understanding the Binomial Coefficient at Khan Academy.
Binomial Distribution SAS Code Example
Let us plot the Probability Mass Function. First of all, I create the PMF data, specifying the probability of success in the individual Bernoulli trials and the number of trials to be performed. Then I use the PDF function to calculate the PMF values. Finally, I use a needle plot to create the graph to the right if the Probability Mass Function.
/* Generate PMF Data */ %let p=0.5; %let n=20; data Bino_PMF; do k=0 to &n; PMF=pdf('Binomial', k, &p, &n); output; end; run; /* Plot PMF */ title "Binomial PMF with p=&p and n=&n"; proc sgplot data=Bino_PMF noautolegend; needle x=k y=PMF / lineattrs=(color=red); xaxis values=(0 to 20) label='k' labelattrs=(size=12 weight=Bold); yaxis display=(nolabel); keylegend / position=NE location=inside across=1 noborder valueattrs=(Size=12 Weight=Bold); run; title;
Finally, this distribution is one of first distributions you will meet in your statistics class. Therefore, I encourage you to play around with the and parameters in the above SAS code example to familiarize yourself with how the distribution changes with the parameters.
In addition, You can download the entire program supporting this example here.