Coder Social home page Coder Social logo

s-faiq-haider-n / simulations Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 710 KB

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

C++ 14.17% Python 85.83%
hardwork luck simulation central-limit-theorem law-of-large-numbers prime-numbers

simulations's Introduction

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! ๐Ÿš€

simulations's People

Contributors

s-faiq-haider-n avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.