Skip to content

Mirasadeghi/Law-of-Large-Numbers-Normal-Distribution-Simulation-in-R

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฏ Simulating the Law of Large Numbers with R

This project demonstrates the Law of Large Numbers using the standard normal distribution in R.

I simulate random values and check what proportion of them fall between -1 and 1. According to the 68โ€“95โ€“99.7 rule, about 68.2% of values in a standard normal distribution should fall within this interval.


๐Ÿ“Š What This Project Does

  • Generates N random values from the standard normal distribution
  • Counts how many values lie between -1 and 1
  • Calculates the proportion and compares it to the theoretical 68.2%
  • Visualizes the distribution using:
    • Density plot with shaded region between -1 and 1
    • Histogram with highlighted range
    • Bar plot comparing theoretical and simulated values

๐Ÿง  Why It Matters

This is a practical demonstration of how the Law of Large Numbers works:

The larger the sample size, the closer the result gets to the expected theoretical value.

It's also a great way to practice working with:

  • Loops and conditionals in R
  • Basic data visualization
  • Statistical thinking using simulation

๐Ÿ“ธ Sample Output

You can expect an output like: Simulated Proportion: 0.6823 Which closely matches the theoretical value of 0.682.

1

2


๐Ÿš€ Run it Yourself

You can run the script using any R environment (e.g., RStudio). Feel free to modify the value of N to see how results vary with smaller or larger sample sizes.

๐Ÿ‘ฉโ€๐Ÿ’ป Author

Samira Sadeghi Data Science student in Milan ๐Ÿ‡ฎ๐Ÿ‡น Researcher in Machine Learning & Cancer Detection ๐Ÿ’ฌ Passionate about R, Python, and building insight from data

โธป

โญ๏ธ If you like this project

Give it a โญ๏ธ on GitHub

About

Simulating the Law of Large Numbers using R and visualizing the 68% rule

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages