Skip to content

Instantly share code, notes, and snippets.

@rcgalbo
Created March 14, 2022 18:45
Show Gist options
  • Save rcgalbo/5eadb639c08798e0ebacd3fdfa6d45d5 to your computer and use it in GitHub Desktop.
Save rcgalbo/5eadb639c08798e0ebacd3fdfa6d45d5 to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
import numpy as np
# set seed for reproduceable
np.random.seed(123)
ind = np.arange(1, 40_001)
x = np.random.random(40_000)
y = np.random.random(40_000)
radius = (x**2 + y**2)**.5
in_circle = radius < 1
cumulative = 4*np.cumsum(in_circle)/ind
fig, ax = plt.subplots(ncols=2, figsize=(8,4))
ax[0].scatter(x, y, alpha=.01, c=in_circle)
ax[1].plot(cumulative)
ax[1].set_ylim(3.12, 3.18)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment