Most modern calculators have random number generators (RNGs) built in, and they are useful things. Of course, most calculator (and computer) RNGs aren't truly random, though there are hardware RNGs (usually with a Geiger counter or other external input).
Even software pseudo-RNGs can be useful. And not just for games. Much of probability theory is built upon the study of random events.
Consider a large flat surface ruled with parallel lines d apart. Onto this drop a needle of length L<d. When the needle comes to rest (assuming the needle is blunt so it neither sticks nor stands on end), it either intersects a line or it doesn't. What's the probability that it intersects a line (or touches one)?
Some of you may be familiar with this problem and know the solution. But try the micro-challenge below anyway. (I call it a micro-challenge because I don't specify the HP calculator to be used, the only limit on program size is the calculator's memory, the only limit on running time is your patience (and perhaps the calculator's battery life)), and as for accuracy, well, read on.
Take your favorite HP calculator and program it to simulate the experiment. Because the outcome of a single random experiment is not of much use other than deciding which side gets the ball first, make the program do it ten times and report the number of intersections. Run it more than once. Do you get the same result every time? If not, what result do you get the most often?
Enhance your program to run n trials (of ten tosses each) and keep track of the results. That is, record how many times it got 0 intersections, 1 intersection, and so on up to 10 intersections. Run the program for a suitable value of n (depending on your calculator's speed and your patience). What does the distribution of results look like? If you can compute the theoretical results, compare them with your impirical results.
I'll present my RPN and RPL programs at the end of the week, along with a fuller discussion of the problem and the results.
Extra Credit
On your HP calculator, evaluate the following integral, giving the value and an estimate of the error.
/1 /1 /1 /1 /1 /1 /1 /1 dA dB dC dD dE eF dG DHSomething a little more precise than
I = | | | | | | | | ---------------------------------
/0 /0 /0 /0 /0 /0 /0 /0 1 + A + B + C + D + E + F + G + H
The minimum value of the function is 1/9 and the maximum value is 1. Thus 1/9 < I < 1.
(After part 3 of this series, you will know how to do this.)
(And that was a big hint right there.)
Extra Extra Credit
Tie in the original problem to the recent World Cup final.
(Answer later this week.)