Understand the theory and implementation of simulation. This book covers simulation topics from a scenario-driven approach using Python and rich visualizations and tabulations. The book discusses simulation used in the natural and social sciences and with simulations taken from the top algorithms used in the industry today. The authors use an engaging approach that mixes mathematics and programming experiments with beginning-intermediate level Python code to create an immersive learning experience that is cohesive and integrated. After reading this book, you will have an understanding of simulation used in natural sciences, engineering, and social sciences using Python. You will:
• Use Python and numerical computation to demonstrate the power of simulation
• Choose a paradigm to run a simulation
• Draw statistical insights from numerical experiments
• Know how simulation is used to solve real-world problems
Who This Book Is For: Entry-level to mid-level Python developers from various backgrounds, including backend developers, academic research programmers, data scientists, and machine learning engineers. The book is also useful to high school students and college undergraduates and graduates with STEM backgrounds.
Author(s): Rongpeng Li, Aiichiro Nakano
Edition: 1
Publisher: Apress
Year: 2022
Language: English
Commentary: TruePDF
Pages: 175
Tags: Python; Data Science; Programming Language
Table of Contents
About the Authors
About the Technical Reviewer
Acknowledgments
Introduction
Chapter 1: Calculating Pi with Monte Carlo Simulation
Background
The Wise Persons’ Competition
Estimating Pi by Sprinkling Grains
Exercise
Contain the Goat!
What Randomness?
Exercise
Summary
Chapter 2: Markov Chain, a Peek into the Future
Weather Forecasting
Eigenstates of Markov Chains
Exercise
Markov Chain Applications
A Random Walk That Has an End
Sonnet Written by Drunk Shakespeare
Exercise
Summary
Chapter 3: Multi-armed Bandits, Probability Simulation, and Bayesian Statistics
Random Pick and Naive Greedy Approach
Greedy-Epsilon: Greedy but Not Always
An Improved Greedy-Epsilon Algorithm
Exercise
The Bayesian Way, a Primer on Bayesian Statistics
Exercise
Summary
Chapter 4: Balls in a 2-D Box, a Simple Physics Engine
One Ball in a 2-D Box
Physics Law of Motion
Collision Detection
Exercise
Multiple Balls in a 2-D Box
Update of Positions and Velocity upon Collision
Collision Detection in Multiple-Ball Scenario
Exercise
Summary
Chapter 5: Percolation, Threshold, and Phase Change
Problem Introduction
Percolation and the Critical Probability
An Analytical Solution for the 1-D Case
A Simulation for the 2-D Case
Exercise
Another Interesting Statistic in 2-D Grid Percolation
Exercise
Summary
Chapter 6: Queuing System: How Stock Trades Are Made
Trading Process Fundamentals
The Order Book
Create the Interfaces and Determine the Data Schema
Implement Order Book Logic
Hook the Bots and Engine Together
Exercises and Extension Ideas
Multiple Bots
An Informed Bot
Order Book Visualization
Order Cancellation Support
Stop Orders Support
Summary
Chapter 7: Rock, Scissors, and Paper: Multi-agent Simulation
Community Formation on a Street
Exercise
Original Schelling Model
Three Groups
How to Win a Global Rock, Paper, and Scissors Contest
Exercise
Summary
Chapter 8: Disease Spreading, Simulating COVID-19 Outbreak
Simplifying the Real World
The SI Model
Exercise
The SIR Model
Exercise
Summary
Chapter 9: Misinformation Spreading and Simulations on a Graph
Model the Social Network
Simulate Misinformation Spreading
Simple Cases
Misinformation Spreading on Different Networks
Exercise
Summary
Index