Graphics Programs Reference
In-Depth Information
It seems that turning a profit after 10,000 games is highly likely, although
withonly 100 trials we do not get sucha good idea of the worst-case
scenario. Though it will take a good bit of time, we should certainly do
1000 trials or more if we are considering putting our money into sucha
venture.
hist(profits(10000, 1000), -200:25:600); axis tight
??? Error using ==> inlineeval
Error in inline expression ==> sum(sign(0.51 - rand(n, k)))
??? Error using ==> -
Out of memory. Type HELP MEMORY for your options.
Error in ==>
C: \ MATLABR12 \ toolbox \ matlab \ funfun \ @inline \ subsref.m
On line 25 ==> INLINE OUT = inlineeval(INLINE INPUTS ,
INLINE OBJ .inputExpr, INLINE OBJ .expr);
This error message illustrates a potential hazard in using MATLAB's vector
and matrix operations in place of a loop: In this case the matrix rand(n,k)
generated within the profits function must fit in the memory of the
computer. Since n is 10,000 and k is 1000 in our most recent attempt to run
this function, we requested a matrix of 10,000,000 random numbers. Each
floating point number in MATLAB takes up 8 bytes of memory, so the matrix
would have required 80MB to store, which is too much for some computers.
Since k represents a number of trials that can be done independently, a
solution to the memory problem is to break the 1000 trials into 10 groups
of 100, using a loop to run 100 trials 10 times and assemble the
results.
profitvec = [];
for i = 1:10
profitvec = [profitvec profits(10000, 100)];
end
hist(profitvec, -200:25:600); axis tight
Search WWH ::




Custom Search