Answer each of the following questions:
a) What does it mean to choose numbers “at random?”
b) Why is the rand function useful for simulating games of chance?
c) Why would you randomize a program by using srand? Under what circumstances is it desirable not to randomize?
d) Why is it often necessary to scale or shift the values produced by rand?
e) Why is computerized simulation of real-world situations a useful technique?
a) Every number has an equal chance of being chosen at any time.
b) Why is the rand function useful for simulating games of chance?
c) The sequence of numbers produced by the random number generator differ each
time function srand is called. Not randomizing is useful for debugging purposes—
the programmer knows the sequence of numbers.
d) To produce random values in a specific range.
e) It enables more accurate predictions of random events such as cars arriving at a toll booth, people arriving in lines, birds arriving at a tree, etc. The results of a simulation can help determine how many toll booths to have open or how many cashiers to have open at specified times.
You might also like to view...
The ________ function indicates the profitability of an investment and is commonly used in business when choosing between investments
A) NPV B) XNPV C) IRR D) XIRR
Which of the following is a possible output from invoking Math.random()?
a. 3.43 b. 0.5 c. 0.0 d. 1.0