Numbers That Carry Uncertainty 🎲अनिश्चितता वाली संख्याएँ 🎲带着不确定性的数字 🎲
You are about to roll a die. You cannot say which face will show, but you know it will be some number. Call that number X. X is not fixed in advance — its value depends on the outcome of a random experiment. That is a random variable.
आप एक die फेंकने वाले हैं। आप नहीं बता सकते कि कौन-सा अंक आएगा, पर इतना पता है कि कोई संख्या आएगी। उस संख्या को X कहें। X पहले से तय नहीं — इसका मान एक random प्रयोग के नतीजे पर निर्भर है। यही random variable है।
你准备掷一颗骰子。你说不准会出现哪一面,但知道一定是某个数。把这个数记作 X。X 事先并不确定 —— 它的值取决于随机试验的结果。这就是随机变量。
Random variables connect probability (sample spaces, events) to real data. Every column you analyse — customer age, transaction amount, exam score, daily rainfall — can be seen as values of a random variable. This tutorial covers what a random variable is, the discrete/continuous split, and the three functions that describe its behaviour: the PMF, PDF and CDF.
Random variables, probability (sample spaces, events) को असली data से जोड़ते हैं। आप जो भी column analyse करते हैं — ग्राहक की उम्र, लेन-देन की राशि, exam score, रोज़ की बारिश — उसे random variable के मानों की तरह देखा जा सकता है। यह tutorial बताता है कि random variable क्या है, discrete/continuous का बँटवारा, और इसके व्यवहार को बताने वाले तीन functions: PMF, PDF और CDF।
随机变量把概率(样本空间、事件)与真实数据连接起来。你分析的每一列 —— 客户年龄、交易金额、考试分数、每日降雨量 —— 都可以看作某个随机变量的取值。本教程介绍随机变量是什么、离散与连续的区别,以及描述其行为的三个函数:PMF、PDF 和 CDF。
Random variables use capital letters (X, Y, Z). The values they take use small letters (x, y, z). So "X = 3" means the random variable X took the value 3 in one trial, and P(X = 3) is the chance of that happening.
Random variables के लिए बड़े अक्षर (X, Y, Z) और उनके मानों के लिए छोटे अक्षर (x, y, z)। तो "X = 3" का मतलब है random variable X ने एक trial में मान 3 लिया, और P(X = 3) इसके होने का chance है।
随机变量用大写字母(X、Y、Z),它们的取值用小写字母(x、y、z)。所以“X = 3”表示随机变量 X 在一次试验中取值 3,P(X = 3) 是这件事发生的概率。
What Is a Random Variable? 🔢Random Variable क्या है? 🔢什么是随机变量?🔢
The Story: The Call Centreकहानी: Call Centre故事:呼叫中心
Priya manages a call centre. Each hour she counts the complaints: some hours 0, some 12, now and then 30. She cannot predict the exact number, but she can describe the pattern. She defines X = "number of complaints in an hour". X is a random variable.
Priya एक call centre चलाती है। हर घंटे वह शिकायतें गिनती है: कभी 0, कभी 12, कभी-कभार 30। वह सही संख्या का अनुमान नहीं लगा सकती, पर pattern बता सकती है। वह X = "एक घंटे में शिकायतों की संख्या" तय करती है। X एक random variable है।
Priya 管理一个呼叫中心。她每小时统计投诉数:有时 0,有时 12,偶尔 30。她无法预测确切数字,但能描述规律。她定义 X =“每小时的投诉数”。X 就是一个随机变量。
Her colleague Arjun measures how long each call lasts: 2.3 minutes, 7.81 minutes, 14.002 minutes… Any positive number is possible. He defines Y = "call duration in minutes". Y is also a random variable, but of a different type.
उसका साथी Arjun हर call की अवधि मापता है: 2.3 मिनट, 7.81 मिनट, 14.002 मिनट… कोई भी positive संख्या संभव है। वह Y = "call की अवधि मिनट में" तय करता है। Y भी random variable है, पर अलग प्रकार का।
她的同事 Arjun 记录每通电话的时长:2.3 分钟、7.81 分钟、14.002 分钟……任何正数都可能。他定义 Y =“通话时长(分钟)”。Y 也是随机变量,但类型不同。
Daily rainfall is neither purely discrete nor purely continuous. Many days have exactly 0 mm, so P(rain = 0) > 0 — a discrete lump. On wet days the amount can be any positive number — a continuous part. Its CDF has a jump at 0 and then rises smoothly. Insurance claims (many are exactly 0) behave the same way.
रोज़ की बारिश न पूरी तरह discrete है न पूरी तरह continuous। कई दिन ठीक 0 mm होती है, इसलिए P(बारिश = 0) > 0 — एक discrete ढेर। बारिश वाले दिनों में मात्रा कोई भी positive संख्या हो सकती है — continuous हिस्सा। इसकी CDF में 0 पर छलांग होती है और फिर यह smooth चढ़ती है। बीमा claims (कई ठीक 0) भी ऐसे ही होते हैं।
每日降雨量既不是纯离散也不是纯连续。很多天恰好是 0 毫米,所以 P(降雨 = 0) > 0 —— 这是离散的一块。下雨的日子雨量可以是任意正数 —— 这是连续部分。它的 CDF 在 0 处有跳跃,之后平滑上升。保险理赔(很多恰好为 0)也是如此。
Random Variables in Pictures — Understand Before the Maths 📊तस्वीरों में Random Variables — गणित से पहले समझें 📊图解随机变量 — 先理解,再算数 📊
Roll two dice. The sample space has 36 equally likely pairs. The rule "add the two numbers" turns each pair into one number from 2 to 12. Counting how many pairs give each sum gives the PMF directly.
दो dice फेंकें। Sample space में 36 बराबर संभावना वाले जोड़े हैं। नियम "दोनों संख्याएँ जोड़ें" हर जोड़े को 2 से 12 तक की एक संख्या में बदल देता है। हर योग देने वाले जोड़े गिनने से सीधे PMF मिल जाता है।
掷两颗骰子,样本空间有 36 个等可能的有序对。规则“把两个数相加”把每一对变成 2 到 12 之间的一个数。数一数每个和对应几对,就直接得到 PMF。
Pick a rule, then roll. Each roll is one outcome ω; the rule turns it into a value of X. The blue bars are the share of rolls; the dashed outlines are the exact PMF.
एक नियम चुनें, फिर फेंकें। हर फेंक एक नतीजा ω है; नियम उसे X के एक मान में बदलता है। नीले bars फेंकों का हिस्सा हैं; dashed outlines सटीक PMF हैं।
选一条规则,然后掷。每次投掷是一个结果 ω,规则把它变成 X 的一个值。蓝柱是实测比例,虚线轮廓是精确 PMF。
Discrete vs Continuous — The Core Split ⚖️Discrete बनाम Continuous — मुख्य बँटवारा ⚖️离散 vs 连续 — 核心区分 ⚖️
The first question about any random variable: can you list its possible values, or can it take any value in an interval? The answer decides which formulas, plots and distributions make sense.
किसी भी random variable के बारे में पहला सवाल: क्या आप इसके संभव मानों की सूची बना सकते हैं, या यह interval का कोई भी मान ले सकता है? जवाब तय करता है कि कौन-से formulas, plots और distributions ठीक हैं।
关于任何随机变量的第一个问题:它的可能取值能列举出来吗,还是能取区间内的任意值?答案决定了该用哪些公式、图形和分布。
- Values can be listed: 0, 1, 2, …मानों की सूची बन सकती है: 0, 1, 2, …取值可以列举:0、1、2、…
- List may be finite or endlessसूची सीमित या अंतहीन हो सकती है可以是有限个或无穷多个
- Gaps between possible valuesसंभव मानों के बीच खाली जगह可能取值之间有间隔
- Described by a PMF: P(X = x)PMF से बताया जाता है: P(X = x)用 PMF 描述:P(X = x)
- PMF values sum to 1PMF मानों का योग 1PMF 之和为 1
- CDF is a staircaseCDF सीढ़ी हैCDF 是阶梯
- Examples: counts, dice, clicksउदाहरण: गिनती, dice, clicks例:计数、骰子、点击
- Any value in an intervalInterval का कोई भी मान区间内任意值
- Values cannot be listedमानों की सूची नहीं बन सकती取值无法列举
- No gapsकोई खाली जगह नहीं没有间隔
- Described by a PDF: f(x)PDF से बताया जाता है: f(x)用 PDF 描述:f(x)
- Area under the PDF = 1PDF के नीचे area = 1PDF 下方面积 = 1
- CDF is a continuous curve (S-shaped for the normal)CDF एक continuous curve (normal के लिए S-आकार)CDF 是连续曲线(正态分布为 S 形)
- Examples: height, time, temperatureउदाहरण: लंबाई, समय, तापमान例:身高、时间、温度
- Discrete: P(X = x) can be > 0Discrete: P(X = x) > 0 हो सकता है离散:P(X = x) 可以 > 0
- Continuous: P(X = x) = 0 alwaysContinuous: P(X = x) = 0 हमेशा连续:P(X = x) 恒为 0
- Continuous: ask about intervalsContinuous: intervals के बारे में पूछें连续:要问区间
- Discrete: bar HEIGHT = probabilityDiscrete: bar की ऊँचाई = probability离散:柱高 = 概率
- Continuous: AREA = probabilityContinuous: AREA = probability连续:面积 = 概率
| FeatureFeature特征 | DiscreteDiscrete离散 | ContinuousContinuous连续 |
|---|---|---|
| Valuesमान取值 | A list {0, 1, 2, …}एक सूची {0, 1, 2, …}可列集合 {0, 1, 2, …} | An interval [a, b] or all of ℝInterval [a, b] या पूरा ℝ区间 [a, b] 或整个 ℝ |
| Probability at one pointएक बिंदु पर probability单点概率 | P(X = x) can be > 0P(X = x) > 0 हो सकता हैP(X = x) 可 > 0 | P(X = x) = 0P(X = x) = 0P(X = x) = 0 |
| FunctionFunction函数 | PMF p(x) = P(X = x) | PDF f(x); area gives probabilityPDF f(x); area से probabilityPDF f(x);面积给出概率 |
| Totalकुल总和 | Σ p(x) = 1 | ∫ f(x) dx = 1 |
| CDF shapeCDF का आकारCDF 形状 | Staircaseसीढ़ी阶梯 | Continuous curve (no jumps)Continuous curve (कोई छलांग नहीं)连续曲线(无跳跃) |
| Common distributionsआम distributions常见分布 | Binomial, Poisson, Geometric | Normal, Exponential, Uniform, Beta |
| Real examplesअसली उदाहरण真实例子 | Defects, goals, clicksDefects, goals, clicks次品数、进球、点击 | Height, weight, time, temperatureलंबाई, वज़न, समय, तापमान身高、体重、时间、温度 |
Probability Mass Function (PMF) 📊Probability Mass Function (PMF) 📊概率质量函数(PMF)📊
The Story: The Quality Inspectorकहानी: Quality Inspector故事:质检员
Ravi checks batches of 3 smartphones. Each phone, independently, has a 20% chance of a defect. X = "number of defective phones in a batch". X can be 0, 1, 2 or 3. The list of probabilities for these four values is the probability mass function.
Ravi 3 smartphones के batches जाँचता है। हर phone में, independently, defect का 20% chance है। X = "batch में ख़राब phones की संख्या"। X 0, 1, 2 या 3 हो सकता है। इन चार मानों की probabilities की सूची probability mass function है।
Ravi 检查每批 3 部智能手机。每部手机独立地有 20% 的概率存在缺陷。X =“一批中的次品数”,可取 0、1、2、3。这四个值的概率清单就是概率质量函数。
The CDF jumps by exactly the PMF bar at each value: 0.512, then +0.384, +0.096, +0.008.
CDF हर मान पर ठीक PMF bar जितनी छलांग लगाती है: 0.512, फिर +0.384, +0.096, +0.008।
CDF 在每个取值处正好跳升一个 PMF 柱高:0.512,然后 +0.384、+0.096、+0.008。
More PMF ExamplesPMF के और उदाहरण更多 PMF 例子
| Experimentप्रयोग试验 | Random variable XRandom variable X随机变量 X | Valuesमान取值 | PMFPMFPMF |
|---|---|---|---|
| Fair coinसही सिक्का均匀硬币 | 1 if heads, 0 if tailsheads पर 1, tails पर 0正面为 1,反面为 0 | {0, 1} | P(X=0) = P(X=1) = 0.5 |
| Fair dieसही die均匀骰子 | Face shownदिखा अंक朝上的点数 | {1, …, 6} | P(X=k) = 1/6 |
| Goals in a football matchफ़ुटबॉल मैच में गोल足球比赛进球数 | Total goalsकुल गोल总进球 | {0, 1, 2, …} | Often modelled as Poisson: e^(−λ) λᵏ / k!अक्सर Poisson से: e^(−λ) λᵏ / k!常用泊松模型:e^(−λ) λᵏ / k! |
| Emails per hourहर घंटे emails每小时邮件数 | Number receivedआए emails की संख्या收到的数量 | {0, 1, 2, …} | Poisson with λ = average ratePoisson, λ = औसत दर泊松,λ = 平均速率 |
| Raffle ticketRaffle ticket抽奖券 | 1 if you win, else 0जीतें तो 1, वरना 0中奖为 1,否则为 0 | {0, 1} | P(X=1) = 1/1000 |
Set n and p for a binomial variable, then move k. Every bar up to k is shaded; their total is F(k), the height of the staircase below. Turn on Poisson to see when it approximates the binomial.
Binomial variable के लिए n और p चुनें, फिर k खिसकाएँ। k तक का हर bar रंगीन है; इनका योग F(k) है, यानी नीचे की सीढ़ी की ऊँचाई। Poisson चालू करें और देखें कि यह कब binomial के पास होता है।
为二项变量设置 n 和 p,再移动 k。k 及以下的柱子都会着色,它们的总和就是 F(k),即下方阶梯的高度。打开泊松,看看它何时近似二项分布。
Probability Density Function (PDF) 🌊Probability Density Function (PDF) 🌊概率密度函数(PDF)🌊
The Story: Hospital Waiting Timeकहानी: अस्पताल में इंतज़ार故事:医院候诊时间
An emergency room records waiting times: 8.7 minutes, 23.14 minutes, 5.003 minutes… The wait Y can be any non-negative number. The chance that Y is exactly 8.7000… minutes is zero. But the chance that Y is between 10 and 20 minutes is a real, useful number: the area under the density curve between 10 and 20.
एक emergency room इंतज़ार के समय दर्ज करता है: 8.7 मिनट, 23.14 मिनट, 5.003 मिनट… इंतज़ार Y कोई भी non-negative संख्या हो सकता है। Y के ठीक 8.7000… मिनट होने का chance शून्य है। पर Y के 10 और 20 मिनट के बीच होने का chance एक असली, काम की संख्या है: 10 और 20 के बीच density curve के नीचे का area।
急诊室记录候诊时间:8.7 分钟、23.14 分钟、5.003 分钟……等待时间 Y 可以是任意非负数。Y 恰好等于 8.7000… 分钟的概率为零。但 Y 落在 10 到 20 分钟之间的概率是一个真实而有用的数:密度曲线在 10 到 20 之间的面积。
f(x) is NOT a probability. It is a density — like population density (people per km²). It can be bigger than 1: Uniform(0, 0.5) has f(x) = 2 on its whole range, yet its total area is 2 × 0.5 = 1. Only areas give probabilities: P(a ≤ X ≤ b) = ∫ₐᵇ f(x) dx.
f(x) probability नहीं है। यह density है — जैसे जनसंख्या घनत्व (लोग प्रति km²)। यह 1 से बड़ी हो सकती है: Uniform(0, 0.5) में पूरी range पर f(x) = 2 है, फिर भी कुल area 2 × 0.5 = 1 है। सिर्फ़ areas probability देते हैं: P(a ≤ X ≤ b) = ∫ₐᵇ f(x) dx।
f(x) 不是概率,而是密度 —— 就像人口密度(每平方千米的人数)。它可以大于 1:Uniform(0, 0.5) 在整个范围上 f(x) = 2,但总面积仍是 2 × 0.5 = 1。只有面积才给出概率:P(a ≤ X ≤ b) = ∫ₐᵇ f(x) dx。
Choose a distribution, move the interval, and change its width. The shaded area is the probability. Press "Shrink" and watch the area vanish while the height stays. Try U(0, 0.5) to see a density above 1.
एक distribution चुनें, interval खिसकाएँ, और उसकी चौड़ाई बदलें। रंगीन area ही probability है। "सिकोड़ें" दबाएँ और देखें कि ऊँचाई रहती है पर area ग़ायब हो जाता है। 1 से ज़्यादा density देखने के लिए U(0, 0.5) आज़माएँ।
选择一个分布,移动区间并改变宽度。阴影面积就是概率。点击“缩成一个点”,看面积消失而高度不变。试试 U(0, 0.5),看看大于 1 的密度。
Cumulative Distribution Function (CDF) 📈Cumulative Distribution Function (CDF) 📈累积分布函数(CDF)📈
The Story: The Weather Forecasterकहानी: मौसम विशेषज्ञ故事:天气预报员
A forecaster studying daily rainfall rarely asks "what is the chance of exactly 15 mm?". She asks "what is the chance of at most 15 mm?". "At most" questions are exactly what the cumulative distribution function answers.
रोज़ की बारिश पढ़ने वाली मौसम विशेषज्ञ शायद ही पूछती है "ठीक 15 mm का chance क्या है?"। वह पूछती है "ज़्यादा से ज़्यादा 15 mm का chance क्या है?"। "ज़्यादा से ज़्यादा" वाले सवालों का जवाब ठीक cumulative distribution function देता है।
研究每日降雨的预报员很少问“恰好 15 毫米的概率是多少?”,她会问“至多 15 毫米的概率是多少?”。“至多”类问题正是累积分布函数回答的。
The CDF works for every random variable — discrete, continuous or mixed. It starts at 0, ends at 1 and never goes down. For discrete variables it is a staircase; for continuous ones it is an unbroken curve whose shape depends on the distribution.
CDF हर random variable के लिए काम करती है — discrete, continuous या mixed। यह 0 से शुरू होती है, 1 पर ख़त्म होती है और कभी नीचे नहीं जाती। Discrete variables के लिए यह सीढ़ी है; continuous के लिए एक अटूट curve जिसका आकार distribution पर निर्भर है।
CDF 适用于所有随机变量 —— 离散、连续或混合。它从 0 开始,到 1 结束,从不下降。离散变量的 CDF 是阶梯;连续变量的是一条不间断的曲线,形状取决于分布。
A line sweeps from left to right. The shaded amount in the top panel is always equal to the height of the CDF in the bottom panel. Try all four distributions.
एक रेखा बाएँ से दाएँ चलती है। ऊपर के panel में रंगीन मात्रा हमेशा नीचे के panel में CDF की ऊँचाई के बराबर होती है। चारों distributions आज़माएँ।
一条竖线从左向右扫过。上图的阴影量始终等于下图 CDF 的高度。四种分布都试试。
From Histogram to Density 🧱Histogram से Density तक 🧱从直方图到密度 🧱
Where does a PDF come from in practice? Record many call durations, draw a histogram, and scale each bar so its area (not height) is the share of calls in that bin. With more data and narrower bins, the bars settle onto a smooth curve — the density.
व्यवहार में PDF कहाँ से आती है? बहुत सारी calls की अवधि दर्ज करें, histogram बनाएँ, और हर bar को ऐसे scale करें कि उसका area (ऊँचाई नहीं) उस bin में calls का हिस्सा हो। ज़्यादा data और पतले bins के साथ bars एक smooth curve पर टिक जाते हैं — यही density है।
实际中 PDF 从哪里来?记录大量通话时长,画直方图,并缩放每根柱子,使其面积(而非高度)等于该组的通话比例。数据越多、组越窄,柱子就越贴合一条平滑曲线 —— 这就是密度。
Call durations here follow an exponential distribution with a mean of 5 minutes. Add calls and narrow the bins.
यहाँ call की अवधि 5 मिनट mean वाले exponential distribution को मानती है। Calls जोड़ें और bins पतले करें।
这里的通话时长服从均值为 5 分钟的指数分布。添加通话并缩小组宽。
PMF vs PDF vs CDF — The Full ComparisonPMF बनाम PDF बनाम CDF — पूरी तुलनाPMF vs PDF vs CDF — 全面比较
| FeatureFeature特征 | PMF p(x) | PDF f(x) | CDF F(x) |
|---|---|---|---|
| Variable typeVariable प्रकार变量类型 | DiscreteDiscrete离散 | ContinuousContinuous连续 | All typesसभी प्रकार所有类型 |
| Value at a pointएक बिंदु पर मान某点的值 | A probability, P(X = x)एक probability, P(X = x)概率 P(X = x) | A density (not a probability)Density (probability नहीं)密度(不是概率) | A probability, P(X ≤ x)एक probability, P(X ≤ x)概率 P(X ≤ x) |
| RangeRange取值范围 | 0 ≤ p(x) ≤ 1 | f(x) ≥ 0 (can exceed 1)f(x) ≥ 0 (1 से ज़्यादा हो सकती है)f(x) ≥ 0(可超过 1) | 0 ≤ F(x) ≤ 1 |
| Totalsकुल总和 | Σ p(x) = 1 | ∫ f(x) dx = 1 | F(+∞) = 1 |
| Pictureतस्वीर图形 | Bars at the valuesमानों पर bars取值处的柱子 | Curve (or flat line)Curve (या सपाट रेखा)曲线(或水平线) | Staircase or unbroken curveसीढ़ी या अटूट curve阶梯或连续曲线 |
| Interval probabilityInterval की probability区间概率 | Add the bars in [a, b][a, b] के bars जोड़ें把 [a, b] 内的柱相加 | Area ∫ₐᵇ f(x) dxArea ∫ₐᵇ f(x) dx面积 ∫ₐᵇ f(x) dx | F(b) − F(a) |
| Linksसंबंध关系 | CDF = running sum of PMFCDF = PMF का चलता योगCDF = PMF 的累加 | CDF = integral of PDFCDF = PDF का integralCDF = PDF 的积分 | PDF = derivative of CDFPDF = CDF का derivativePDF = CDF 的导数 |
Common Discrete Distributions 🎰आम Discrete Distributions 🎰常见离散分布 🎰
| DistributionDistribution分布 | PMF p(k) | ParametersParameters参数 | MeanMean均值 | Use caseउपयोग用途 |
|---|---|---|---|---|
| Bernoulli(p) | p if k = 1; 1 − p if k = 0k = 1 पर p; k = 0 पर 1 − pk = 1 时为 p;k = 0 时为 1 − p | p ∈ [0, 1] | p | One trial: click or no clickएक trial: click या नहीं单次试验:点击与否 |
| Binomial(n, p) | C(n, k) pᵏ (1 − p)ⁿ⁻ᵏ | n trials, success chance pn trials, सफलता chance pn 次试验,成功概率 p | np | Successes in n trialsn trials में सफलताएँn 次试验中的成功次数 |
| Poisson(λ) | e^(−λ) λᵏ / k! | λ = average countλ = औसत गिनतीλ = 平均次数 | λ | Events per unit of time or spaceसमय/जगह की इकाई में घटनाएँ单位时间或空间内的事件数 |
| Geometric(p) | (1 − p)ᵏ⁻¹ p, for k = 1, 2, …(1 − p)ᵏ⁻¹ p, k = 1, 2, … के लिए(1 − p)ᵏ⁻¹ p,k = 1, 2, … | p = success chancep = सफलता chancep = 成功概率 | 1/p | Trials until the first success (some books count failures instead)पहली सफलता तक trials (कुछ किताबें असफलताएँ गिनती हैं)直到首次成功的试验次数(有些书改为计失败次数) |
| Discrete uniform{a, …, b}Discrete uniform{a, …, b}离散均匀{a, …, b} | 1/(b − a + 1) | a = min, b = max | (a + b)/2 | Fair die, lottery numberसही die, लॉटरी नंबर均匀骰子、彩票号码 |
Common Continuous Distributions 🌊आम Continuous Distributions 🌊常见连续分布 🌊
| DistributionDistribution分布 | PDF f(x) | RangeRange范围 | MeanMean均值 | Use caseउपयोग用途 |
|---|---|---|---|---|
| Uniform(a, b) | 1/(b − a) | [a, b] | (a + b)/2 | Equally likely over an intervalInterval पर बराबर संभावना区间内等可能 |
| Normal N(μ, σ²) | (1/(σ√(2π))) e^(−(x−μ)²/(2σ²)) | (−∞, +∞) | μ | Measurement errors, heights, test scoresमाप की ग़लतियाँ, लंबाई, test scores测量误差、身高、考试分数 |
| Exponential(λ) | λ e^(−λx) | [0, +∞) | 1/λ | Time between random eventsRandom घटनाओं के बीच समय随机事件之间的时间 |
| Beta(α, β) | x^(α−1) (1−x)^(β−1) / B(α, β) | [0, 1] | α/(α + β) | Unknown proportions and ratesअज्ञात अनुपात और दरें未知的比例与比率 |
| Gamma(k, θ) | x^(k−1) e^(−x/θ) / (θᵏ Γ(k)) | [0, +∞) | kθ | Waiting times, claim sizes (θ is the scale; some books use a rate 1/θ)इंतज़ार समय, claim आकार (θ scale है; कुछ किताबें rate 1/θ लेती हैं)等待时间、理赔金额(θ 为尺度参数;有的书用速率 1/θ) |
| Log-normal | (1/(xσ√(2π))) e^(−(ln x−μ)²/(2σ²)) | (0, +∞) | e^(μ + σ²/2) | Incomes, file sizes, pricesआय, file आकार, कीमतें收入、文件大小、价格 |
Using the CDF — Four Practical Questions 🔧CDF का इस्तेमाल — चार व्यावहारिक सवाल 🔧使用 CDF — 四个实际问题 🔧
Python ImplementationPython ImplementationPython 实现
PMF, CDF, mean and variance with scipy.statsscipy.stats से PMF, CDF, mean और variance用 scipy.stats 计算 PMF、CDF、均值和方差
# 1) PMF, CDF, mean and variance of the defective-phone example
from scipy import stats
X = stats.binom(n=3, p=0.2)
for k in range(4):
print(f"P(X={k}) = {X.pmf(k):.3f} F({k}) = P(X<={k}) = {X.cdf(k):.3f}")
print(f"sum of PMF = {sum(X.pmf(k) for k in range(4)):.3f}")
print(f"E[X] = {X.mean():.2f}, Var(X) = {X.var():.2f}, SD = {X.std():.3f}")
print(f"P(X > 1) = 1 - F(1) = {X.sf(1):.3f}")
Zero probability at a point; density above 1एक बिंदु पर शून्य probability; 1 से ऊपर density单点概率为零;密度可大于 1
# 2) Continuous: a point has zero probability, and density can exceed 1
from scipy import stats
bus = stats.uniform(loc=0, scale=10) # Uniform(0, 10)
print(f"f(3) = {bus.pdf(3):.2f} (a density, not a probability)")
print(f"P(2 <= Y <= 5) = {bus.cdf(5) - bus.cdf(2):.2f}")
for w in [1, 0.1, 0.001, 0]:
print(f"P(3 <= Y <= 3+{w}) = {bus.cdf(3 + w) - bus.cdf(3):.4f}")
narrow = stats.uniform(loc=0, scale=0.5) # Uniform(0, 0.5)
print(f"Uniform(0, 0.5): f(x) = {narrow.pdf(0.2):.1f}, total area = {narrow.cdf(0.5):.1f}")
Normal areas and the 68-95-99.7 ruleNormal areas और 68-95-99.7 नियम正态面积与 68-95-99.7 法则
# 3) Normal heights: areas from the CDF
from scipy import stats
H = stats.norm(loc=165, scale=8)
print(f"P(H > 170) = {H.sf(170):.3f}")
for k in (1, 2, 3):
lo, hi = 165 - k * 8, 165 + k * 8
print(f"P({lo} <= H <= {hi}) = {H.cdf(hi) - H.cdf(lo):.4f}")
print(f"peak density f(165) = {H.pdf(165):.4f} per cm")
Four CDF questions, including the inverse CDFचार CDF सवाल, inverse CDF सहित四个 CDF 问题(含反 CDF)
# 4) Four CDF questions about test scores ~ N(70, 10^2)
from scipy import stats
S = stats.norm(loc=70, scale=10)
print(f"P(X <= 80) = {S.cdf(80):.4f}")
print(f"P(X > 80) = {S.sf(80):.4f}")
print(f"P(60 <= X <= 80) = {S.cdf(80) - S.cdf(60):.4f}")
print(f"90th percentile = {S.ppf(0.90):.2f}")
Simulation vs exact PMF, and Poisson ≈ BinomialSimulation बनाम सटीक PMF, और Poisson ≈ Binomial模拟 vs 精确 PMF,以及泊松 ≈ 二项
# 5) Simulation meets theory: sum of two dice, and Poisson ≈ Binomial
import numpy as np
from collections import Counter
from scipy import stats
rng = np.random.default_rng(1)
sums = rng.integers(1, 7, 100_000) + rng.integers(1, 7, 100_000)
count = Counter(sums)
for s in range(2, 13):
exact = (6 - abs(s - 7)) / 36
print(f"sum {s:2d}: simulated {count[s] / 100_000:.4f} exact {exact:.4f}")
print()
n, p = 1000, 0.003
for k in range(6):
print(f"k={k}: Binomial {stats.binom.pmf(k, n, p):.4f} Poisson {stats.poisson.pmf(k, n * p):.4f}")
Random Variables in Data Science & ML 🤖Data Science और ML में Random Variables 🤖数据科学与机器学习中的随机变量 🤖
| Applicationउपयोग应用 | Random variableRandom variable随机变量 | Typeप्रकार类型 | Typical modelआम model常用模型 |
|---|---|---|---|
| 🖱️ Ad click predictionAd click prediction广告点击预测 | 1 = click, 0 = no click1 = click, 0 = नहीं1 = 点击,0 = 未点击 | DiscreteDiscrete离散 | Bernoulli / Binomial |
| 📦 InventoryInventory库存 | Daily demand (units)रोज़ की माँग (units)每日需求(件) | DiscreteDiscrete离散 | Poisson (or negative binomial if more spread)Poisson (या ज़्यादा फैलाव हो तो negative binomial)泊松(离散度更大时用负二项) |
| 📉 Stock returnsStock returns股票收益 | Daily log-returnरोज़ का log-return日对数收益 | ContinuousContinuous连续 | Normal as a first guess; real returns have fatter tailsपहले अनुमान के रूप में Normal; असली returns की tails मोटी初步可用正态;真实收益尾部更厚 |
| ⏱️ Server response timeServer response time服务器响应时间 | Time to respond (ms)जवाब का समय (ms)响应时间(毫秒) | ContinuousContinuous连续 | Exponential / Gamma / Log-normal |
| 🎯 Bayesian A/B testingBayesian A/B testing贝叶斯 A/B 测试 | True conversion rateअसली conversion दर真实转化率 | ContinuousContinuous连续 | Beta |
| 🔤 Word countsWord counts词频 | Count of a word in a documentDocument में शब्द की गिनती文档中某词的次数 | DiscreteDiscrete离散 | Multinomial / Poisson |
| 🧬 GenomicsGenomics基因组学 | Mutations per genomeहर genome में mutations每个基因组的突变数 | DiscreteDiscrete离散 | Poisson |
| 🏠 House pricesHouse prices房价 | log(price)log(price)log(价格) | ContinuousContinuous连续 | Normal after the logLog के बाद Normal取对数后近似正态 |
Many common loss functions come from an assumed distribution. Minimising mean squared error is the same as maximum likelihood if the target is normal around the prediction with constant spread. Cross-entropy comes from a Bernoulli or categorical model. Poisson loss suits counts. (Some losses, like the hinge loss, are not built this way.) Knowing PMFs and PDFs helps you pick a loss that matches your data.
कई आम loss functions किसी माने गए distribution से आते हैं। Mean squared error घटाना maximum likelihood के बराबर है, अगर target prediction के चारों ओर normal हो और फैलाव स्थिर हो। Cross-entropy Bernoulli या categorical model से आती है। Poisson loss गिनती के लिए ठीक है। (कुछ losses, जैसे hinge loss, ऐसे नहीं बनते।) PMF और PDF की समझ से ऐसा loss चुनना आसान होता है जो आपके data से मेल खाए।
许多常见损失函数都来自某种假设的分布。若目标值围绕预测值呈方差恒定的正态分布,最小化均方误差就等价于最大似然。交叉熵来自伯努利或类别分布模型。泊松损失适合计数数据。(也有一些损失,如合页损失,并不是这样推导的。)理解 PMF 和 PDF,能帮你选出与数据相符的损失函数。
The Golden Rulesसुनहरे नियम黄金法则
A random variable turns outcomes into numbers. The discrete/continuous split picks your language. The PMF puts probability on points; the PDF spreads it as density, with area as probability; the CDF adds it up from the left and answers every "at most" question. Together they describe any uncertain quantity — the base of every statistical model.
Random variable नतीजों को संख्याओं में बदलता है। Discrete/continuous का बँटवारा आपकी भाषा तय करता है। PMF बिंदुओं पर probability रखता है; PDF उसे density की तरह फैलाता है, जहाँ area = probability; CDF बाईं ओर से जोड़ती है और हर "ज़्यादा से ज़्यादा" सवाल का जवाब देती है। मिलकर ये किसी भी अनिश्चित मात्रा का वर्णन करते हैं — हर statistical model की नींव।
随机变量把结果变成数字。离散/连续的区分决定了你用的语言。PMF 把概率放在点上;PDF 把它铺成密度,面积即概率;CDF 从左往右累加,回答所有“至多”类问题。它们共同描述任何不确定的量 —— 这是一切统计模型的基础。