Group 6
Overview
Law of Large Numbers:
The Law of Large Numbers is a fundamental concept in probability theory and statistics. It states that as the sample size increases, the average of a sequence of independent and identically distributed random variables approaches the expected value of those variables. In simpler terms, the Law of Large Numbers suggests that the more observations we have, the closer our sample mean will be to the population mean.
Understanding the Law of Large Numbers is crucial for building knowledge in probability and statistics. It forms the basis for statistical inference and justifies many statistical techniques. It highlights the importance of collecting sufficient data and how sample size impacts the reliability of statistical results.
Monte Carlo Method:
The Monte Carlo Method is a computational technique used to estimate unknown quantities by simulating random processes repeatedly. It leverages random sampling and probability principles to approximate solutions for complex problems that may be difficult or impossible to solve analytically.
The Monte Carlo Method finds applications in various fields, including physics, finance, engineering, and computer science. It enables researchers to model and analyze systems with a large number of variables and uncertainties. By repeatedly simulating random scenarios, the method provides statistical estimates and insights into the behavior of the system.
Relationship between Law of Large Numbers and Monte Carlo Method:
The Law of Large Numbers and the Monte Carlo Method are closely related. The Law of Large Numbers provides the theoretical foundation for the Monte Carlo Method. It explains why the method works and why repeated simulations converge to accurate estimates.
By understanding the Law of Large Numbers, students can appreciate how the Monte Carlo Method leverages random sampling to approximate unknown quantities. They can see how the method utilizes the principles of the law to simulate and analyze complex systems.
Exploring through Shiny app (Instruction)
The shiny app is a useful tool to explore the law of large numbers and Monte-Carlo Method when there's something probabilistic that we can't predict, we need to do a lot of trials to make sure we're understanding the system correctly.
We will use four shiny apps to study four tasks separately.
Pre-task (Fair & False Coins)
In the shiny app of the pre-task, students can control the number of flips in order to find out the probability of getting a head.
Regarding the outcomes, there are two pieces of information that students will see:
The probability of getting the heads.
The histogram, which shows the number of tails and heads in the set of throwing the coins.
The probability should converges to 0.5 when the number of flips increase.
Task 1 (Estimate pi)
In the shiny app of task 1, you can set different number of needles to estimate the value of pi.
For the outcomes, there are two parts that students will see:
A graph showing the results of needle throwing.
Each point in line graph represents the each estimation of different number of needles from 0 to the number you set before.
Task 2 (Estimate the Area of the irregular white shape in the given image)
In the shiny app of task 2, you can set a different value of "total points" which represents the different number of points fall inside on the picture. Then, please click on the button "run simulation" to get the value of the estimated white area.
For the results,
1. there is coordinate graph. Every time you set a random point and run the simulation, a new point will be added to the it, x-axis represent "Number of Random Points" and y-axis represent"Estimated White Area".
2. the corresponding record will be shown in the table named "Simulation Results" below the coordinate graph. It record "Number of Random Points" and "Estimated White Area".
In addition, you can click the button "Download Results", then you will get a ".txt" file of simulation results, which records all the random points you have entered and the corresponding size of the area you got.
Task 3 (Life application - gamble)
In the shiny app of task 3, you can first set the total number of people.
Then set the total rounds according to the required task or as your interest.
After set two parameters, please click the button "Simulating Gambling" to get the outcomes.
For the outcomes,you will see two parts:
The table of each people's situation, like total number of rounds they completed and money remaining. You can click the arrows near the titles to decide the showing order is ascending or descending so that you can easily see the largest money remaining, the lowest rounds completed, etc. In the second row, you can also set the range to get what you want.
The summary information concludes the performance of the total sample. It provides five informations:
1. total rounds;
2. total number of people;
3. number of people who went bankrupt & withdraw early;
4. number of people with profit (complete total rounds);
5. number of people with a loss (complete total rounds).
Each shiny app link will post on the page of corresponding task.
Use it to explore. Hope you'll have a good studying experience!🙋
Pre- Task - (Fair & False Coins)
Theorm of the law of large numbers:
Let X₁, X₂, X₃, ..., Xₙ be a sequence of independent and identically distributed random variables with the same expected value (μ) and finite variance (σ²). The sample mean (X̄ₙ) of these variables is defined as:
Then, according to the law of large numbers, as the number of variables (n) approaches infinity, the sample mean X̄ₙ converges in probability to the expected value μ:
This equation states that as n becomes larger and larger, the probability that the absolute difference between the sample mean X̄ₙ and the expected value μ is less than any given positive value ε approaches 1. In other words, the likelihood of X̄ₙ being arbitrarily close to μ increases as the sample size increases.
Situation:
Let's think about a coin. We want to know if the coin is fair or not. A fair coin has these properties:
If you flip a coin just one time, what will happen? It will either land on heads or tails.
If you flip a coin and it lands on tails, and then you walk away, have you proven that P(tails)=1 and that the coin is not fair?
Of course not! A fair coin can also land on tails after one try, after all.
Maybe you flip the coin again and it lands on heads, thus proving that P(tails)=P(head)=1/2, and that the coin is fair.
But have you actually proven that the coin is fair?
Maybe the coin isn't completely fair but it does land on both sides sometimes.
Instruction:
By using two set of suggested data, we are going to prove that the coin is fair by considering two cases: Fair and False coins.
Eventually, you will know how is the the law of large numbers have applied in this set-up scenario.
In addition, you will need to use the Shiny to perform the upcoming Pre-task. You can perform lots of flips while the Shiny Apps.
The following is the link of Shiny app that we use in this task.
1. Set the probability to 0.5 (getting a head)
2. Try the number of flips at 1,5,10,100,10000
3. What have you observed? Discuss with your groupmate
4. Click the “Ans for Pre-Task1” button to check the answer.
1. Set the probability to 0.75 (getting a false coins)
2. Try the number of flips at 1,5,10,100,10000
3. What have you observed? Discuss with your groupmate
4. Click the ““Ans for Pre-Task2” button to check the answer.
Ideas behind the Pre-task
The law of large numbers, applied to the context of throwing a fair coin, states that as the number of coin tosses increases, the proportion of heads (or tails) observed will converge to 0.5.
In other words, if you repeatedly flip a fair coin and record the outcomes, the relative frequency of heads will approach 0.5 as the number of coin tosses increases. This means that over a large number of tosses, you would expect to observe roughly an equal number of heads and tails.
It's important to note that while the law of large numbers suggests a tendency for the proportion of heads to approach 0.5, it does not guarantee that the exact proportion will always be exactly 0.5 for any finite number of tosses. There can still be some variation in the short term, but over a large number of trials, the proportion will converge to the expected value of 0.5.
Task 1 - Estimating Pi
Monte Carlo simulations are often used when the problem at hand has a probabilistic component.
An expected value of that probabilistic component can be studied using Monte Carlo due to the law of large numbers.
With enough data, even though it's sampled randomly, Monte Carlo can hone in on the truth of the problem.
Principle:
Now, we are going to estimate the value of π .
What we need to do is throwing random needles into a circle inscribed within a square that is drawn on the ground. After many needles are dropped, one quadrant of the circle is then examined. The ratio of the number of needles that are inside the square to the number of needles inside the circle is a very good approximation of pi. The more needles that are dropped, the closer the approximation gets.
Think about inscribing a circle and a square with sides of length 1, so that the radius r of the circle is of length 1.
We have the area of the circle π*r*r=π and the area of a tangent circle inside a square is one quarter of the whole circle,
But what is π?
We can throw a large number of random pins into the square, then some will land inside the circle and some outside.
By this way, the ratio of the number of pillows located inside the circle (blue point) to the number of needles located inside the square(red point + blue point) can then be used to estimate the area of the circle.
The following is the link of Shiny app we can use in this task.
Question:
Enter different numbers of needles on the shiny, submit the line graph in google sites, and describe its trends.
ANSWER
The more needles we drop in the circle, the closer our approximation gets to the actual value of π.
Task 2 - Estimate the Area of the irregular white shape in the given image
Monte Carlo methods are also often used to calculate the area of irregular shapes.
Irregular shapes are shapes that cannot be described by simple geometric shapes.
These figures are widely used in practical applications, such as clouds and mountains.
For these figures, area is an important parameter which is directly related to the analysis and calculation in many scientific and engineering fields.
Therefore, it has great significance to solve the area of irregular shapes using Monte Carlo methods.
Principle:
The basic principle is to generate a large number of points randomly within the picture where an irregular graph is located, then calculate the probability that these points fall inside the irregular graph, and finally multiply this probability by the total number of points.
Procedures:
The specific realization process is as follows:
1. Randomly generate a large number of points within a picture where an irregular graph is located and ensure that these points are uniformly distributed inside the picture.
2. For each generated point, you need to determine whether it is the point inside the irregular graph.
3. The number of points falling inside the graph divided by the total number of points and then multiplied by the total area of the picture, you get the area of the irregular graph.
The procedures are achieved by Monte-Carlo Simulation Method in this task.
The following is the link of Shiny app we can use in this task.
Questions 1:
Next, looking at the image, please calculate the area of the white part with the help of shiny app.
Questions 2:
Now fill in the following table using the shiny app and find out what are the characteristics of the value of white area obtained as the number of random points increases?
ANSWER 1:
1.The value obtained by the Monte Carlo method is not an exact value, but an approximation. Based on the size of the area estimated, it can be seen that the gradual value of the white area approximation obtained converges to the true value as the number of cast points becomes larger and larger.
(The answer of "Estimated White Area" is not unique)
Question 2: Please estimate the size of the area of the white irregular figure based on the data obtained.
ANSWER 2:
Close to 150000. (The answer is not unique)
Task 3 - Life Application (gamble)
Although there are numerous people in deprivation, divorce, and even suicide due to gambling, there still are so many people who want or already gambled for a very long time. Many people do not know the final outcome of gambling and still have a mentality of luck. Next, we will use Monte-Carlo method through Shiny app to speculate on the outcome of continuous gambling.
Principle
Monte-Carlo simulation method is that when the problem has probability characteristics, computer simulation can be used to generate sampling results, and statistical or parameter values can be calculated based on the sampling. As the number of simulations increases, stable conclusions can be obtained by averaging the estimated values of each statistical or parameter.
Set Scenario
The gambler and the banker bet on tossing coins. If it is head, the gambler wins, and the banker pays the gambler 1 dollar, vise versa. The gambler has an initial bet of 10 dollar, and they will withdraw from the game once they lose all their money. Otherwise, they will complete total rounds.
The gambling outcome essentially depends on the result of each coin toss. Thus, each round of gambling is a Bernoulli experiment, with a probability of winning p=0.5.
The following is the link of the Shiny app we can use in this task.
Question 1:
Set the total number of people be 10000 because Monte-Carlo Method need large number of sample to get its highly approximated conclusion.
Please complete the table with the help of shiny.
Question 2: What can you conclude from the table?
(A) As the number of rounds increases, the number of people who with a profit increase
(B) As the number of rounds increases, the number of people who went bankrupt increase
(C) When gamblers play 10000 rounds, there are almost 90 percent of people who went bankrupt
(D) Every person will benefit from gambling no matter the number of rounds.
(A) is wrong since as the number of rounds increases, the number of people who with a profit decrease.
(B) is correct according to the table.
(C) is correct since 9181/10000=91.81% (the number might be little different)
(D) is wrong. There always are some people loss their money.
Question 3: What do you learned about gambling from this task?
People should not be addicted to gambling. (The answer is not the only)
Reference:
https://en.wikipedia.org/wiki/Law_of_large_numbers#Examples
https://brilliant.org/wiki/monte-carlo/
https://math.ryerson.ca/~niushan/lln.pdf
Links:
Pre-Task: https://maedgroup6.shinyapps.io/Pre-Task/
Task 1: https://lckict.shinyapps.io/Task1-EstimatePi/
Task 2: https://lckict.shinyapps.io/Task2-Area/
Task 3: https://lckict.shinyapps.io/Task3-Casino/
Group members & Contributions:
LOK Chin Hung (20933605): Pre-task's designer, Google-site's designer
LI Kangyu (21004968): Task 3's designer, Google-site's designer
HUANG Siqin (21001409): Task 1's designer, Google-site's designer
WEI Ke (21000625): Task 2's designer, Google-site's designer