Graphics Programs Reference
In-Depth Information
We see that the net profit can fluctuate significantly from one set of 100
games to the next, and there is a sizable probability that the house has lost
money after 100 games. To get an idea of how the net profit is likely to be
distributed in general, we can repeat the experiment a large number of times
and make a histogram of the results. The following function computes the
net profits for k different trials of n games each:
profits = inline('sum(sign(0.51 - rand(n, k)))', 'n', 'k')
profits =
Inline function:
profits(n,k) = sum(sign(0.51 - rand(n, k)))
What this function does is to generate an n × k matrix of random
numbers and then perform the same operations as above on each entry of
the matrix to obtain a matrix with entries 1 for bets the house won and 1
for bets it lost. Finally it sums the columns of the matrix to obtain a row
vector of k elements, eachof whichrepresents the total profit from a
column of n bets.
Now we make a histogram of the output of profits using n = 100 and
k = 100. Theoretically the house could win or lose up to 100 units, but in
practice we find that the outcomes are almost always within 30 or so of 0.
Thus we let the bins of the histogram range from 40 to 40 in increments of
2 (since the net profit is always even after 100 bets).
hist(profits(100, 100), -40:2:40); axis tight
12
10
8
6
4
2
0
40
30
20
10
0
10
20
30
40
Search WWH ::




Custom Search