# Binomial sequence and graph display

1. Jul 13, 2010

### physics.alex

1. The problem statement, all variables and given/known data
Given a series of 0 and 1 , how can we plot the binomial curve ??
Example: 00000011100010010100011110

say,p=0.8 q=0.2, N=26

2. Relevant equations

If I apply the classic binomial formula, 26C0 (0.8)^0(0.2)^(26-0) etc.. seems cannot do so.

2. Jul 13, 2010

### vela

Staff Emeritus
It's not really clear what you're trying to do. Could you provide more details?

3. Jul 13, 2010

### physics.alex

sorry my question is unclear
objective: plot a binomial distribution curve by giving a sequence of '0' and '1'

Example: 00000011100010010100011110

say,p=0.8 q=0.2, N=26

4. Jul 13, 2010

### vela

Staff Emeritus
What are the 0s and 1s supposed to represent? The result of 26 trials with p=0.8? You can't get a binomial distribution curve from just that.

5. Jul 13, 2010

### physics.alex

like coins flipping
0=H
1=T
p(H)=0.8
p(T)=0.2

6. Jul 13, 2010

### vela

Staff Emeritus
Can you provide the complete text of the problem? You seem to be leaving out info that might make your question make sense.

Right now, you're asking something like: given that you rolled a pair of dice and they came up 2 and 4, how can we plot the probability distribution of all the possible outcomes?

7. Jul 13, 2010

### physics.alex

Given a biasd coin and flip 26 times.
Example: HHHTTTHHHTTTTHHT p(H)=0.8
How to interpret the sequence using Binomial distribution? and How is the graph looks like?

8. Jul 13, 2010

### vela

Staff Emeritus
What's the probability of getting n heads and m tails in (n+m) trials?

9. Jul 13, 2010

### physics.alex

sorry the question is already posted.
We can make our assumption as long as it is a biased coin.

Example: total 26 trials (n+m) and prob. of getting head is 0.8
does it make sense??
The main objective is to show that in biased case, the plotted curve is easily be distinguished by just observing the graph

10. Jul 13, 2010

### vela

Staff Emeritus
So are you just asking how to plot the binomial distribution when it's hard to calculate because the numbers are big or small? You don't have an actual sequence of 1s and 0s, right?

11. Jul 13, 2010

### physics.alex

hm..yes we dont have the actual sequence according to the question.

what is wrong with the question?? The main objective is to plot the graph and see these 2 results (i.e.H or T) has a easy distinguished pattern. If it is the unbiased coin, i.e. p(h)=0.5, the pattern is not easy to distinguish.

12. Jul 13, 2010

### vela

Staff Emeritus
There's nothing wrong with the question; it's the way you asked it. It sounded like you were provided with a random sequence of 26 1s and 0s and wanted to somehow extract the binomial distribution from it.

Usually, when the numbers get too unwieldy to calculate the binomial distribution directly, you can approximate it by a normal distribution with the same mean and variance.

13. Jul 13, 2010

### vela

Staff Emeritus
Or do you want to generate a bunch of data and try to empirically produce the binomial distribution? If that's the case, just generate a bunch of sets of N ones and zeros randomly, and for each set, count the number of times one appears. Make a histogram of the results, and it should approach a binomial distribution.

14. Jul 13, 2010

### physics.alex

Ok if I take your approach, randomly generate 1 and 0, and would like to plot the histogram, what is the x-axis? y-axis should be the probability,right?
I use Matlab and run the following

clear;
x1=1:102;
y1 = binopdf(x1,102,0.2);

x2=1:102;
y2 = binopdf(x2,102,0.8);

plot(x1,y1,'+',x2,y2,'ro');

xlabel('symbols');
ylabel('probability');
title('Biased prob. of symbol H and symbol T');
legend('symbol H','symbol T');

I got the graph with two distribution with same height (i.e. same probability) and sounds doesn't make sense to me. (see attachment)

#### Attached Files:

• ###### HT.jpg
File size:
12 KB
Views:
78
15. Jul 13, 2010

### vela

Staff Emeritus
Your code doesn't generate any random numbers. The function binopdf is the binomial probability density function.

You calculated the probability of x heads and, separately, the probability of y tails both out of n trials. Do you see why the probability of x heads is equal to the probability of n-y tails? If you understand that, it should make sense why you got the two curves you did.

16. Jul 13, 2010

### physics.alex

Because the only difference of these 2 curves is the p which can controls the curve position.
So you mean we cannot do so,right? How can I obtain 2 curves that easily to distinguish the H and T clusters??

17. Jul 13, 2010

### vela

Staff Emeritus
It seems I still have no idea what you're trying to do.

18. Jul 13, 2010

### physics.alex

ok .. if use histogram, we will have only 2 bars, one is shorter than another,right?

19. Jul 13, 2010

### vela

Staff Emeritus
No. What exactly are you trying to do?

20. Jul 13, 2010

### physics.alex

"Or do you want to generate a bunch of data and try to empirically produce the binomial distribution? If that's the case, just generate a bunch of sets of N ones and zeros randomly, and for each set, count the number of times one appears. Make a histogram of the results, and it should approach a binomial distribution. "

I am trying to plot the graph that you suggested