Skip to content

[prob_dist] Bernoulli distribution section - editorial suggestions #403

Closed
@longye-tian

Description

@longye-tian

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 $S = {0, 1}$, which has PMF:

$$p(x_i) = \begin{cases} p & \text{if $x_i=1$}\\ 1-p & \text{if $x_i = 0$}\\ \end{cases}$$

Here $x_i\in S$ is the outcome of the random variable.

The interpretation of $p(x_i)$ is the probability of 'true' for any single experiment that asks 'True-False' question.

We can import the Bernoulli distribution on $S = {0,1}$ from SciPy like so:

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 $p$, and the formula for the variance is $p(1-p)$.

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 $p(x_i)$ at $x_i$.


Best,
Longye

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions