> For the complete documentation index, see [llms.txt](https://stephanosterburg.gitbook.io/scrapbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stephanosterburg.gitbook.io/scrapbook/math/statistics-and-probability/binomial-variables/binomial-mean-and-standard-deviation-formulas.md).

# Binomial mean and standard deviation formulas

### Mean and variance of Bernoulli distribution example

unfavorable = 40% ----> 0

favorable = 60% ----> 1

We map the values to a 0 and 1.

#### Mean:

$$\mu = 0.4 \cdot 0 + 0.6 \cdot  1 = 0.6$$

#### Variance:

$$\sigma^2 = 0.4 \cdot (0-0.6)^2 + 0.6 \cdot (1 - 0.6)^2 \newline \sigma^2 = 0.4 \cdot 0.36 + 0.6 \cdot 0.16\newline \sigma^2 = 0.24\newline \sigma\ \ =\sqrt{0.24} = 0.49$$

### Bernoulli distribution mean and variance formulas

unfavorable = 40% ----> 0 ===> we change it to (1 - p) -> failure

favorable = 60% ----> 1 ===> we change it to (p) -> success

$$\mu = (1-p) \cdot 0 + p \cdot 1 = p$$

$$\sigma^2=(1 -p)(0-p)^2 + p(1-p)^2\newline  \sigma^2 = (1-p)p^2 +p(1-2p+p^2)\newline \sigma^2 = p^2 -p^3+p-2p^2+p^3\newline \sigma^2= p-p^2 \newline \sigma^2 = p(1-p)$$

### [Expected value of a binomial variable](/scrapbook/math/hackerrank.md)

(see Statistics (hackerrank)/Poisson Distribution)

X = # of successes after $$n$$ trials where P(success) for each trial is $$p$$

$$E(X)=n \cdot p$$

$$E(X+Y)=E(X)+E(Y)$$

### Finding the mean and standard deviation of a binomial random variable

> A company produces cell phone chips. 2% of them are defect. A quality check involves randomly selecting and testing 500 chips.
>
> What are the mean and standard deviation?

$$X$$= # of defective chips in 500 chip sample

$$\mu\_x=E(X)=n \cdot p \newline \mu\_x = 500 \cdot 0.02 = 10$$

$$\sigma\_x = \sqrt{\sigma\_x^2} = \sqrt{Var(X)}=\sqrt{n \cdot p \cdot (1-p)}=\sqrt{500 \cdot 0.02 \cdot 0.98} = \sqrt{9.8} = 3.13$$
