Documentation
¶
Overview ¶
https://introcs.cs.princeton.edu/java/21function/Benford.java.html https://en.wikipedia.org/wiki/Benford%27s_law
https://en.wikipedia.org/wiki/Birthday_problem simulates birthday problem
For every 100 coin flips, record the number of heads encountered and subtract .5 from it, does it go to 0 as the number of coin flips go to infinity? Answer: yes Since it is a uniform and fair dice, the probability as n goes to infinity, it should be .5
Tosses a coin and times and records whether or not the proportion of heads is within .1 of .5 (i.e., between .4 and .6). Have your program repeat this experiment 100 times. About how large must n be so that approximately 95 out of 100 times the proportion of heads is between .4 and .6? Answer: about 1-sqrt(n) >= 95 for a uniform random dice we increment the time when it hits heads, minus one otherwise, we do this so it can "remember", if we reset every 100 times, it is as if it forgets what it obtained
https://en.wikipedia.org/wiki/Monty_Hall_problem
In raquetball, a player continues to serve as long as she is winning; a point is scored only when a player is serving and wins the volley. The first player to win 21 points wins the game. Assume that you serve first and have a probability .6 of winning a volley when you serve and probability .5 when your opponent serves. Estimate, by simulation, the probability that you will win a game?
answer: running N simulations, get 75% wins for you, 25% for them
Write a program to simulate a random walk in one dimension starting at 0. Have your program print out the lengths of the times between returns to the starting point (returns to 0). See if you can guess from this simulation the answer to the following question: Will the walker always return to his starting point eventually or might he drift away forever?
In Las Vegas, a roulette wheel has 38 slots numbered 0, 00, 1, 2, ..., 36. The 0 and 00 slots are green and half of the remaining 36 slots are red and half are black. A croupier spins the wheel and throws in an ivory ball. If you bet 1 dollar on red, you win 1 dollar if the ball stops in a red slot and otherwise you lose 1 dollar. Write a program to find the total winnings for a player who makes 1000 bets on red.
Answer: for a thousand tries, on average you seem to lose on average 38% of the time for -398 dollars lost