Search

Search papers and lessons

Rademacher Distribution

Level 2 · 11 min read

The Rademacher distribution is a random variable that equals plus 1 or minus 1 with equal chance, so its mean is 0 and its variance is 1.

On this page

  • Colour = topic mix
  • Probability
  • Discrete math
  • Calculus
  • ReadReady to readNot yet

TL;DR

A Rademacher random variable takes the value plus 1 or minus 1, each with probability one half. It is the simplest symmetric random sign: nothing favours either side. Its mean is 0 and its variance is 1, and sums of independent Rademacher variables are a standard tool for modelling random noise and for randomising algorithms.

Builds on: Probability Mass Function, Mean and Variance · Leads to: Rademacher Complexity

Where it's used

Learning theory. The Rademacher complexity of a family of prediction functions is defined by averaging over random sign variables. It measures how well the family can fit pure noise, and that ability bounds how far training error can fall below test error. The theory uses Rademacher variables because each sign has an exact mean of 0 and variance of 1.

Stochastic optimisation. The simultaneous perturbation method, proposed by James Spall in 1992, estimates the gradient of a loss with many parameters by moving all of them at once. The random direction is a vector of Rademacher signs, one per parameter. A model with 100 parameters can therefore be tuned with two loss evaluations per step. A finite-difference estimate, which moves one parameter at a time, would need 200.

Random projections and sketching. A random matrix with independent Rademacher entries projects high-dimensional data down to a smaller space while roughly preserving distances. Because every entry is plus or minus 1, the matrix is cheap to store and to multiply.

How it works

Start with a fair coin. Heads and tails each have probability one half. Turn the coin into a random variable by setting X=+1X = +1 for heads and X=−1X = -1 for tails.

flowchart LR
  A["Fair coin flip"] --> B{"Heads or tails?"}
  B -- heads --> C["X = +1"]
  B -- tails --> D["X = -1"]
  1. Define the variable. Heads gives X=+1X = +1, tails gives X=−1X = -1. Every outcome of the flip is now a number. Check: there are exactly two possible values, +1+1 and −1-1.

  2. Assign the probabilities. Each outcome of a fair coin has probability 1/21/2, so P(X=1)=1/2P(X = 1) = 1/2 and P(X=−1)=1/2P(X = -1) = 1/2. Check: 1/2+1/2=11/2 + 1/2 = 1, so the probabilities cover every outcome.

  3. Find the average. Multiply each value by its probability and add: (+1)(1/2)+(−1)(1/2)=0(+1)(1/2) + (-1)(1/2) = 0. In a long run of flips the running average settles near 0, as the law of large numbers says it must. Check: the positive and negative contributions cancel exactly.

  4. Find the spread. Every value squared is 1, because (+1)2=1(+1)^2 = 1 and (−1)2=1(-1)^2 = 1. So the average of X2X^2 is 1. The variance is 1−02=11 - 0^2 = 1. Check: each value sits exactly one unit from the mean of 0, so the typical squared distance is 1.

  5. Add several flips. Let S=X1+X2+X3+X4S = X_1 + X_2 + X_3 + X_4 for four independent flips. Each XkX_k has mean 0 and variance 1, so SS has mean 0 and variance 4. Its possible values are −4,−2,0,2,4-4, -2, 0, 2, 4. Check: each sign is odd, and a sum of four odd numbers is even, so SS can only be even.

Step 1 gives the definition, step 2 gives the rule, and steps 3 and 4 give the two numbers that the rest of the lesson uses. Step 5 shows why independent signs are useful: their sum spreads out in a predictable way.

The math

Definition: Rademacher distribution

A random variable XX has the Rademacher distribution when P(X=1)=P(X=−1)=12P(X = 1) = P(X = -1) = \tfrac{1}{2}. Its probability mass function is p(x)=12p(x) = \tfrac{1}{2} for x∈{−1,1}x \in \{-1, 1\}, and p(x)=0p(x) = 0 for every other value. We write X∼RadX \sim \mathrm{Rad}.

Here P(⋅)P(\cdot) means probability and E\mathbb{E} means expected value. The math below follows the steps above.

Step 2 in symbols: the probability mass function

The two values have probabilities p(−1)+p(1)=12+12=1p(-1) + p(1) = \tfrac{1}{2} + \tfrac{1}{2} = 1, as required.

Step 3 in symbols: the mean

E[X]=∑xx p(x)=(−1)⋅12+(1)⋅12=0.\mathbb{E}[X] = \sum_{x} x\, p(x) = (-1)\cdot\tfrac{1}{2} + (1)\cdot\tfrac{1}{2} = 0.

Step 4 in symbols: the variance

Since X2=1X^2 = 1 for both values, E[X2]=1\mathbb{E}[X^2] = 1. Then

Var(X)=E[X2]−(E[X])2=1−0=1.\mathrm{Var}(X) = \mathbb{E}[X^2] - (\mathbb{E}[X])^2 = 1 - 0 = 1.

The formula Var(X)=E[X2]−(E[X])2\mathrm{Var}(X) = \mathbb{E}[X^2] - (\mathbb{E}[X])^2 is the same as the one in mean and variance.

If BB is a Bernoulli variable with success probability 12\tfrac{1}{2}, then X=2B−1X = 2B - 1 is Rademacher. When B=1B = 1, X=1X = 1; when B=0B = 0, X=−1X = -1. This gives the same mean and variance by a different route. Since E[B]=12\mathbb{E}[B] = \tfrac{1}{2}, we get E[X]=2⋅12−1=0\mathbb{E}[X] = 2 \cdot \tfrac{1}{2} - 1 = 0. Since Var(B)=12⋅12=14\mathrm{Var}(B) = \tfrac{1}{2} \cdot \tfrac{1}{2} = \tfrac{1}{4}, we get Var(X)=22⋅14=1\mathrm{Var}(X) = 2^2 \cdot \tfrac{1}{4} = 1.

Step 5 in symbols: sums of independent signs

If X1,…,XnX_1, \dots, X_n are independent Rademacher variables and Sn=X1+⋯+XnS_n = X_1 + \dots + X_n, then the means add and the variances add, because the variables are independent. So E[Sn]=0\mathbb{E}[S_n] = 0 and Var(Sn)=n\mathrm{Var}(S_n) = n. The typical size of SnS_n is therefore about n\sqrt{n}. The central limit theorem makes this precise: Sn/nS_n / \sqrt{n} becomes close to a Gaussian as nn grows.

Worked examples

Example
Example 1: one flip (tiny)

Let XX be the sign of one fair coin flip, so XX is Rademacher.

  1. List the values and probabilities: X=−1X = -1 with probability 12\tfrac{1}{2}, and X=1X = 1 with probability 12\tfrac{1}{2}.
  2. Compute the mean: (−1)(12)+(1)(12)=−12+12=0(-1)(\tfrac{1}{2}) + (1)(\tfrac{1}{2}) = -\tfrac{1}{2} + \tfrac{1}{2} = 0.
  3. Compute X2X^2 for each value: (−1)2=1(-1)^2 = 1 and 12=11^2 = 1.
  4. Compute the second moment: E[X2]=1⋅12+1⋅12=1\mathbb{E}[X^2] = 1 \cdot \tfrac{1}{2} + 1 \cdot \tfrac{1}{2} = 1.
  5. Compute the variance: Var(X)=1−02=1\mathrm{Var}(X) = 1 - 0^2 = 1.

Interpretation: the sign has no tendency to lean either way, so the mean is 0, and every outcome is exactly one unit from that mean.

Example
Example 2: four flips added together (standard)

Let S=X1+X2+X3+X4S = X_1 + X_2 + X_3 + X_4 for four independent Rademacher variables. If KK is the number of plus signs among the four, then S=2K−4S = 2K - 4, and KK follows the binomial distribution, with probabilities (4K)/16\binom{4}{K}/16.

  1. Each value of KK gives one value of SS:
    • K=0K = 0: S=−4S = -4, probability 1/161/16.
    • K=1K = 1: S=−2S = -2, probability 4/164/16.
    • K=2K = 2: S=0S = 0, probability 6/166/16.
    • K=3K = 3: S=2S = 2, probability 4/164/16.
    • K=4K = 4: S=4S = 4, probability 1/161/16.
  2. Check the probabilities: 1+4+6+4+1=161 + 4 + 6 + 4 + 1 = 16, so they sum to 1.
  3. Compute the mean: (−4)(1)+(−2)(4)+0⋅6+2⋅4+4⋅1(-4)(1) + (-2)(4) + 0 \cdot 6 + 2 \cdot 4 + 4 \cdot 1, all divided by 16, which is (−4−8+8+4)/16=0(-4 - 8 + 8 + 4)/16 = 0.
  4. Compute E[S2]\mathbb{E}[S^2]: the squares are 16,4,0,4,1616, 4, 0, 4, 16, so E[S2]=(16⋅1+4⋅4+0⋅6+4⋅4+16⋅1)/16=64/16=4\mathbb{E}[S^2] = (16 \cdot 1 + 4 \cdot 4 + 0 \cdot 6 + 4 \cdot 4 + 16 \cdot 1)/16 = 64/16 = 4.
  5. Since the mean is 0, the variance is 44, which equals n=4n = 4, as step 5 of the walkthrough predicts.

Interpretation: four flips can land anywhere from −4-4 to 44, but the most likely total is 0, and the spread matches the count of flips.

Example
Example 3: one perturbation for three parameters (realistic)

The simultaneous perturbation method estimates a gradient by perturbing all parameters at once with a random Rademacher vector Δ=(Δ1,Δ2,Δ3)\Delta = (\Delta_1, \Delta_2, \Delta_3). Let ff be a loss function and θ\theta the current parameter vector, and let c=0.1c = 0.1 be the size of the perturbation. The estimate of the ii-th gradient component is

g^i=f(θ+cΔ)−f(θ−cΔ)2c Δi.\hat g_i = \frac{f(\theta + c\Delta) - f(\theta - c\Delta)}{2c\,\Delta_i}.
  1. Draw Δ=(1,−1,1)\Delta = (1, -1, 1). Each entry is plus or minus 1.
  2. Since Δi2=1\Delta_i^2 = 1, dividing by Δi\Delta_i gives the same result as multiplying by it, so 1/Δi=Δi1/\Delta_i = \Delta_i.
  3. Suppose that measuring the loss gives f(θ+cΔ)=10.8f(\theta + c\Delta) = 10.8 and f(θ−cΔ)=10.2f(\theta - c\Delta) = 10.2. The difference is 0.60.6.
  4. Divide the difference by 2c=0.22c = 0.2 to get 0.6/0.2=30.6 / 0.2 = 3. This is the common numerator for all three components.
  5. Divide by each Δi\Delta_i, which by step 2 is the same as multiplying: g^=(3⋅1,3⋅(−1),3⋅1)=(3,−3,3)\hat g = (3 \cdot 1, 3 \cdot (-1), 3 \cdot 1) = (3, -3, 3).

Interpretation: two loss measurements gave an estimate for all three components at once. The same two measurements would serve for a model with any number of parameters.

Try it: A model has 100 parameters. Using the same method, how many loss measurements does one gradient estimate need?

Answer: Two. The two measurements f(θ+cΔ)f(\theta + c\Delta) and f(θ−cΔ)f(\theta - c\Delta) are enough, because every parameter is perturbed in the same step.

Common mistakes and tradeoffs

It is tempting to think that a fair sign is the same as a fair coin with values 0 and 1. In fact the Rademacher values are −1-1 and 11, so the mean is 0. A Bernoulli variable with success probability one half has mean one half. The two are related by X=2B−1X = 2B - 1, but they are different variables.

It is tempting to think that the sum of nn signs is typically near nn or −n-n. In fact a sum of nn independent signs is typically of size about n\sqrt{n}, because positive and negative values cancel. The extreme values ±n\pm n occur only with probability 2/2n2/2^n.

It is tempting to think that a Rademacher variable is a Gaussian with a different name. In fact the Rademacher variable takes only two values, so it is bounded and discrete, while a Gaussian has no upper bound. Analysts often use Gaussian variables because the mathematics is smoother, and use Rademacher variables because they are cheap to generate and store.

When to use a Rademacher variable: the noise or perturbation should be symmetric and bounded, and each unit should carry the same magnitude, as in gradient estimation, random projections and symmetrisation arguments. When not to use one: the outcomes are not symmetric, the values should be spread over a range, or the model needs a continuous noise distribution. Alternatives: the Bernoulli distribution for yes or no outcomes, the uniform distribution for values spread evenly over an interval, and the Gaussian distribution when a smooth bell-shaped noise is needed.

History

Hans Rademacher, a German-American mathematician, studied sequences of functions that take the values plus and minus 1 in 1922. Those functions, now called Rademacher functions, became a standard example in the theory of orthogonal series, and the name of the distribution comes from them.

Probability theorists used random signs for symmetrisation arguments, where replacing each variable by a random sign simplified a proof. In 2002 Peter Bartlett and Shahar Mendelson used the same idea to define Rademacher complexity, a measure of how well a class of functions fits noise, which then became central to learning theory.

In 1992 James Spall proposed the simultaneous perturbation method for stochastic optimisation. Its random perturbation direction is a vector of random signs, which made the method cheap in high-dimensional problems.

Recap

  • A Rademacher variable takes the values +1+1 and −1-1 with probability one half each.
  • Its mean is 0 and its variance is 1, so every outcome lies one unit from the centre.
  • It is the same as a Bernoulli variable with probability one half, after the change X=2B−1X = 2B - 1.
  • Sums of nn independent signs have mean 0, variance nn, and typical size n\sqrt{n}.
  • Read next: Rademacher Complexity, which builds on random signs to measure how well a family of functions fits noise.

Check yourself

QuestionWhat are the possible values of a Rademacher variable, and what is the probability of each?Show answer

The possible values are +1+1 and −1-1. Each has probability one half, so the two probabilities add up to 1.

QuestionLet XX be Rademacher. Compute E[(X+1)2]\mathbb{E}[(X + 1)^2].Show answer

When X=1X = 1, X+1=2X + 1 = 2 and (X+1)2=4(X+1)^2 = 4. When X=−1X = -1, X+1=0X + 1 = 0 and (X+1)2=0(X+1)^2 = 0. The mean is 4⋅12+0⋅12=24 \cdot \tfrac{1}{2} + 0 \cdot \tfrac{1}{2} = 2.

QuestionWhy is dividing by a Rademacher sign the same as multiplying by it?Show answer

Each sign is +1+1 or −1-1, and in both cases its square is 1. Multiplying Δi\Delta_i by Δi\Delta_i gives Δi2=1\Delta_i^2 = 1, so Δi\Delta_i is its own reciprocal: 1/Δi=Δi1/\Delta_i = \Delta_i.

QuestionThree independent fair sign flips are added together to give SS. What is the probability that ∣S∣=1|S| = 1?Show answer

The possible values of SS are −3,−1,1,3-3, -1, 1, 3. The value S=1S = 1 needs two plus signs and one minus sign, which happens in (32)=3\binom{3}{2} = 3 of the 88 equally likely patterns. The value S=−1S = -1 needs two minus signs and one plus sign, which also happens in 3 patterns. So P(∣S∣=1)=6/8=3/4P(|S| = 1) = 6/8 = 3/4.

Sources