Bernoulli Distribution

The Bernoulli distribution models a single trial with two possible outcomes — success or failure. It’s the building block for more complex distributions like the Binomial and is widely used in binary classification and yes/no decisions. ⚖️

\[ p_{X}(x) = \begin{cases} p & \text{if } x = 1, \\ q = 1-p & \text{if } x = 0. \end{cases} \]

Python Code: Bernoulli Distribution

To create Bernoulli distributed data using numpy:

import numpy as np

interval = [0,1]
size = (1000,1)
p = [1-0.5, 0.5]

data = np.random.choice(interval, size, p = p)