Concepts / Random Variables

Random Variables

The main reading rule is: D describes the distribution, and z ∼ D describes the relationship between the variable z and that distribution.

  • Programming

From Distribution to Sample

Random-variable notation becomes easier when you read it from the distribution outward. Start with D: it names a probability distribution over a set Z. Then read z ∼ D as a sampling statement: z is obtained by sampling according to D. The symbol z does not identify one permanently fixed value. It represents a value whose source is the distribution D.

Ddistribution over Zz₁probability under Dz₂probability under Dz₃probability under Dsamplingsamplingsampling
How does a distribution D produce a sampled value z, and what does it mean for each possible z to have a corresponding probability?
Key point

The main reading rule is: D describes the distribution, and z ∼ D describes the relationship between the variable z and that distribution.

Reading D and z ∼ D

Imagine that D describes how values are selected from a set Z. Writing z ∼ D tells you to regard z as a value obtained by sampling from D. It does not select one permanently fixed value in advance. Instead, it establishes a sampling convention that later expressions can use.

Worked example

Following the Sampling Convention

Suppose D is a distribution over a set Z, and write z ∼ D. What does a later expression involving z mean?

  1. 1
    1. Identify D

    D is the distribution that governs how values are selected from Z.

  2. 2
    2. Interpret z ∼ D

    The variable z is regarded as a value sampled according to D.

  3. 3
    3. Use z later

    A later function, event, or expectation involving z is evaluated with respect to that sampling convention.

Result

The notation does not describe a fixed value of z. It describes where z comes from and which distribution governs reasoning about it.

Two Questions About a Sample

Once z is understood as sampled from D, later notation can ask different kinds of questions. Expected-value notation summarizes a real-valued function of the sampled variable. Probability notation for an event summarizes how often a Boolean condition is true.

E_{z ∼ D}[f(z)]expected value of areal-valued functionreal valuesummary of f(z)Pr_{z ∼ D}[f(z)]probability that a Booleancondition is trueprobabilitychance the condition istruesummarizesmeasures
What is the difference between averaging a numeric random variable, such as E[z], and measuring the chance of an event, such as Pr[z ∈ A]?
NotationWhat it describesWhat to ask
E_{z ∼ D}[f(z)]The expected value of a real-valued function of zWhat value does f(z) summarize on average under D?
Pr_{z ∼ D}[f(z)]The probability that a Boolean condition is trueHow often is the condition f(z) true under D?

Both expressions use the same sampling context, but they summarize different kinds of information.

Worked example

Separating an Average from an Event

Read the difference between E_{z ∼ D}[f(z)] and Pr_{z ∼ D}[f(z)].

  1. 1
    Expected value

    In E_{z ∼ D}[f(z)], f is treated as a real-valued function. The notation summarizes the expected value of the result of applying f to a sample from D.

  2. 2
    Event probability

    In Pr_{z ∼ D}[f(z)], f is treated as a Boolean condition. The notation summarizes the probability that the condition is true for a sample from D.

  3. 3
    Context shorthand

    When the dependence on z and its distribution is already clear, E[f] may be used as shorter notation for the same expected quantity.

Result

Expected-value notation averages a real-valued result; probability notation measures the chance that a condition holds.

Building D^m

A single sampled variable is not the only object that can have a distribution. If m points are sampled from D, the resulting object is an m-component tuple written as (z₁, …, zₘ). The notation Dm refers to the probability over the larger space Zm induced by this sampling process.

Ddistribution over Zz₁sampled from D(z₁, …, zₘ)point in Z^m D^m probability over Z^m z₂sampled independently fromDzₘsampled independently fromDdraw 1draw 2draw mcombinecombinecombineinduces
What does Dm represent, and how do m separate independent draws from D become a sample tuple?
Worked example

Interpreting Dm

Suppose m points are sampled from D independently. What object is described by Dm?

  1. 1
    1. Make individual draws

    Each component zᵢ is sampled from D.

  2. 2
    2. Form the tuple

    The individual samples are collected as (z₁, …, zₘ), an m-component point in Zm.

  3. 3
    3. Identify the induced distribution

    Dm describes the probability over these m-component tuples that is induced by the independent sampling process.

Result

D governs individual samples from Z, while Dm governs the larger space Zm of m-component sample tuples.

Common Reading Errors

  • Common mistake

    Treating z ∼ D as if it named one permanently fixed value.

    What it looks like

    Reading z ∼ D as though z had been selected once and would no longer depend on the sampling convention.

    Why it fails

    The notation tells you that z is regarded as a value obtained by sampling from D.

    Do this instead

    Keep the distribution context active whenever you interpret a later expression involving z.

  • Common mistake

    Confusing an expected value with an event probability.

    What it looks like

    Assuming E_{z ∼ D}[f(z)] and Pr_{z ∼ D}[f(z)] ask the same question.

    Why it fails

    Expected value summarizes a real-valued function, whereas probability notation summarizes when a Boolean condition is true.

    Do this instead

    Check whether the expression is averaging a numeric result or measuring the chance that a condition holds.

  • Common mistake

    Interpreting Dm as another individual sample from D.

    What it looks like

    Reading the superscript m as if it changed the name of one sampled value.

    Why it fails

    Dm describes a probability over m-component tuples in Zm produced by independent sampling.

    Do this instead

    Expand the notation mentally as separate samples z₁ through zₘ collected into the tuple (z₁, …, zₘ).

  • Common mistake

    Ignoring the distribution subscript in an expectation.

    What it looks like

    Treating E_{z ∼ D}[f(z)] as though the subscript were decorative.

    Why it fails

    The subscript identifies the distribution governing the variable inside the brackets.

    Do this instead

    Use the subscript to identify which sampling process determines the expected value, unless the context already makes it clear.

Practice the Notation

MEDIUM

For each expression, identify whether it describes a sampled variable, an expected value, an event probability, or a distribution over tuples: z ∼ D; E_{z ∼ D}[f(z)]; Pr_{z ∼ D}[f(z)]; D^m.

Hints
  • Start by identifying the role of D.
  • For the expressions with brackets, ask whether the inside describes a real-valued function or a Boolean condition.
  • For Dm, look for the larger space and the tuple produced by repeated sampling.
Worked example

Practice Answer

Classify z ∼ D, E_{z ∼ D}[f(z)], Pr_{z ∼ D}[f(z)], and D^m.

  1. 1
    z ∼ D

    This states that z is sampled according to D.

  2. 2
    E_{z ∼ D}[f(z)]

    This is an expected-value expression for a real-valued function of a sample from D.

  3. 3
    Pr_{z ∼ D}[f(z)]

    This is an event-probability expression for the condition f(z) being true under the sampling convention.

  4. 4
    Dm

    This is the induced probability over m-component tuples in Zm formed from independent samples from D.

Result

The notation changes meaning according to whether it establishes sampling, summarizes numeric values, measures a Boolean event, or describes repeated sampling over tuples.

Key Takeaways

  1. 1
    D is a probability distribution over a set Z.
  2. 2
    z ∼ D says that z is sampled according to D; it does not identify one permanently fixed value.
  3. 3
    E_{z ∼ D}[f(z)] summarizes the expected value of a real-valued function of the sampled variable.
  4. 4
    Pr_{z ∼ D}[f(z)] summarizes the probability that a Boolean condition is true.
  5. 5
    Dm describes the induced probability over m-component tuples in Zm formed by independent sampling from D.

At a glance

  • Read D first: it names the distribution over the set Z.
  • Read z ∼ D as a sampling relationship between z and D.
  • Separate expected-value notation from event-probability notation by asking whether the expression summarizes a real-valued result or a Boolean condition.
  • Interpret Dm as the probability over m-component tuples induced by independent samples from D.

Related concepts

More concepts starting with R