1.3.5 · HinglishProbability & Statistics

Random variables (discrete and continuous)

2,792 words13 min readRead in English

1.3.5 · AI-ML › Probability & Statistics

Ek random variable ek function hota hai jo kisi random experiment ke outcomes ko real numbers pe map karta hai. Yeh messy real world (coin flips, pixel intensities, user clicks) aur clean mathematical world ke beech ka bridge hai, jahan hum probabilities aur expectations calculate kar sakte hain.

Why Random Variables Matter in ML

Machine learning mein, almost sab kuch ek random variable hai:

  • Features: pixel values, word counts, sensor readings
  • Labels: class assignments, regression targets
  • Model parameters: training ke dauran sample kiye gaye weights
  • Predictions: uncertainty ke saath outputs

RVs ko samajhne se aap:

  1. Data aur predictions mein uncertainty quantify kar sakte ho
  2. Aise loss functions design kar sakte ho jo aapke data distribution se match karein
  3. Complex distributions se sample kar sakte ho (GANs, VAEs)
  4. Model behavior ke baare mein probabilistically reason kar sakte ho

The Core Intuition

Example: Ek die roll karo. Outcome space hai {⚀, ⚁, ⚂, ⚃, ⚄, ⚅}. Define karo = "dots ki sankhya". Tab map karta hai ⚂ → 3, ⚅ → 6, wagera. random variable hai, outcome "3" khud nahi.


Discrete Random Variables

Probability Mass Function (PMF)

Probability mass function woh probability deta hai ki exactly value leta hai.

Requirements (yeh ensure karte hain ki yeh ek valid probability distribution hai):

  1. Non-negativity: sabhi ke liye
  2. Normalization: (saari probabilities ka sum 1 hota hai)

Yeh rules kyun? Non-negativity: probabilities negative nahi ho sakti. Normalization: kuch na kuch zaroor hona chahiye, isliye total probability = 1.

Figure — Random variables (discrete and continuous)

First principles se:

  • Socho experiment baar repeat ho raha hai, values milti hain
  • Sample average hai
  • Identical values group karo: agar baar aata hai, average =
  • Jab , (frequency probability pe converge hoti hai)
  • Isliye:

Har term se weight kyun hota hai? Zyada probable values long run mein zyada baar aati hain, isliye woh average mein zyada contribute karti hain.

PMF:

Compact form: for

Yeh form kyun? Jab : . Jab : . Yeh dono cases ek expression mein likhne ka ek clever tarika hai.

Expected value:

kyun? Agar ke saath 100 baar flip karo, toh expect karte ho lagbhag 30 heads. Average = 30/100 = 0.3 = .

ML Application: Binary classification labels (spam/not spam). Logistic regression output karta hai, jo literally hai Bernoulli RV "kya yeh example class 1 hai?" ke liye.

PMF ki Derivation:

  • Kisi bhi specific sequence ki probability jisme heads hain: (heads baar prob ke saath aate hain, tails baar prob ke saath)
  • Aise sequences ki sankhya ( flips mein heads ke orderings):
  • Multiplication kyun? Har specific sequence ki prob hai, aur mutually exclusive sequences hain

Expected value:

Kyun? Har flip expected value contribute karta hai. independent flips ke saath: .

ML Application: Neural networks mein Dropout. Har neuron independently probability ke saath "survive" karta hai. Ek layer mein active neurons ki sankhya ~ Binomial.


Continuous Random Variables

Discrete se key difference: kisi bhi specific ke liye. Kyun? Infinitely many points, probability infinitely thin spread ho jaati hai. Hume intervals ke baare mein poochna hoga: .

Probability Density Function (PDF)

Probability density function ek probability NAHI hai—yeh ek density hai. Ise socho "probability per unit length" ki tarah.

Requirements:

  1. Non-negativity: sabhi ke liye
  2. Normalization:

Integration kyun? Tum interval par infinitesimal probabilities ko sum kar rahe ho. "" density ko probability mein convert karta hai: ke units hain "probability per unit", ke units hain "unit", product ke units hain "probability".

Geometric intuition: Probability = curve ke neeche aur ke beech ka area.

kyun? Discrete jaisi hi logic: har value ko uski "probability" se weight karo (yahan, density × ).

PDF:

Yeh form kyun? mein constant density (equally likely). 1 tak integrate hona chahiye:

Expected value:

Simplify karo: , isliye:

Midpoint kyun? Symmetry. Dono taraf equally likely, isliye average center hota hai.

ML Application: Neural networks mein weight initialization aksar uniform distributions use karta hai (jaise Xavier/Glorot initialization se sample karta hai).

PDF:

Parameters: (mean, location), (variance, spread)

Yeh functional form kyun? (Mean/variance constraints ke under maximum entropy se brief derivation—full proof complex hai, lekin intuition):

  • Hum "sabse random" distribution chahte hain sirf mean aur variance ki knowledge diye gaye
  • , subject to entropy maximize karna yeh exponential-quadratic form deta hai
  • ensure karta hai ki

shape kyun? Yeh probability ko mean () ke paas concentrate karta hai, tails quickly khatam ho jaate hain. Exponent mein quadratic smoothness aur "bell" shape ensure karta hai.

Expected value: ke around symmetry se, .

ML Applications:

  1. Data mein Gaussian noise: , jahan
  2. Weight initialization (jaise He initialization: )
  3. Gaussian processes, variational autoencoders (VAE latent space)
  4. Linear regression assume karta hai

Cumulative Distribution Function (CDF)

Discrete aur continuous dono RVs ka CDF hota hai .

Discrete RV ke liye: (PMF values ko sum karo)

Continuous RV ke liye: (PDF integrate karo)

Useful kyun?

  • CDFs hamesha exist karte hain (PMFs/PDFs mixed distributions ke liye nahi hote)
  • Probabilities compute karna aasaan:
  • PDF se relationship: (PDF, CDF ka derivative hai)

ML Application: Percentile-based metrics, quantile regression, inverse transform sampling (kisi bhi distribution se samples generate karo uniform random numbers par apply karke).


Common Mistakes

Kyun sahi lagta hai: Hum discrete RVs se ke aadat hain.

Fix: density hai, probability nahi. Units: "probability per unit" hai. matlab "locally, probability 2 units per unit length ki speed se accumulate ho rahi hai". Actual probability: (jo chhote ke liye chhota hai).

Check: ke liye, . Lekin

Kyun sahi lagta hai: Dono weighted averages use karte hain.

Fix:

  • Discrete: E_X = sum(x * P(x) for x in values)
  • Continuous: E_X = integrate(x * f(x), x, -inf, inf) ya E_X = np.mean(samples) samples ke liye

NumPy mein, agar tumhare paas continuous RV ke samples hain, toh np.mean(samples) use karo, na ki sum(x * count(x)) (jo discrete assume karta hai).

Kyun sahi lagta hai: Hum thermometers par "20°C" measure karte hain.

Fix: Real measurements finite precision hoti hai. Tumhara thermometer "20°C" padhta hai = "19.5 aur 20.5°C ke beech" (ek interval). Continuous RVs ke liye, hamesha intervals ke baare mein poochho: .


Active Recall

Recall Random Variables ko ek 12-Saal ke Bacche ko Explain Karo

Socho tumhare paas ek magic box hai jo games khelta hai. Kabhi woh dice roll karta hai, kabhi wheel spin karta hai. Har baar jab tum box use karte ho, woh tumhe ek number deta hai. Woh number random hota hai (pehle se pata nahi hota), lekin woh rules follow karta hai.

Ek random variable us number ka nickname jaisa hai. Hum ise kehte hain. Agar hum die roll karein, 1, 2, 3, 4, 5, ya 6 ho sakta hai (sirf yahi numbers, beech mein kuch nahi). Yeh discrete hai—jaise candies ginana.

Lekin agar hum ek wheel spin karein jo 0 se 100 ke beech kahin bhi land kar sakta hai, 23.7145... ya 99.001... ya beech mein koi bhi number ho sakta hai. Yeh continuous hai—jaise cup mein kitna paani hai measure karna.

Discrete ke liye, hum keh sakte hain "exactly 3 milne ki probability hai..." (jaise fair die ke liye ). Continuous ke liye, hum "exactly 23.7145" nahi keh sakte kyunki infinite possibilities hain—yeh aise hai jaise beach par ek specific ret ka daana dhundna. Isliye hum poochte hain "X ke 20 aur 30 ke beech hone ki probability kya hai?" aur us range mein probabilities add karte hain (integration).

Cool part yeh hai: AI mein almost sab kuch ek random variable hai—image mein kaunsa digit hai, agla word kya aayega, email spam hai ya nahi. RVs samajhna matlab AI uncertainty kaise handle karta hai yeh samajhna hai.


Memory Aids

  • Discrete = Distinct, Discrete math (integers)
  • PMF = Probability Mass (mass points par baith jaati hai)
  • PDF = Probability Density (fluid ki tarah spread)

Alphabet trick:

  • PMF Sum use karta hai ()
  • PDF Integral use karta hai ()
  • "S comes before I" → discrete ke liye sum use karo, continuous ke liye integral

Connections


#flashcards/ai-ml

Random variable kya hota hai? :: Ek function jo random experiment ke outcomes ko real numbers pe map karta hai. Yeh real-world randomness aur mathematical probability ke beech ka bridge hai.

Discrete aur continuous random variable mein kya fark hai?
Discrete RVs countable values lete hain (list kar sakte ho); continuous RVs uncountably infinite values lete hain (kisi interval mein koi bhi real number).
PMF kya hai aur uski do requirements kya hain?
Probability Mass Function: discrete RVs ke liye . Requirements: (1) (non-negative), (2) (sum 1 hota hai).
PDF kya hai aur probability kyun nahi hai?
Continuous RVs ke liye Probability Density Function. ek density hai (probability per unit length), probability nahi. Probability = (curve ke neeche area).
Continuous random variables ke liye kyun hota hai?
Infinite possible values matlab probability infinitely thin spread ho jaati hai. Hume exact points ki jagah intervals ke baare mein poochna hoga.
Discrete RV ke liye expected value formula?
. Har value apni probability se weighted.

Continuous RV ke liye expected value formula? :: . Density par weighted integral.

Bernoulli distribution: PMF aur expected value?
, . . Binary outcomes (success/failure) model karta hai.
Binomial distribution: yeh kya model karta hai aur kya hai?
independent Bernoulli trials mein successes ki sankhya. . .
Uniform distribution on : PDF aur expected value?
for , 0 otherwise. (symmetry se midpoint).
Gaussian distribution: PDF aur parameters?
. Parameters: (mean), (variance).
CDF kya hai aur PDF/PMF se uska kya relation hai?
Cumulative Distribution Function: . Continuous RVs ke liye, aur .
PDF ki values 1 se zyada kyun ho sakti hain?
PDF ek density hai (probability per unit), probability nahi. Jab tak hai, locally 1 se zyada ho sakta hai (jaise mein ).
ML application of Bernoulli distribution?
Binary classification labels. Logistic regression output karta hai Bernoulli RV "kya yeh class 1 hai?" ke liye.
ML application of Gaussian distribution?
Noise modeling (, ), weight initialization, VAE latent space, Gaussian processes.

Concept Map

outcomes

is a

type

type

takes values from

described by

requires

used to compute

derived from

example

enables in ML

Random experiment

Random variable

Function mapping to reals

Discrete RV

Continuous RV

Countable set

Probability mass function

Non-negativity and Normalization

Expected value

Long-run sample average

Bernoulli distribution

Quantify uncertainty