Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Plot distribution for winning bets of flips for a fair coin
Replies: 1   Last Post: Sep 16, 2013 4:07 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
eeuser

Posts: 1
Registered: 9/16/13
Plot distribution for winning bets of flips for a fair coin
Posted: Sep 16, 2013 4:25 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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;
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



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.