import numpy as np
import matplotlib.pyplot as plt
x = np.zeros(3)
x
array([0., 0., 0.])
x = (x + 10) / 2
x
array([5., 5., 5.])
a = np.ones((3, 5)) + 11
a
array([[12., 12., 12., 12., 12.],
       [12., 12., 12., 12., 12.],
       [12., 12., 12., 12., 12.]])
rng = np.random.default_rng(37)
z = rng.normal(size = (2, 3, 4))
z.shape
(2, 3, 4)
t = (0, 1)
np.shape(np.mean(z, axis = t))
(4,)
np.mean(z, axis = t)
array([ 0.52065158,  0.37233466, -0.99693327, -0.09792453])
z.sum(axis = 1)
array([[ 2.46895966,  1.56062171, -5.36693704,  0.09368193],
       [ 0.6549498 ,  0.67338627, -0.61466258, -0.68122913]])
N = 10100
p = 0.7
x = rng.binomial(1, p, size = N)
# np.mean(rng.binomial(1, 0.5, size = 10000000001))
np.mean(rng.binomial(1, p, size = N))
0.7118811881188118
ndx = np.arange(N) + 1
cx = np.cumsum(x)
cm = cx / ndx
plt.plot(ndx, cm)
plt.axhline(p, color = "black", linestyle = "--")