Tutorials › Statistical Theory I - Probability and Distribution Theory › Affine Recodings of Bernoulli Outcomes

Bernoulli and Binomial Families · Tutorial 104 of 994

Affine Recodings of Bernoulli Outcomes

Learn how shifting and rescaling a Bernoulli outcome changes its two-point distribution, mean, variance, and higher moments.

Beginner 9 min read

What You'll Learn

  • Find the possible values and probabilities of an affine recoding of a Bernoulli variable.
  • Write its distribution function, including when the recoding reverses the order of the outcomes.
  • Derive its mean, variance, and integer raw and central moments.
  • Use the affine moment formulas to analyze payoff, scoring, and indicator codings.
  • Recognize when a recoding or a boundary probability reduces the support to one point.

Why Recoding Changes the Values, Not the Uncertainty

A Bernoulli variable records one of two outcomes, commonly coded as 0 for failure and 1 for success. In applications, the quantity of interest may instead be a score, cost, payoff, or measurement that assigns different numerical values to those outcomes. An affine recoding expresses this change as a shift and rescaling: \(Y=a+bX\). Its possible values and probabilities follow directly from those of \(X\), while its moments show exactly how the recoding affects location and variability.

Throughout, let \(X\sim\operatorname{Bernoulli}(p)\), so \(P(X=1)=p\) and \(P(X=0)=1-p\), with \(0\leq p\leq 1\). Let \(a,b\) be fixed real numbers, and define \(Y=a+bX\). The constant \(a\) shifts both outcomes; \(b\) determines their separation and, if negative, reverses their order.

Definition: An affine recoding of \(X\) is a random variable \(Y=a+bX\) for fixed real constants \(a\) and \(b\). If \(b\ne 0\) and \(0<p<1\), its two possible values are \(a\) and \(a+b\), with probabilities \(1-p\) and \(p\), respectively. The support consists of values having positive probability. If \(p\) is 0 or 1, or if \(b=0\), some or all of these values coincide or have probability zero, so the support must be reduced accordingly.

Distribution and Two-Point Support

The outcome \(X=0\) maps to \(Y=a\), and the outcome \(X=1\) maps to \(Y=a+b\). Therefore, when \(b\ne 0\) and \(0<p<1\), the probability mass function is

$$ f_Y(y)=(1-p)\mathbf{1}\{y=a\}+p\mathbf{1}\{y=a+b\}, $$

where \(\mathbf{1}\{A\}\) equals 1 when the condition \(A\) holds and 0 otherwise. This expression specifies the mass at each of the two points and is zero elsewhere. The distribution function can be written without splitting into cases according to the sign of \(b\):

$$ F_Y(y)=P(Y\leq y) =(1-p)\mathbf{1}\{a\leq y\}+p\mathbf{1}\{a+b\leq y\}. $$

If \(b>0\), then \(a<a+b\), so the lower value has probability \(1-p\) and the upper value has probability \(p\). If \(b<0\), then \(a+b<a\): the lower value now has probability \(p\), and the upper value has probability \(1-p\). The probabilities remain attached to the original outcomes \(X=1\) and \(X=0\), not to whichever value happens to be larger.

Theorem: For \(Y=a+bX\), with \(X\sim\operatorname{Bernoulli}(p)\), every integer raw moment of order \(r\geq 0\) is $$ E[Y^r]=(1-p)a^r+p(a+b)^r. $$ For every integer \(r\geq 1\), the central moment is $$ E[(Y-E[Y])^r] =b^r\left[(1-p)(-p)^r+p(1-p)^r\right]. $$ In particular, \(E[Y]=a+bp\) and \(\operatorname{Var}(Y)=b^2p(1-p)\).

These formulas apply for all real \(a,b\) and \(0\leq p\leq 1\), including degenerate cases. For \(r=0\), the raw-moment formula gives \(E[1]=1\), including when a possible value is zero, since \(y^0\) here denotes the constant function 1.

Deriving the Moment Formulas

Because \(X\) takes only the values 0 and 1, \(Y\) takes the corresponding values \(a\) and \(a+b\). Weighting each value by its probability gives the raw moment:

$$ E[Y^r] =(1-p)a^r+p(a+b)^r. $$

In particular,

$$ E[Y]=(1-p)a+p(a+b)=a+bp. $$

To obtain the central moments, subtract this mean from each possible value. When \(X=0\), \(Y-E[Y]=a-(a+bp)=-bp\). When \(X=1\), \(Y-E[Y]=a+b-(a+bp)=b(1-p)\). Thus

$$ E[(Y-E[Y])^r] =(1-p)(-bp)^r+p\bigl(b(1-p)\bigr)^r =b^r\left[(1-p)(-p)^r+p(1-p)^r\right]. $$

Taking \(r=2\) yields

$$ \operatorname{Var}(Y) =b^2\left[(1-p)p^2+p(1-p)^2\right] =b^2p(1-p)\left[p+(1-p)\right] =b^2p(1-p). $$

This derivation shows why a shift does not affect variance, while multiplying by \(b\) multiplies variance by \(b^2\). The sign of \(b\) changes the direction of the recoding but not its variance. The derivation also gives higher central moments when needed; for example, the third central moment is \(b^3p(1-p)(1-2p)\). \(\square\)

Worked Example: A Net Payoff From a Bernoulli Outcome

A clinical decision has probability \(p=0.30\) of success. The decision incurs a fixed cost of 2 units whether or not it succeeds, and success earns 10 units. Let \(X=1\) denote success and \(X=0\) failure. Find the distribution, mean, and variance of the net payoff \(Y\).

The payoff is \(-2\) on failure and \(10-2=8\) on success. Thus \(Y=-2+10X\), so \(a=-2\) and \(b=10\). The support points and masses are

$$ P(Y=-2)=0.70,\qquad P(Y=8)=0.30. $$

The mean is

$$ E[Y]=a+bp=-2+10(0.30)=1. $$

Direct calculation checks the result: \(0.70(-2)+0.30(8)=-1.4+2.4=1\). The variance is

$$ \operatorname{Var}(Y)=b^2p(1-p)=10^2(0.30)(0.70)=21. $$

A second check uses \(E[Y^2]=0.70(4)+0.30(64)=2.8+19.2=22\), so \(\operatorname{Var}(Y)=E[Y^2]-(E[Y])^2=22-1=21\).

Worked Example: A Negative Rescaling Reverses the Support Order

Let \(X\sim\operatorname{Bernoulli}(0.80)\), where 1 denotes success, and define \(Z=5-2X\). Find the support, probability masses, mean, and variance.

If \(X=0\), then \(Z=5\), with probability \(0.20\). If \(X=1\), then \(Z=3\), with probability \(0.80\). Because the slope is negative, success maps to the smaller value:

$$ P(Z=3)=0.80,\qquad P(Z=5)=0.20. $$

The mean formula gives \(E[Z]=5+(-2)(0.80)=3.4\). Direct calculation agrees: \(0.80(3)+0.20(5)=2.4+1=3.4\). The variance is

$$ \operatorname{Var}(Z)=(-2)^2(0.80)(0.20)=0.64. $$

Although the outcome labels have reversed order, the mass associated with each original Bernoulli outcome has not changed. In particular, the probability at 3 is \(p\), not \(1-p\).

Worked Example: Recoding a Bernoulli Variable as Two Scores

Suppose \(X\sim\operatorname{Bernoulli}(0.40)\), and a scoring rule assigns 20 points for \(X=0\) and 50 points for \(X=1\). Find the distribution and first two raw moments of the score \(S\).

The difference between the scores is \(50-20=30\), so \(S=20+30X\). Its support is \(\{20,50\}\), and

$$ P(S=20)=0.60,\qquad P(S=50)=0.40. $$

The mean is \(E[S]=20+30(0.40)=32\). The second raw moment is

$$ E[S^2] =(0.60)(20^2)+(0.40)(50^2) =(0.60)(400)+(0.40)(2500) =240+1000=1240. $$

Consequently, \(\operatorname{Var}(S)=1240-32^2=1240-1024=216\). This also follows from \(30^2(0.40)(0.60)=900(0.24)=216\).

Degenerate Cases and a Useful Check

The two-point description requires two distinct values with positive probability. If \(b=0\), then \(Y=a\) with probability 1, whatever \(p\) is. If \(p=0\), then \(X=0\) with probability 1 and \(Y=a\); if \(p=1\), then \(Y=a+b\) with probability 1. In each case the variance formula correctly gives zero. A formula listing \(a\) and \(a+b\) should not be mistaken for two support points when one of the values is impossible or when the values coincide.

Worked Example: Checking a Boundary Probability

Let \(X\sim\operatorname{Bernoulli}(1)\) and \(Y=7-3X\). Since \(X=1\) with probability 1, \(Y=7-3=4\) with probability 1. Thus the support is the singleton \(\{4\}\), \(E[Y]=4\), and \(\operatorname{Var}(Y)=0\). The general formulas confirm this: \(7-3(1)=4\) and \((-3)^2(1)(0)=0\).

Common Mistake: Assigning Probabilities by Numerical Order

A frequent error is to assume that the larger recoded value must have probability \(p\), or that a negative multiplier changes \(p\) to \(1-p\). Neither is correct. The probability \(p\) remains attached to the event \(X=1\), whose recoded value is \(a+b\); the probability \(1-p\) remains attached to \(X=0\), whose recoded value is \(a\). Only after identifying those mappings should the two values be arranged from smaller to larger, if that is useful.

Another check is to distinguish a change in location from a change in spread. Adding a constant changes the mean but not the variance. Multiplying by \(b\) changes the variance by a factor of \(b^2\), not \(b\). This remains true for negative \(b\), because variance is based on squared deviations.

Key takeaway: For \(Y=a+bX\) with \(X\sim\operatorname{Bernoulli}(p)\), the values \(a\) and \(a+b\) inherit probabilities \(1-p\) and \(p\). The mean is \(a+bp\), and the variance is \(b^2p(1-p)\). Check the sign of \(b\) and any boundary probabilities before describing the support.

Check Your Understanding

Answer each question by tracking the original outcomes \(X=0\) and \(X=1\).

  1. If \(X\sim\operatorname{Bernoulli}(0.25)\) and \(Y=4+6X\), what are the support points and their probabilities?
  2. For the variable in Question 1, calculate \(E[Y]\) and \(\operatorname{Var}(Y)\).
  3. If \(X\sim\operatorname{Bernoulli}(0.60)\) and \(Z=8-5X\), which support point has probability \(0.60\)? Explain.
  4. What is the support of \(Y=a+bX\) when \(p=0\), and what is its variance?
  5. Why does a negative value of \(b\) not make \(\operatorname{Var}(Y)\) negative?