From outcomes to random variables

Program a numerical rule on physical card outcomes, group probability mass and recover events from output values.

24 minutes · intermediate · Original Poker4Quant lesson

What you will learn

Construct a finite random variable and its induced distribution while keeping the outcome mechanism, numerical function and event distinct.

Prerequisites: Equally likely outcomes · Unequal outcome weights

A random variable is a rule, not an extra shuffle

An experiment produces an outcome ω in a sample space Ω. A real-valued random variable X assigns one number X(ω) to each outcome. The rule is fixed before the outcome is known. Randomness comes from which outcome occurs, not from the function changing its mind. We use finite spaces here; continuous distributions require additional machinery.

A physical card includes its suit as well as rank. In the toy deck J♥, J♠, Q♦, K♣, the two jacks remain different outcomes even if the rule assigns both the same number. X = rank − 11 maps them to 0, the queen to 1 and the king to 2. Once a card is known, its output is determined. A different rule, such as red = 3 and black = −1, can be applied to exactly the same experiment.

The distribution collects mass from inverse images

For each output x, collect every physical outcome that maps to x. This set is the inverse image {ω: X(ω)=x}. The probability mass function is pX(x) = P(X=x), the sum of the original probabilities of those outcomes. Do not replace the original probabilities with equal weights on distinct output labels.

Under a uniform one-card draw from the four-card toy deck, X = rank − 11 has pX(0)=2/4, pX(1)=1/4 and pX(2)=1/4. The three possible numbers are not equally likely. The inverse-image sets are disjoint and cover the sample space, so their masses add to one. A wrong function can also yield a normalized distribution: normalization is necessary, not proof that you implemented the stated rule.

Keep the mechanism when the labels look symmetric

Now stipulate one-card probabilities 1/8, 4/8, 1/8, 2/8 for J♥, J♠, Q♦, K♣. This is a supplied weighted model, not what an ordinary uniform shuffle of these cards produces. For X=3 on red and −1 on black, pX(3)=2/8 and pX(−1)=6/8. Counting two red and two black labels and reporting one half would discard the mechanism.

The expectation E[X] is the probability-weighted sum of numerical outputs. Here it is 3(2/8)−1(6/8)=0. Zero mean does not mean every outcome is zero, that the two outputs have equal probability, or that a single draw is likely to equal its mean. These scores are numbers used to study a mapping, not gambling payouts or a profit claim.

Transform first; then ask which event you mean

For an event such as X≥1, recover every original outcome whose output satisfies the inequality. This inverse image lets you calculate its probability even when different outcomes share an output. In the uniform rank-offset example the event contains Q♦ and K♣, mass one half. The point event X=1 contains only Q♦, mass one quarter. An inequality and a point are different questions.

A nonlinear function can group outcomes unevenly even when all original outcomes are equally likely. Draw an unordered pair without replacement from the same four cards. There are six physical pairs, each mass 1/6. Let X=max(rank)−10. The pair of jacks gives 1; the two jack–queen pairs give 2; the two jack–king pairs and queen–king pair give 3. The induced masses are 1/6, 2/6, 3/6 and the mean is 7/3.

The activity makes you program each physical output, execute the function, route its original mass packet and construct an inverse-image event. Matching only a mean or even the full probability law is insufficient to identify a function: swapping the two equal-mass outputs 1 and 2 in the first model preserves the law but changes which card produces which number. Source references support the definitions; these card rules, examples and game are original.

Worked example

Uniformly draw an unordered pair from J♥, J♠, Q♦, K♣. For X=max(rank)−10, find P(X=3) and E[X].

  1. List six physical pairs: J♥J♠, J♥Q♦, J♥K♣, J♠Q♦, J♠K♣, Q♦K♣. Do not collapse the two jacks.
  2. Apply the rule to obtain outputs 1,2,3,2,3,3. Every pair has mass 1/6.
  3. The inverse image of 3 is the three pairs containing K♣; add their masses to get 3/6.
  4. Weight each output by its multiplicity: (1×1 + 2×2 + 3×3)/6 = 14/6.

P(X=3)=1/2 and E[X]=7/3. The three output labels are not a uniform distribution; the mean need not be an attainable output.

Hands-on: Program outcomes and route their probability mass

Implement three physical-card functions, conserve original mass packets, construct inverse-image events and audit weighted means.

Reading mapping workshop…

Common mistakes

  • Collapsing distinct physical outcomes before assigning their probability mass.
  • Assuming every numerical output is equally likely because the original outcomes are uniform.
  • Treating a normalized PMF as proof that every outcome was mapped correctly.
  • Counting labels instead of weights under the explicitly unequal mechanism.

Keep these ideas

  • Specify the experiment and its probabilities before defining X.
  • Apply the rule to every physical outcome, then add mass for equal outputs.
  • Recover events by selecting all original outcomes satisfying the output condition.
  • A distribution or mean summarizes a function without uniquely identifying it.

Further reading

Check your understanding

Untimed · 3 checks · Guest progress stays in this browser. Sign in to save account snapshots.

Loading saved lesson…

Take the track assessment →