Coconote
AI notes
AI voice & video notes
Export note
Try for free
Computer Simulation of Probabilistic Experiments using Python
Jun 22, 2024
Computer Simulation of Probabilistic Experiments using Python
Introduction
Lecture on computer simulation of probabilistic experiments
Difference from regular computations and derivations
Focus on hands-on Python programming
No major Python structures; simple functions provided
Aim: to simulate probabilistic experiments and verify theoretical probabilities using Monte Carlo simulations
Experiments and Simulations
Concept of an Experiment
Defined as an action leading to some outcome
Simulate experiments using a computer program
Utilize Python routines to simulate and verify probabilities
Example: Simulating coin toss to verify the probability of heads (0.5)
Monte Carlo Simulation
Standard technique to estimate the probability of events
Simulate the experiment multiple times to approximate the probability
Formula: Probability ≈ (Number of successful events) / (Total number of experiments)
Demonstrated with a coin toss and die throw example
Python Notebooks in Google Colab
Introduction to Python Notebooks and Google Colab
Creating and using cells (code or text)
Importance of Python Notebooks in data science and other fields
Example notebook provided and explained (probability in Python)
Using Python in Colab
Importing necessary modules (e.g., numpy)
Implementing functions to simulate experiments (e.g., uniform distribution for coin toss, die throw)
Example code snippets for single and multiple tosses of a coin and die
Monte Carlo Techniques in Detail
Estimating probability using repeated experiments
Steps: Define repetitions, conduct the experiment, check the event, calculate the probability
Examples:
Coin toss simulation to estimate the probability of heads
Die throw simulation to estimate the probability of getting a specific number or a range of numbers
Classic Probability Problems using Python
Birthday Problem
Scenario: Probability of shared birthdays in a group
Assumption: Birthdays uniformly distributed across 365 days, independent
Calculation: Using combinatorial probability and Monte Carlo simulation
Key Insight: Over 50% chance of shared birthdays with just 23 people
Python simulation to verify theoretical probability
Monty Hall Problem
Game show scenario with three doors, one car, and two goats
Choice dynamics: Initially choose a door, host reveals a goat behind another door, choice to switch or stick
Insight: Switching doors increases the probability of winning the car to 2/3
Python simulation to verify theoretical result
Other Experiments
Polya’s Urn Scheme (briefly mentioned)
Simple Random Walk / Gambler's Ruin
Scenario: Gambler with k units of money, goal to reach n units or go bankrupt
Analysis: Using a fair/unfair coin, probability of reaching the goal or going bankrupt
Python simulation to verify theoretical probabilities
Activity for Students
Understanding how to set parameters in Python code
Recreating Monte Carlo simulations for chosen experiments
Example: Modify code to simulate different probabilistic scenarios (e.g., binomial distribution)
Goal: Compare theoretical and simulated probabilities
Submission: Share the customized notebook on Google Sites
Conclusion
Recap of Stats One concepts in Week One
Preparation for new topics from Week Two
Emphasis on practical skills and theoretical understanding in probabilistic simulations
📄
Full transcript