Skip to content

This repo includes implemtation of basic simulations in different programming languages and tools.

Notifications You must be signed in to change notification settings

s-faiq-haider-n/Simulations

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simulations Repository

Welcome to the repository for some general simulations! 🎮 Here, we explore various simulations implemented in C++ to gain insights into different phenomena.

1-) Luck and Hard-Work Simulation

The first simulation included is the Luck and Hard Work simulation, inspired by a Veritasium video (A YouTube Channel). In this simulation, we model the selection process for NASA astronauts, considering factors like skill, experience, and luck. The number of applicants and selected candidates is as per the 2017 application process. The simulation generates random skill and luck scores for a pool of applicants and selects top candidates based on their overall scores.

How to Run the Simulation

To run the Luck and Hard Work simulation, compile and execute the provided C++ code. The simulation iterates multiple times for accurate results. You can adjust the number of iterations for detailed analysis.

Results

After running the simulation, you'll obtain insights into the average luck score of selected candidates.

Average Luck Score: 97.1016

This highlights the significant role luck plays in the selection process alongside skill and hard work. Note: While luck may play a role, remember to stay dedicated and work hard towards your goals. Who knows, maybe a lucky break is just around the corner! "Luck can open doors, but it takes skill to keep them open."


2-) Law of Large Numbers

In probability theory, the law of large numbers is a fundamental theorem that describes the behavior of averages of random samples. It states that the average of the results obtained from a large number of independent and identically distributed random samples converges, in some sense, to the true value, if it exists.

Theoretical vs. Practical Probability

There are two perspectives of calculating probabilities:

Theoretical Probability:

Theoretical probability is based on mathematical principles and assumes ideal conditions, where all outcomes are equally likely. It is calculated using theoretical formulas under idealized scenarios.

Practical Probability (Empirical Probability):

Practical probability, also known as empirical probability, is based on observed data from experiments or real-world events. It involves estimating probabilities based on actual outcomes. To illustrate, consider the probability of rolling a six on a fair six-sided die:

The theoretical probability of rolling a six is 1/6, assuming each face of the die is equally likely. However, in practice, the observed probability might differ based on the outcomes of actual die rolls.

Law of Large Numbers and Convergence:

The law of large numbers, attributed to Jakob Bernoulli, states that although practical (empirical) probabilities may diverge from theoretical probabilities for small sample sizes, as the sample size increases, the practical probability tends to converge towards the true (theoretical) probability.

In summary, the law of large numbers underscores the relationship between observed frequencies and underlying probabilities, demonstrating that with a sufficiently large number of trials or samples, empirical probabilities approach theoretical probabilities.

In the code section of the repository, practical demonstrations are showcased using Python libraries matplotlib and numpy. These demonstrations illustrate the law of large numbers for both dice rolls and coin tosses.

Below is an example execution of the program, demonstrating how the probability of rolling a 3 with a die converges to the true value as the sample size increases.

DEMO Execution

For getting 3 in 100 die rolls

three_100

For getting 3 in 1000 die rolls

three_1000

For getting 3 in 1000000 die rolls

three_1000000


3-) Prime number Generator (Different Types)

This repo consists of a python script aimed at generating Primes of different types till a specified range.

01. Simple Prime Numbers

Primes such that they are only divisible by 1 and themselves

02. Additive prime numbers

Primes such that the sum of digits is a prime

03. Factorial prime

Primes of the form n! − 1 or n! + 1

04. Fibonacci prime

Primes in the Fibonacci sequence

05. Happy prime

Primes that eventually reach 1 under iteration of: x -> sum of squares of digits of x

06. Mersenne prime

Primes of the form 2^n - 1

07. Multiplicative prime

Primes such that the product of digits is a prime

08. Palindromic prime

A palindromic prime is a prime number that is also a palindromic number

09. Pythagorean prime

Primes of the form 4n + 1

10. Safe prime

A safe prime is a prime number of the form 2p + 1, where p is also a prime

DEMO Execution

Fibonacci primes till 100

fibonacci

Palidromic primes till 100

Palidromic


Future Work

This repository aims to expand its simulations to explore various scenarios and factors influencing success. Stay tuned for updates as we delve deeper into understanding different phenomena through simulations! Feel free to contribute, provide feedback, or suggest ideas for future simulations. Let's continue exploring the world of simulations together! 🚀

About

This repo includes implemtation of basic simulations in different programming languages and tools.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published