# MatLab distribution for bets on flips of a fair coin

#### tquiva

Joined Oct 19, 2010
176
Could someone please help me finish my MatLab script for the following specifications of this scenario:

Specs:
- 2 players flip a fair coin
- Bet sizes are equal

I'm trying to plot the distribution of the length of winning streaks for the game with numeric MatLab. Below is what I have so far:

% Arbitrary Scenario:
% Total of 10 coin tosses
% Player 1 (P1) bets on heads for each toss; Player 2 (P2) bets on tails
% for each toss

n = 10; % Coin is tossed 10 times
t=rand(1,n)<0.5; % Random generation of a vector of 10 0's or 1's
x=sum(t); % Count the number of heads (Amt of P1 wins)
y=n-x; % Count the number of tails (Amt of P2 wins)

Now all I want to do is plot the distribution for x and y.
Did I approach my problem correctly or did I miss anything? How would you guys go about plotting this distribution of length of winning streaks?

Many thx in advance!
- T

#### WBahn

Joined Mar 31, 2012
29,885
Where in your work have you done anything having anything to do with winning streaks?