Description
I've noticed that the content in the Bernoulli distribution section closely mirrors that of the uniform distribution section.
With this in mind, I'd like to propose the following amendments. Would that be alright with you, John(@jstac)?
Another useful distribution is the Bernoulli distribution on
Here
The interpretation of
We can import the Bernoulli distribution on
p = 0.4 # The probability of True
u = scipy.stats.bernoulli(p)
Here's the mean and variance:
u.mean(), u.var()
The formula for the mean is
Now let's evaluate the PMF:
u.pmf(0)
u.pmf(1)
Here's a plot of the probability mass function:
fig, ax = plt.subplots()
S = np.arange(-4, 6)
ax.plot(S, u.pmf(S), linestyle='', marker='o', alpha=0.8, ms=4)
ax.vlines(S, 0, u.pmf(S), lw=0.2)
ax.set_xticks(S)
plt.show()
Here's a plot of the CDF:
fig, ax = plt.subplots()
S = np.arange(-4, 6)
ax.step(S, u.cdf(S))
ax.vlines(S, 0, u.cdf(S), lw=0.2)
ax.set_xticks(S)
plt.show()
The CDF jumps
Best,
Longye