Graphics Programs Reference
In-Depth Information
First we construct an expression that computes the net revenue to the
house for a single game, based on a random number chosen between 0 and 1
by the MATLAB function rand . If the random number is less than or equal
to 0.51, the house wins one betting unit, whereas if the number exceeds 0.51,
the house loses one unit. (In a high-stakes game, each bet may be worth
$1000 or more. Thus it is important for the casino to know how bad a losing
streak it may have to weather to turn a profit — so that it doesn't go
bankrupt first!) Here is an expression that returns 1 if the output of rand is
less than 0.51 and 1 if the output of rand is greater than 0.51 (it will also
return 0 if the output of rand is exactly 0.51, but this is extremely unlikely):
revenue = sign(0.51 - rand)
revenue =
-1
In the game simulated above, the house lost. To simulate several games at
once, say 10 games, we can generate a vector of 10 random numbers withthe
command rand(1,10) and then apply the same operation.
revenues = sign(0.51 - rand(1, 10))
revenues =
1111111111
In this case the house won 5 times and lost 5 times, for a net profit of 0 units.
For a larger number of games, say 100, we can let MATLAB sum the revenue
from the individual bets as follows:
profit = sum(sign(0.51 - rand (1, 100)))
profit =
-4
For this trial, the house had a net loss of 4 units after 100 games. On
average, every 100 games the house should win 51 times and the player(s)
should win 49 times, so the house should make a profit of 2 units (on
average). Let's see what happens in a few trial runs.
profits = sum(sign(0.51 - rand(100, 10)))
profits =
4262400202
Search WWH ::




Custom Search