# Why 0 for failure and 1 for success in a Bernoulli distribution?

Why do we choose these numbers and not for e.g $e$ and $\pi$ for success and failure in an experiment?

What is the logic and how badly would it affect my calculations if I choose other values instead of 0 and 1?

• It makes things mathematically convenient, although using 0 for success and 1 for failure could be equally convenient. Note that, per en.wikipedia.org/wiki/Bernoulli_distribution , "The Bernoulli distribution is a special case of the two-point distribution, for which the two possible outcomes need not be 0 and 1". You are perfectly free to define a two-point distribution whose values are $e$ and $\pi$ (respectively for success and failure in an experiment); it could be called the Oleg distribution. – Mark L. Stone Mar 27 '16 at 19:57

## 2 Answers

As already noted by Mark L. Stone, it is used because of tradition and convenience. It could have been $-1$ and $+1$ as with Rademacher distribution, or any other values.

However there are also other reasons that make $0$ and $1$ a convenient choice. First, expected value of Bernoulli distributed random variable is

$$E[X] = 0\times(1-p)+ 1\times p = p$$

...so it is instantly obvious from the distributions definition. Sample mean is being maximum likelihood estimator of $p$ since taking the arithmetic mean of zeros and ones leads to proportion of ones in the whole sample.

Moreover, we can easily extend Bernoulli distribution to binomial distribution, i.e. from modelling single success in single draw, change to modelling $k$ successes in $n$ draws -- it is quite helpful that you can just sum $1$'s to get number of successes.

There are also multiple other reasons why such coding is convenient for computations, to learn more see Why is gender typically coded 0/1 rather than 1/2, for example?

Mathematical convenience. Here is an example: if you set the success case to be $1$ and the failure case to be $0$, then you have that the binomial variable $X \sim B(n, p)$, which counts the number of successes in $n$ independent Bernoulli trials $X_i \sim B(1, p)$, with $i = 1, 2, ..., n$, can be written as

$$X = \sum_i X_i$$

Therefore,

$$E[X] = \sum_i E[X_i] = np$$

In addition,

$$V[X] = \sum_i V[X_i] = np(1 - p)$$