00
Project Overview
Simulations
Coin Toss + Dice Roll
Output
Matplotlib Bar Charts
Speed
< 0.5s for N=100,000
Algorithm
Mersenne Twister PRNG
01
Source Repository
Open Source · Public Repository
Full project on
GitHub
GitHub
The complete source code, commit history, and documentation for the Probability Simulator & Analyzer lives here. Clone it, fork it, or star it — it's all yours.
PBL 2025–26
Solo Project
Python · MIT
BVDUCOE, Pune
02
Complete Source Code — PBL.py
1# ═══════════════════════════════════════════════════════════════2# Probability Simulator & Analyzer3# Author : Animesh Pattnaik | BVDUCOE, Pune | PBL 2025-264# ═══════════════════════════════════════════════════════════════56import random7import matplotlib.pyplot as plt89n = int(input("Enter number of trials: "))1011# ── COIN TOSS ──────────────────────────────────────────────────12heads = 013tails = 01415for i in range(n):16 toss = random.randint(0, 1)17 if toss == 1:18 heads += 119 else:20 tails += 12122print("Heads =", heads)23print("Tails =", tails)2425plt.figure()26plt.bar(["Heads", "Tails"], [heads, tails])27plt.xlabel("Outcome")28plt.ylabel("Count")29plt.title("Coin Toss Simulation")30plt.show()3132# ── DICE ROLL ──────────────────────────────────────────────────33dice = [0, 0, 0, 0, 0, 0]3435for i in range(n):36 value = random.randint(1, 6)37 dice[value - 1] += 13839print("Dice results:", dice)4041plt.figure()42plt.bar([1, 2, 3, 4, 5, 6], dice)43plt.xlabel("Dice Number")44plt.ylabel("Frequency")45plt.title("Dice Roll Simulation")46plt.show()
03
Coin Toss Simulation Kernel
1# Coin toss — Bernoulli trial P(H)=0.52heads, tails = 0, 034for i in range(n):5 toss = random.randint(0, 1) # 0=Tails 1=Heads6 if toss == 1: heads += 17 else: tails += 189print("Heads =", heads)10print("Tails =", tails)11plt.bar(["Heads", "Tails"], [heads, tails])12plt.title("Coin Toss Simulation"); plt.show()
04
Dice Roll Simulation Kernel
1# Dice roll — Discrete Uniform U{1..6}2dice = [0] * 634for i in range(n):5 value = random.randint(1, 6) # face 1–66 dice[value - 1] += 178print("Dice results:", dice)9plt.bar([1,2,3,4,5,6], dice)10plt.title("Dice Roll Simulation"); plt.show()
05
Terminal Output — N = 1000
$ python3 PBL.py
↳ Enter number of trials: 1000
--- Coin Toss Results ---
Heads = 497
Tails = 503
--- Dice Roll Results ---
Dice results: [168, 162, 171, 163, 169, 167]
✓ Process exited with code 0 · runtime: 0.23s
06
How To Run
1# Install dependency (one-time)2pip install matplotlib34# Run the simulator5python3 PBL.py67# Enter when prompted — try these values:8# 10 → high variance, fun to observe9# 1000 → clear convergence visible10# 100000 → near-perfect theoretical match