Explore Library
Code QuizIntermediate

Law of Large Numbers Simulation

Find the bug in a coin-flip average that should approach 0.5.

Codepython
import numpy as np

# Simulate 100000 fair coin flips (0 or 1)
flips = np.random.randint(0, 1, size=100000)
avg = flips.mean()
print(avg)  # expect close to 0.5

What is the bug in this code?