The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Matlab betting on a biased coin
Replies: 2   Last Post: Feb 11, 2013 10:34 AM

Advanced Search

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

Posts: 5
Registered: 12/10/12
Matlab betting on a biased coin
Posted: Feb 11, 2013 7:25 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I'm trying to run a simluation on a biased coin toss. At each toss i want to 'bet' a specific fraction of my current wealth on the coin toss, then run this for 100+ tosses and plot my wealth over these tosses. This is what i have so far but something in my for loop is not right. Can anyone help with this?

>>Ntoss = 100;
for i=2:Ntoss
s = -bet(i)* ones(1, Ntoss);
u = rand(1, Ntoss);
h = find(u < 0.6); % finds where it was heads.
winnings = cumsum(s);
plot(1:Ntoss, Wealth)

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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.