Let
Pick a random matrix
X = np.array([[1, 2], [3, 4]])
Compute norm along the column axis
row_norms = np.linalg.norm(X, axis=1, keepdims=True)
X_normed = X / row_norms
We sample points uniformly in the unit square
The probability of falling inside the quarter unit circle is
N = 10000
x = np.random.rand(N)
y = np.random.rand(N)
inside = x**2 + y**2 <= 1
pi_est = 4 * np.sum(inside) / N
NumPy is the foundation of many scientific stacks in Python.
Use the quickstart and examples to learn.
The reference is best when you need details about a function.