An unexpected result involving sums of random numbers
|
03-02-2023, 10:00 PM
Post: #14
|
|||
|
|||
RE: An unexpected result involving sums of random numbers
(03-01-2023 07:14 PM)Namir Wrote: Your results are good. With one million iteration I get an average of 2.71. With a sum of 2 I get an average of 4.6. And with an average of 3 I get an average of 6.5. I have modified two programs to handle arbitrary sums. Even 5000 iterations, which is quite feasible on the HP-15C LE, will give results close to the theoretical values: 1 -> 2.7182818; e 2 -> 4.6707743; e(e - 1) 3 -> 6.6665656; e(2e² - 4e + 1)/2 Code:
0 STO RAN# 1 ENTER 5000 f A -> 2.7152 ( 55.5 seconds ) 0 STO RAN# 2 ENTER 5000 f A -> 4.6656 ( 100.6 seconds ) 0 STO RAN# 3 ENTER 5000 f A -> 6.6754 ( 146.7 seconds ) Of course, on a computer or smartphone running Free42 we can go even further. For instance, Code: 00 { 40-Byte Prgm } 4 SEED 1 ENTER 1E7 XEQ “X” -> 2.7181530 ( 29.4 seconds ) 4 SEED 2 ENTER 1E7 XEQ “X” -> 4.6711803 ( 50.1 seconds ) 4 SEED 3 ENTER 1E7 XEQ “X” -> 6.6667329 ( 71.6 seconds ) As mentioned earlier in this thread, I was motivated by a short note on a book I read some years ago and ran into it again last week, which read Quote:Here is an example of e turning up unexpectedly. Select a random number between 0 and 1. Now select another and add it to the first. Keep doing this, piling on random numbers. How many random numbers, on average, do you need to make the total greater than 1? The answer is e. Not forgetting about Valentin's Math Challenge linked above would have spared me some time, but then again I would have lost the chance to dust off my calculators and check that out for myself. Detailed information and a shorter and possibly faster RPN program also available in his original solution. Thanks you all for your interest and contributions. Gerson. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 5 Guest(s)