1.3.12Probability & Statistics

Uniform, Exponential, and Beta distributions

3,226 words15 min readdifficulty · medium

Core Intuition

The Uniform Distribution

Derivation from First Principles

WHY uniform? We want "no preference"—the probability density must be constant across [a,b][a, b] and zero elsewhere.

WHAT does that mean mathematically? Let the constant density be cc. Since probability must integrate to 1:

abcdx=1\int_{a}^{b} c \, dx = 1

HOW do we solve?

c(ba)=1    c=1bac \cdot (b - a) = 1 \implies c = \frac{1}{b-a}

Key Properties (Derived)

Expected Value:

E[X]=abx1badx=1bax22ab=1bab2a22=b+a2E[X] = \int_{a}^{b} x \cdot \frac{1}{b-a} \, dx = \frac{1}{b-a} \cdot \frac{x^2}{2} \Big|_a^b = \frac{1}{b-a} \cdot \frac{b^2 - a^2}{2} = \frac{b+a}{2}

WHY? The mean is exactly the midpoint—makes sense for a symmetric distribution!

Variance:

E[X2]=abx21badx=1bax33ab=b3a33(ba)=a2+ab+b23E[X^2] = \int_{a}^{b} x^2 \cdot \frac{1}{b-a} \, dx = \frac{1}{b-a} \cdot \frac{x^3}{3} \Big|_a^b = \frac{b^3 - a^3}{3(b-a)} = \frac{a^2 + ab + b^2}{3}

Var(X)=E[X2](E[X])2=a2+ab+b23(a+b)24=(ba)212\text{Var}(X) = E[X^2] - (E[X])^2 = \frac{a^2 + ab + b^2}{3} - \frac{(a+b)^2}{4} = \frac{(b-a)^2}{12}

WHY this matters? Variance grows with the square of the range—wider intervals mean more uncertainty.

Figure — Uniform, Exponential, and Beta distributions

The Exponential Distribution

Derivation from Poisson Process

WHY exponential? In a Poisson process, events are independent and occur at constant rate λ\lambda. What's the probability that NO events occur in time tt?

From Poisson distribution: P(0 events in time t)=eλtP(\text{0 events in time } t) = e^{-\lambda t}

WHAT is the CDF? The probability that the first event occurs BEFORE time tt is:

F(t)=P(Tt)=1P(T>t)=1eλtF(t) = P(T \leq t) = 1 - P(T > t) = 1 - e^{-\lambda t}

HOW do we get the PDF? Differentiate the CDF:

f(t)=ddtF(t)=ddt(1eλt)=λeλtf(t) = \frac{d}{dt}F(t) = \frac{d}{dt}(1 - e^{-\lambda t}) = \lambda e^{-\lambda t}

The Memoryless Property

CLAIM: P(T>s+tT>s)=P(T>t)P(T > s + t \mid T > s) = P(T > t)

WHY is this profound? "If you've waited ss time units without an event, the probability of waiting another tt is the same as if you just started." The process "forgets" the past.

Proof:

P(T>s+tT>s)=P(T>s+t)P(T>s)=eλ(s+t)eλs=eλt=P(T>t)P(T > s+t \mid T > s) = \frac{P(T > s+t)}{P(T > s)} = \frac{e^{-\lambda(s+t)}}{e^{-\lambda s}} = e^{-\lambda t} = P(T > t)

WHERE does this matter? Exponential is the ONLY continuous distribution with this property. Models radioactive decay, time between server requests, or failure of components with constant hazard rate.

Deriving the Mean:

E[T]=0tλeλtdtE[T] = \int_0^\infty t \cdot \lambda e^{-\lambda t} \, dt

Use integration by parts: u=tu = t, dv=λeλtdtdv = \lambda e^{-\lambda t} dt

=[teλt]0+0eλtdt=0+1λ=1λ= \left[-t e^{-\lambda t}\right]_0^\infty + \int_0^\infty e^{-\lambda t} \, dt =0 + \frac{1}{\lambda} = \frac{1}{\lambda}

WHY this makes sense? If events happen at rate λ=5\lambda = 5 per hour, average time between events is 15\frac{1}{5} hour = 12 minutes.

The Beta Distribution

Derivation from the Conjugate Prior Perspective

WHY does Beta exist? Suppose we flip a coin with unknown bias pp. After observing α1\alpha - 1 heads and β1\beta - 1 tails, what distribution describes our belief about pp?

WHAT form should it take? We want:

  1. Support on [0,1][0, 1] (since pp is a probability)
  2. Flexibility to represent different beliefs (uniform ignorance, strong certainty, etc.)
  3. Mathematical convenience (conjugate to Binomial)

The Beta function normalizes the distribution:

B(α,β)=01xα1(1x)β1dx=Γ(α)Γ(β)Γ(α+β)B(\alpha, \beta) = \int_0^1 x^{\alpha-1}(1-x)^{\beta-1} \, dx = \frac{\Gamma(\alpha)\Gamma(\beta)}{\Gamma(\alpha+\beta)}

where Γ(n)=(n1)!\Gamma(n) = (n-1)! for integers.

Understanding Shape via Parameters

HOW do α\alpha and β\beta control the shape?

  • α=β=1\alpha = \beta = 1: Beta(1,1)=Uniform(0,1)\text{Beta}(1, 1) = \text{Uniform}(0, 1) — total ignorance
  • α>β\alpha > \beta: Distribution skewed toward 1 (more successes observed)
  • α<β\alpha < \beta: Distribution skewed toward 0 (more failures observed)
  • α,β>1\alpha, \beta > 1: Unimodal (single peak)
  • α,β<1\alpha, \beta < 1: U-shaped (bimodal, certainty near extremes)
  • Large α,β\alpha, \beta: Narrow distribution (high confidence)

Deriving the Mean:

E[X]=01xxα1(1x)β1B(α,β)dx=1B(α,β)01xα(1x)β1dxE[X] = \int_0^1 x \cdot \frac{x^{\alpha-1}(1-x)^{\beta-1}}{B(\alpha, \beta)} \, dx = \frac{1}{B(\alpha, \beta)} \int_0^1 x^\alpha (1-x)^{\beta-1} \, dx

The integral is B(α+1,β)B(\alpha+1, \beta):

=B(α+1,β)B(α,β)=Γ(α+1)Γ(β)/Γ(α+β+1)Γ(α)Γ(β)/Γ(α+β)= \frac{B(\alpha+1, \beta)}{B(\alpha, \beta)} = \frac{\Gamma(\alpha+1)\Gamma(\beta)/\Gamma(\alpha+\beta+1)}{\Gamma(\alpha)\Gamma(\beta)/\Gamma(\alpha+\beta)}

=αΓ(α)(α+β)Γ(α+β)=αα+β= \frac{\alpha \cdot \Gamma(\alpha)}{(\alpha+\beta) \cdot \Gamma(\alpha+\beta)} = \frac{\alpha}{\alpha+\beta}

WHY this makes sense? If you observe α1\alpha-1 heads and β1\beta-1 tails, you expect the true probability to be near α1α+β2\frac{\alpha-1}{\alpha+\beta-2}, which for large counts approaches αα+β\frac{\alpha}{\alpha+\beta}.

Connections Between the Three

Property Uniform(a,b)(a, b) Exponential(λ)(\lambda) Beta(α,β)(\alpha, \beta)
Support [a,b][a, b] [0,)[0, \infty) [0,1][0, 1]
Use case No prior info Waiting times Probabilities
Memoryless? No Yes No
Shape Constant Decreasing Flexible
Special cases Uniform(0,1)(0,1) = Beta(1,1)(1,1) Exp(1)(1) = Gamma(1,1)(1,1) Beta(1,1)(1,1) = Uniform

Recall Feynman Explanation (for a12-year-old)

Imagine you have three magic dice: The Flat Die (Uniform): Every number has the exact same chance. Like a perfectly fair spinner—no cheating, every spot equally likely. We use this when we have zero information and want to be completely fair.

The Forgetful Die (Exponential): This models waiting. Like waiting for the next bus. The weird thing? It doesn't matter how long you've waited—your chance of the bus coming in the next minute is ALWAYS the same. It's like the universe has amnesia! This works for things like radioactive atoms decaying or customers arriving at a store randomly.

The Belief Die (Beta): This one is about guessing probabilities. Imagine you're trying to figure out if a coin is fair. You flip it a few times. The Beta distribution describes how confident you are about what the true "heads probability" is. Get more data? The Beta updates, becoming more confident and accurate. It's like your brain getting smarter with each flip!


Connections


#flashcards/ai-ml

What are the support (valid ranges) for Uniform, Exponential, and Beta distributions? :: Uniform: [a,b][a, b] (finite interval), Exponential: [0,)[0, \infty) (non-negative reals), Beta: [0,1][0, 1] (unit interval)

What is the PDF of Uniform(a,b)(a, b)?
f(x)=1baf(x) = \frac{1}{b-a} for axba \leq x \leq b, zero otherwise. The constant ensures total probability = 1.

What is the mean and variance of Uniform(a,b)(a, b)? :: Mean: a+b2\frac{a+b}{2} (midpoint), Variance: (ba)212\frac{(b-a)^2}{12} (grows with square of range)

What is the memoryless property of the exponential distribution?
P(T>s+tT>s)=P(T>t)P(T > s+t \mid T > s) = P(T > t) — probability of waiting additional time tt is independent of how long you've already waited.
What is the PDF of Exponential(λ)(\lambda)?
f(t)=λeλtf(t) = \lambda e^{-\lambda t} for t0t \geq 0, where λ\lambda is the rate parameter (events per unit time).
What is the relationship between rate λ\lambda and mean waiting time in Exponential?
Mean E[T]=1λE[T] = \frac{1}{\lambda}. Higher rate → shorter average wait. If λ=4\lambda = 4 events/hour, average wait is 14\frac{1}{4} hour = 15 minutes.
What is the CDF of Exponential(λ)(\lambda)?
F(t)=1eλtF(t) = 1 - e^{-\lambda t} for t0t \geq 0. Used to find probability of event occurring within time tt.
What is the PDF of Beta(α,β)(\alpha, \beta)?
f(x)=1B(α,β)xα1(1x)β1f(x) = \frac{1}{B(\alpha, \beta)} x^{\alpha-1}(1-x)^{\beta-1} for x[0,1]x \in [0,1], where B(α,β)=Γ(α)Γ(β)Γ(α+β)B(\alpha, \beta) = \frac{\Gamma(\alpha)\Gamma(\beta)}{\Gamma(\alpha+\beta)} is the normalizing Beta function.
What is the mean of Beta(α,β)(\alpha, \beta)?
E[X]=αα+βE[X] = \frac{\alpha}{\alpha + \beta}. If α=5,β=3\alpha = 5, \beta = 3, mean = 58=0.625\frac{5}{8} = 0.625.
How does Beta(α,β)(\alpha, \beta) update with new Binomial data?
If prior is Beta(α,β)(\alpha, \beta) and you observe kk successes in nn trials, posterior is Beta(α+k,β+nk)(\alpha + k, \beta + n - k). This is conjugacy!
What does Beta(1,1)(1, 1) equal?
Uniform(0,1)(0, 1). It represents complete ignorance about a probability—every value [0,1][0,1] equally likely.
What happens to Beta(α,β)(\alpha, \beta) shape when both parameters are large?
Distribution becomes more concentrated (lower variance), representing high confidence. Example: Beta(100,100)(100, 100) is tightly peaked at 0.5.
What does α>β\alpha > \beta indicate in Beta(α,β)(\alpha, \beta)?
Distribution skewed toward 1 (right-skewed), indicating more evidence for successes than failures. Mean >0.5> 0.5.
Why is Uniform(0,1)(0,1) important in simulation?
Most random number generators produce Uniform(0,1)(0,1) samples. These can be transformed to ANY other distribution using inverse transform sampling: X=F1(U)X = F^{-1}(U) where UUniform(0,1)U \sim \text{Uniform}(0,1).
What is the mode of Beta(α,β)(\alpha, \beta) when α,β>1\alpha, \beta > 1?
Mode =α1α+β2= \frac{\alpha - 1}{\alpha + \beta - 2}. This is the peak of the distribution, the most likely value.
Why is Exponential the only memoryless continuous distribution?
The memoryless property P(X>s+tX>s)=P(X>t)P(X > s+t \mid X > s) = P(X > t) uniquely characterizes the exponential distribution through a functional equation that forces the form eλte^{-\lambda t}.
What ML application uses Uniform for initialization?
Xavier/Glorot initialization uses Uniform(6nin+nout,6nin+nout)(-\sqrt{\frac{6}{n_{in}+n_{out}}}, \sqrt{\frac{6}{n_{in}+n_{out}}}) to initialize neural network weights, keeping gradient variance stable.
What is Thompson Sampling and how does Beta help?
Thompson Sampling for multi-armed bandits: maintain Beta(αi,βi)(\alpha_i, \beta_i) for each arm ii, sample from each Beta, pull arm with highest sample. Beta naturally balances exploration (uncertain arms vary more) and exploitation (high-mean arms favored).

Concept Map

integrate to 1

PDF

mean

variance

applied in

Xavier sampling

defines

models

continuous analog of

models uncertainty in

conjugate prior for

enables

No preference density

Uniform Distribution

f = 1 over b-a

mu = a+b over 2

Var = b-a squared over 12

Random Initialization

Neural Net Weights

Memoryless property

Exponential Distribution

Waiting times between events

Geometric Distribution

Beta Distribution

Probabilities themselves

Bernoulli and Binomial

Elegant Bayesian Updates

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Chalo is baat ko simple tarike se samajhte hain. Ye teen distributions ML mein bahut kaam aati hain, aur har ek ka apna "personality" hai. Uniform distribution ka matlab hai "koi favouritism nahi" — jaise interval [a, b] ke andar har point equally likely hai. Isliye jab humein kuch nahi pata hota, ya jab hum neural network ke weights randomly initialize karte hain, tab Uniform kaam aata hai. Iska density constant hota hai, aur wo constant 1ba\frac{1}{b-a} isliye aata hai taaki total probability exactly 1 ban jaye — kyunki koi bhi PDF ka area 1 hona chahiye. Mean midpoint pe aata hai (obvious hai, symmetric jo hai), aur variance range ke square pe depend karta hai — matlab jitna wide interval, utni zyada uncertainty.

Exponential distribution ki soul hai "waiting time" — agli event kab aayegi. Jaise agla customer kab aayega, ya component kab fail hoga, ya neuron kab spike karega. Iska derivation Poisson process se aata hai: agar events rate λ\lambda pe hoti hain, to "time tt tak koi event nahi" ki probability eλte^{-\lambda t} hoti hai. Isko 1 se minus karke CDF milta hai, aur usko differentiate karke PDF λeλt\lambda e^{-\lambda t} nikalta hai. Iski sabse mast property hai memorylessness — matlab past ka koi asar nahi, distribution ko yaad nahi rehta ki tum kitni der se wait kar rahe ho. Ye continuous version hai geometric distribution ka.

Aur Beta distribution to sabse interesting hai — ye khud probability ki probability model karta hai! Matlab jab tum kisi probability ke baare mein hi unsure ho (jaise coin kitna biased hai, ya click-through rate kya hoga), tab Beta tumhara "belief" represent karta hai 0 se 1 ke beech. Bayesian ML mein iska bada role hai kyunki ye Bernoulli/Binomial ka conjugate prior hai — iska matlab jab tum naya data dekhte ho, to update karna mathematically clean aur elegant ho jaata hai. Ye teeno distributions samajhna isliye zaroori hai kyunki random initialization, sampling, aur Bayesian reasoning — ye sab ML ke core foundations hain, aur inke bina modern algorithms ki intuition adhoori reh jaati hai.

Go deeper — visual, from zero

Test yourself — Probability & Statistics

Connections