1.3.6 · D4Probability & Statistics

Exercises — Probability mass and density functions

2,005 words9 min readBack to topic

This page is a self-test ladder. Each rung is harder than the last:

  • L1 Recognition — can you spot which object (PMF or PDF) you are looking at?
  • L2 Application — can you plug into the defining formulas?
  • L3 Analysis — can you reason about area, normalization, and edge cases?
  • L4 Synthesis — can you combine PMF/PDF with the CDF, expectation, and named families?
  • L5 Mastery — can you build new distributions and connect them to real ML machinery like softmax and maximum likelihood?

Everything you need was built in the parent note Probability mass and density functions. Try each problem with the solution collapsed, then open it.


Level 1 — Recognition

L1.1

A function is given as a table:

0 1 2
0.2 0.5 0.3

Is a valid PMF? Answer yes/no and say why.

Recall Solution L1.1

A valid PMF must satisfy two things, both from the parent definition:

  1. Every height is between and : here all lie in . ✓
  2. The heights sum to exactly : . ✓

Both hold, so yes, is a valid PMF. Notice we only added the values — for a discrete variable each height already is a probability, so summing them is the whole test.

L1.2

A curve is given by for and elsewhere. Someone panics: "But , that can't be a probability!" Are they right that is invalid?

Recall Solution L1.2

They are wrong. is a candidate PDF, and a PDF is a density, not a probability — it is allowed to exceed . The only tests are:

  1. everywhere: and . ✓
  2. Total area equals : The height being is fine because the region is only wide; height width . Look at figure below: a tall-but-narrow rectangle can still enclose area .
Figure — Probability mass and density functions

Level 2 — Application

L2.1

is the sum of two fair dice (same setup as the parent note). Compute and .

Recall Solution L2.1

Each ordered pair has probability . : pairs summing to are — that is outcomes. : add masses for . Counts: sum has way, sum has ways, sum has ways. We summed masses — legal because the events are disjoint (a single roll gives one sum), so their probabilities add.

L2.2

is uniform on , so for and elsewhere. Find and .

Recall Solution L2.2

A PDF gives probability by area (integration): For a single point: because the strip from to has zero width, hence zero area. This is the "points have zero probability" property in action.


Level 3 — Analysis

L3.1

A candidate PDF is for , and elsewhere. Find the constant that makes it valid, then compute .

Recall Solution L3.1

Normalization forces the total area to be . Why this tool (an integral)? Because for a density, "total probability" is the area under the whole curve: Setting gives . Check : on . ✓ (A rising triangle — see figure.)

: integrate from to : More area sits on the right because the density grows with — bigger values are more likely here.

Figure — Probability mass and density functions

L3.2

For the exponential PDF (with , ), find using the CDF .

Recall Solution L3.2

The CDF already is the accumulated area from to , so no new integral is needed: Interpretation: with rate , roughly of waits are under one time unit — the decay makes long waits rare.


Level 4 — Synthesis

L4.1

is Bernoulli with , . Using the compact PMF , compute the expected value from the definition , with .

Recall Solution L4.1

Expectation weights each value by its mass: With : . The term vanishes (multiplied by ), so the mean of a Bernoulli is simply its success probability. This is why in maximum likelihood the fitted turns out to be the observed fraction of successes.

L4.2

is uniform on (from L2.2). Find its CDF for all real — covering all three regions (, , ).

Recall Solution L4.2

The CDF is accumulated area . We must cover every case:

  • : no density yet, area . So .
  • : area of a rectangle of height and width : .
  • : all probability already accumulated: . Differentiating the middle piece returns , confirming the PDF–CDF link. See the ramp figure.
Figure — Probability mass and density functions

Level 5 — Mastery

L5.1

Two logits (raw scores) from a classifier are and . The softmax turns them into a PMF over two classes: Compute the PMF and verify it is a valid PMF.

Recall Solution L5.1

Exponentiate each logit (this is what makes every value positive): Denominator: . Then Validity: each and by construction (the denominator is the sum of numerators). Softmax is literally a machine for turning arbitrary scores into a legal PMF over classes — the discrete cousin of everything in this note.

L5.2

Build a brand-new distribution: the density on (zero elsewhere). (a) Find . (b) Argue from symmetry what is, then confirm by integration.

Recall Solution L5.2

(a) Normalize. Total area must be : Set . Check : on . ✓ (A dome — see figure.)

(b) Symmetry argument. The density is even () and centered at , so probability mass balances around ; the mean must be . Confirm: The integrand is odd, so its integral over a symmetric interval is . Hence , matching the symmetry argument.

Figure — Probability mass and density functions

Recall Quick self-check clozes

A PMF value is itself a probability so it must lie in . A PDF value is a density (probability per unit length) so it may exceed . For a continuous variable, equals ::: , because the integrating strip has zero width. To get a probability from a PDF you must ::: integrate over an interval (take the area). The first step whenever a PDF has an unknown constant is ::: set the total integral equal to 1 (normalize).

Related families and machinery: random variables, common distributions, Gaussian processes, and the Hinglish companion 1.3.06 Probability mass and density functions (Hinglish).