1.3.12 · D4Probability & Statistics

Exercises — Uniform, Exponential, and Beta distributions

2,486 words11 min readBack to topic

This page is a self-test. Try each problem with the solution hidden, then open the [!recall]- callout to check every step. Problems climb from L1 Recognition (just spot the right formula) up to L5 Mastery (stitch several ideas together). Every symbol used here is built in the parent note — if a piece feels unfamiliar, re-read that note first.

A one-screen reminder of the three toolkits, so nothing below is a surprise:


Level 1 — Recognition

Goal: read a word problem and pick the right distribution + plug into one formula.

L1.1 — Which distribution?

A bus is equally likely to arrive at any minute between 10:00 and 10:15. You want the chance it comes in the first 5 minutes. Name the distribution and its parameters, then compute measuring time in minutes after 10:00.

Recall Solution

WHAT distribution? "Equally likely at any point of an interval" is the signature of the Uniform. Measuring minutes after 10:00, the interval is , so .

WHY the CDF? is exactly what the CDF answers — "how much probability has piled up by the point ." So a chance.

Read the figure below: the teal rectangle is the whole uniform density — its full area is exactly . The burnt-orange shaded slab covers only the first of the minutes, so it captures one third of the width and (because the height is constant) one third of the area. That shaded area is . The dashed callout points at the constant height .

Figure — Uniform, Exponential, and Beta distributions

L1.2 — Reading a rate

Emails arrive at your inbox at rate per hour, as a Poisson process. What is the average waiting time between emails, and the standard deviation of that wait?

Recall Solution

WHAT distribution? "Time until the next event in a Poisson process" is the Exponential, (rate in emails per hour).

Mean: hour minutes. Variance: , so hour minutes.

WHY mean = std here? For the exponential these are always equal () — a fingerprint of this distribution.

L1.3 — Beta = Uniform special case

Show that is the same as by evaluating its PDF.

Recall Solution

Put into . The exponents become . The normaliser is . So for — a flat line of height 1, exactly . WHY it matters: "no data yet" (0 pseudo-successes, 0 pseudo-failures) means total ignorance, and total ignorance is the flat uniform.


Level 2 — Application

Goal: run the formula machinery — integrate, invert a CDF, use two parameters.

L2.1 — Uniform expectation of a function

. Find by direct integration, and confirm it matches .

Recall Solution

The density is on . Check: , . Then . ✓ They agree, as the identity guarantees.

L2.2 — Percentile of an exponential

A component's lifetime is with mean hours. Find the median lifetime (the time by which half the components have failed).

Recall Solution

Rate from the mean: per hour. Median solves : WHY median < mean? The exponential is right-skewed: a few very long lifetimes drag the mean () above the median (). Half the parts die before h even though the average is h.

L2.3 — Beta mean and mode

You model a click-through rate as . Give the mean and the mode, and say which side of the peak leans toward.

Recall Solution

Mean: Mode (valid since ): Both are below , so the bump leans toward — sensible, because pseudo-failures outnumber pseudo-successes, so we believe the true rate is low.

Read the figure below: the plum curve is the density. The teal dashed line marks the mode (the top of the hump — the single most likely rate), and the burnt-orange dashed line marks the mean (the balance point). Notice the mean sits to the right of the mode: the long tail stretching toward pulls the average up, which is the visual signature of a right-skewed Beta.

Figure — Uniform, Exponential, and Beta distributions

Level 3 — Analysis

Goal: reason about why, prove a property, compare two setups.

L3.1 — Memorylessness in numbers

A server's request-gap is with per second. You have already waited second with no request. What is the probability you wait at least more seconds? Compare it to the unconditional .

Recall Solution

Conditional (waited 1s already): use the memoryless property with : Unconditional: — identical. WHY identical? The exponential "forgets" the elapsed second; the future wait resets as if the clock just started. This is the only continuous distribution with that property, which is why constant-hazard models (radioactive decay, bandit arrival gaps) use it.

L3.2 — Why variance shrinks as Beta gets confident

For the variance is . Take a fixed mean of (so ) and show the variance as . Evaluate at .

Recall Solution

Set . Then

  • (this is exactly 's variance!).
  • As , : the belief piles up into a thin spike at . Interpretation: more pseudo-data (bigger ) = more confidence = narrower distribution — the mathematical face of "the more evidence, the surer we are."

Level 4 — Synthesis

Goal: combine multiple tools; a Bayesian update, or a transform between distributions.

L4.1 — One Bayesian coin update, start to finish

Your prior belief about a coin's heads-probability is . You then flip and see 7 heads and 3 tails. Find the posterior distribution of , its mean, and its mode. This is the conjugate-prior update from Bayesian Inference and Conjugate Priors.

Recall Solution

The conjugate rule: with a prior and Binomial data of heads, tails, the posterior is simply — you add the counts. WHY it works: the Beta PDF and the likelihood multiply into — the same Beta shape.

Here : Mean: Mode: The belief has moved from a symmetric hump at toward the observed heads-rate , but not all the way — the prior "pseudo-data" pulls it back a little (this is regularisation in disguise).

Read the figure below: the teal curve is the flat-ish prior centred at ; the plum curve is the posterior , taller, narrower, and shifted right. The dotted burnt-orange line marks the raw observed rate . See how the posterior peak lands just short of : the prior tugs the belief back toward , so the update is a compromise between prior and data.

Figure — Uniform, Exponential, and Beta distributions

L4.2 — Sampling exponential from uniform (inverse-CDF)

Monte Carlo code needs exponential samples but the RNG only gives . Derive the transform that turns a uniform draw into an draw, and test it: with and , what is ?

Recall Solution

The idea (inverse-transform): if , then has CDF . So set the exponential CDF equal to and solve for : Since is also uniform on , the common shortcut is .

Domain edge-cases — why we require (open interval):

  • As , and , so — the rare, very long waits live here (that is correct: the exponential has an infinite tail).
  • As , and , so — the near-instant waits.
  • The endpoints and would give exactly or ; a good RNG returns values strictly inside , which is why we treat as living on the open interval and never actually hit those degenerate points.

Test (, using the derived form with ): Sanity check: is the median of the uniform, so it should map to the median of the exponential, which from L2.2 is . ✓


Level 5 — Mastery

Goal: a multi-step, open-ended problem that welds distributions, calculus, and ML meaning.

L5.1 — Xavier init: from a variance target back to interval bounds

Xavier init wants a layer's weights to have variance with inputs, drawn from a symmetric uniform . (a) Solve for the half-width . (b) State the PDF height. (c) A downstream layer instead samples waiting-time "dropout gaps" as and wants those gaps to have the same variance as the weights; find . Explain in one line why the exponential's mean is then forced.

Recall Solution

(a) Half-width. For the range is , so Set this to : (Note: this equals the classic Xavier bound .)

(b) PDF height. The uniform density is . Substitute : for and elsewhere. So the exact height is .

(c) Matching variance with an exponential. Exponential variance is . Setting it equal to the weight variance : WHY the mean is then forced: for the exponential and , so always — the variance and the squared mean are the same quantity. Fixing the variance to therefore fixes and, with it, pins the mean to . You cannot choose spread and centre independently for an exponential (one parameter controls both), unlike the uniform where you could slide the interval sideways to move the mean without touching the variance.


Recall Quick self-quiz (cover the answers)

Uniform variance ::: Exponential CDF ::: Exponential mean and variance relationship ::: (both ) Beta mean ::: Conjugate update after heads, tails ::: Uniform-to-exponential transform :::

See also: Maximum Likelihood Estimation · Continuous Random Variables and PDFs · Bayesian Inference and Conjugate Priors · the Hinglish version.