Exercises — Bayes' theorem — derivation and applications
2.7.9 · D4· Maths › Statistics & Probability — Intermediate › Bayes' theorem — derivation and applications
Level 1 — Recognition
Yahan tumhe bas kaunsi quantity kaunsi hai woh spot karni hai. Koi mushkil arithmetic nahi — goal yeh hai ki kabhi bhi "cause diya hua" aur "evidence diya hua" mein confuse mat hona.
Exercise 1.1
Ek weather app kehti hai: "Jab actually barish hoti hai, tab app ne barish forecast ki thi time." Symbols mein, jahan "barish hoti hai" aur "app barish forecast karti hai", kaunsi conditional probability hai: ya ?
Recall Solution 1.1
Sentence pehle actual weather fix karta hai ("jab actually barish hoti hai") aur phir batata hai app kaise behave karti hai. Toh given (condition, bar ke baad wali cheez) hai. Iska matlab hai: Yeh ek likelihood hai — evidence (forecast) ki probability given cause (rain). Jo quantity ek user actually chahta hai, "usne barish forecast ki, toh actual barish kitni likely hai?", woh ulti wali hai, aur Bayes hi unhe connect karta hai.
Exercise 1.2
Disease-test setting mein, har phrase ko uske symbol se match karo: (a) " logon ko disease hai", (b) "test sensitive hai", (c) "tumhara test positive aaya; kya tum beemar ho?". = disease, = positive test use karo.
Recall Solution 1.2
- (a) prior hai — kisi bhi test se pehle belief.
- (b) likelihood hai — test kaise behave karta hai given tum beemar ho (sensitivity ek "true-positive rate" hai).
- (c) posterior hai — positive dekhne ke baad updated belief. Yeh woh unknown hai jo Bayes compute karta hai.
Exercise 1.3
Do bags tumhare saare marbles partition karti hain: bag (red) aur bag (blue), jahan , . Abhi tak koi evidence nahi hai, kya in dono priors ka sum hona zaroori hai? Kyun?
Recall Solution 1.3
Haan: . Ek partition ka matlab hai causes mutually exclusive hain (ek marble exactly ek bag mein hai) aur exhaustive hain (koi aur bag nahi hai). Har marble exactly ek baar account hota hai, isliye priors ka sum hona zaroori hai. Agar nahi hota, toh Bayes ka denominator posteriors ko tak normalise kabhi nahi kar sakta.
Level 2 — Application
Ab tum formula mein numbers daalo, joints organize karne ke liye tree structure use karo.
Exercise 2.1
Ek factory line: items Type-A hain, Type-B hain. Type-A inspection mein probability se pass hota hai; Type-B probability se pass hota hai. Ek item pass hota hai. nikalo.
Recall Solution 2.1
Priors: . Likelihoods: .
Evidence (Law of Total Probability — pass A ya B se aa sakta hai): Bayes: Posterior () prior () se barely upar jaata hai — pass hona sirf thoda sa evidence hai Type-A ka, kyunki Type-A items lagbhag utni hi aasaani se pass hote hain jitna Type-B.
Exercise 2.2
Exercise 2.1 ke numbers reuse karo lekin item fail ho jaata hai. nikalo.
Recall Solution 2.2
Fail likelihoods complements hain: , .
Evidence: (Check: , toh passes aur fails saare items ko partition karte hain.)
Bayes: Failure Type-B ka strong evidence hai: chahe sirf items Type-B hain, woh aath guna zyada baar fail hote hain, isliye woh failures mein dominate karte hain.
Exercise 2.3
Parent note ke Worked Example 1 ko redo karo lekin ek zyada specific test ke saath: , (specificity ), prevalence . nikalo.
Recall Solution 2.3
False-positive rate ko se tak karna posterior ko (parent note) se exactly tak le jaata hai. Specificity, sirf sensitivity nahi, woh hai jo rare disease par false positives ko control karta hai.
Level 3 — Analysis
Yahan tum teen ya zyada causes ki partition handle karte ho, ya kaise answer move karta hai iske baare mein reason karte ho.
Exercise 3.1
Teen factories chips supply karti hain: X (, defect rate ), Y (, defect rate ), Z (, defect rate ). Ek chip defective hai. Har factory se aane ki posterior probability nikalo, aur most likely source batao.
Recall Solution 3.1
Joints : Evidence: Posteriors: Inका sum hai (achha). Sabse kam chips banane ke bawajood, Z ek defect ka most likely source hai kyunki iska defect rate X ka char guna hai. Figure dekho: prior bars (widths) posterior tak shrink ho jaate hain jab hum defect rate se weight karte hain.

Exercise 3.2
Exercise 3.1 mein, bina recompute kiye decide karo: agar Factory Z ki defect rate aadhi hokar ho jaaye, toh kya upar jaayega ya neeche? Phir verify karo.
Recall Solution 3.2
Pehle reasoning: Z ki defect rate aadhi karna Z ke joint ko se tak shrink karta hai, jabki X aur Y unchanged hain. Ek chhota numerator ek chhote total ke saath Z ki share ko neeche kheenchta hai.
Verify: naye joints ; evidence . se neeche aa gaya. Y ab leader ban jaata hai (). Most likely cause fixed nahi hai — yeh prior aur likelihood ke product ko track karta hai.
Exercise 3.3
Ek spam filter: email spam hai. Word "free" spam mein aur ham (non-spam) mein appear hota hai. Ek email mein "free" hai. nikalo, phir batao ki "free" contain karne wale emails ka kitna fraction actually ham hai.
Recall Solution 3.3
Priors: . Likelihoods: . Ham fraction complement hai, . Yeh "ek word, ek update" step exactly ek Naive Bayes Classifier ka atom hai, jo aisi kai word-updates ko multiply karta hai.
Level 4 — Synthesis
Ab tum Bayes ko ek doosri idea ke saath combine karte ho: repeated evidence, complementary reasoning, ya Independent Events.
Exercise 4.1
Parent note wali same rare disease: , , . Tum do baar positive test karte ho, aur dono tests tumhari true state given conditionally independent hain. nikalo.
Recall Solution 4.1
Conditional independence ka matlab hai, ek fixed true state given, dono results multiply hote hain: Evidence: Bayes: Ek positive ne sirf diya tha; ek doosra independent positive ise rocket karke tak le jaata hai. Bayes chains: test 1 ke baad posterior test 2 ke liye prior ban jaata hai.
(Chaining view se cross-check: test 1 ke baad, prior . Phir — same answer.)
Exercise 4.2
Ek box mein do coins hain: ek fair () aur ek two-headed (), equal prior ke saath choose kiya gaya. Tum ek coin draw karte ho, flip karte ho, aur heads aata hai. nikalo. Phir usi coin ke agle flip ki probability nikalo ki heads aaye.
Recall Solution 4.2
Priors: har coin . Likelihoods: . Agla flip — dono coins ko unke posterior weights se mix karo: Ek heads dekhne se tum two-headed coin ki taraf lean karne lage, jo agle heads ki expected chance se upar le jaata hai.
Exercise 4.3
Ek student ne ya toh padha (prior ) ya guess kiya (prior ). Ek padhne wala -option question sahi probability se answer karta hai; ek guesser pure chance se sahi karta hai, . Student correctly answer karta hai. nikalo.
Recall Solution 4.3
Guess likelihood: . Ek correct answer studying mein belief ko se tak nudge karta hai — evidence hai, lekin certainty nahi, kyunki guessers kabhi kabhi lucky ho jaate hain.
Level 5 — Mastery
Full modelling: tum partition, likelihoods banate ho, aur result interpret karte ho — koi scaffolding nahi.
Exercise 5.1
Ek urn mein red aur blue balls hain. Tum without replacement do balls draw karte ho. Given ki doosri ball red hai, probability nikalo ki pehli ball red thi. (Order matters; "pehle red" / "pehle blue" ko apni partition ke do causes ke roop mein use karo.)
Recall Solution 5.1
Priors (pehle draw ka colour): . Likelihoods "doosra red hai" ke liye, ab ek ball remove ho chuki hai: Evidence: (Sanity check: symmetry se kisi bhi specific draw ka marginal chance red hone ka overall red fraction ke barabar hai — reassuring.) Bayes: Yeh jaanna ki doosri ball red hai, pehli ball ka red hona uske prior se thoda kam likely banata hai — kyunki red pehla draw doosre ke liye kam reds chhodta hai.
Exercise 5.2
Ek signal source bit prior ke saath aur bit prior ke saath bhejta hai. Ek noisy channel bit ko probability se flip karta hai (kaunsa bit hai usse independent). Tumhe receive hota hai. Most likely kya bheja gaya tha, aur kis posterior probability ke saath?
Recall Solution 5.2
receive karne ki likelihoods: agar bheja gaya, koi flip nahi: ; agar bheja gaya, flip zaroori hai: . Most likely bheja gaya tha, posterior . Receiver ka optimal decision prior bit-frequency aur channel reliability dono use karta hai — yeh Bayesian decoding ka core hai.
Exercise 5.3
Bag : balls green hain. Bag : green. Tum randomly ek bag choose karte ho ( each), with replacement draw karte ho, aur sequence green, green, red observe karte ho. Kaunsa bag zyada likely hai, aur do.
Recall Solution 5.3
With replacement, bag given draws independent hain, toh likelihoods multiply hoti hain. Evidence: Bayes: Bag zyada likely hai (). Do greens greener bag ki taraf kheenchte hain; ek red thoda wapas kheenchta hai, lekin itna nahi ki usse overturn kar sake.
Recall Jaane se pehle ek-line self-test
Upar har problem ne same skeleton follow kiya — ise recite karo. ::: Priors list karo; matching likelihoods list karo; products sum karke evidence nikalo; jo ek joint chahiye use se divide karo. "PLE over E."
Connections
- Bayes' theorem — derivation and applications — parent note jise ye exercises drill karte hain.
- Conditional Probability — definition jis par har step dependent hai.
- Law of Total Probability — har solution mein evidence denominator banata hai.
- Independent Events — L4/L5 mein likelihoods multiply karne ke liye use hota hai.
- Tree Diagrams — joints ke peeche bookkeeping picture.
- Naive Bayes Classifier — spam problem (3.3) scaled up.
- Prior and Posterior Distributions — jahan chained updates (4.1) generalize hote hain.