Make notes and add more examples to easily understand the concept

Reading File
Running Command

cd /home/daytona/workspace/attachments/42f25875-e535-4582-9cdd-629db184a8f7/ && python3 -c " import pdfplumber with pdfplumber.open('UNIT V_Probability.pdf') as pdf: print(f'Total pages: {len(pdf.pages)}') for i, page in enumerate(pdf.pages): text = page.extract_text() print(f'--- PAGE {i+1} ---') print(text) print() "

Reading File
Running Command

cd /home/daytona/workspace/attachments/42f25875-e535-4582-9cdd-629db184a8f7/ && python3 -c " import pdfplumber from PIL import Image import io with pdfplumber.open('UNIT V_Probability.pdf') as pdf: for i in range(10): page = pdf.pages[i] # Get any words/chars on the page words = page.extract_words() print(f'--- PAGE {i+1} words: {words[:50] if words else \"[empty]\"}') # Check images imgs = page.images print(f' Images on page: {len(imgs)}') "

Browsing Directory

/home/daytona/workspace

Running Command

mkdir -p /home/daytona/workspace/probability-notes && ls /home/daytona/skills/docx/

Writing File

~/probability-notes/create_notes.js

const {
  Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell,
  HeadingLevel, AlignmentType, BorderStyle, WidthType, ShadingType,
  VerticalAlign, PageBreak
} = require('docx');
const fs = require('fs');

// Helper: Heading 1
function h1(text) {
  return new Paragraph({
    text,
    heading: HeadingLevel.HEADING_1,
    spacing: { before: 400, after: 200 },
  });
}

// Helper: Heading 2
function h2(text) {
  return new Paragraph({
    text,
    heading: HeadingLevel.HEADING_2,
    spacing: { before: 300, after: 150 },
  });
}

// Helper: Heading 3
function h3(text) {
  return new Paragraph({
    text,
    heading: HeadingLevel.HEADING_3,
    spacing: { before: 200, after: 100 },
  });
}

// Helper: Normal paragraph
function para(text) {
  return new Paragraph({
    children: [new TextRun({ text, size: 22 })],
    spacing: { after: 120 },
  });
}

// Helper: Bold + normal mixed paragraph
function mixedPara(boldText, normalText) {
  return new Paragraph({
    children: [
      new TextRun({ text: boldText, bold: true, size: 22 }),
      new TextRun({ text: normalText, size: 22 }),
    ],
    spacing: { after: 120 },
  });
}

// Helper: Bullet point
function bullet(text, level = 0) {
  return new Paragraph({
    children: [new TextRun({ text, size: 22 })],
    bullet: { level },
    spacing: { after: 80 },
  });
}

// Helper: Example box (shaded paragraph)
function exampleTitle(text) {
  return new Paragraph({
    children: [new TextRun({ text: `📌 Example: ${text}`, bold: true, size: 22, color: '1F4E79' })],
    shading: { type: ShadingType.SOLID, color: 'DEEAF1' },
    spacing: { before: 160, after: 60 },
    indent: { left: 360 },
  });
}

function exampleBody(text) {
  return new Paragraph({
    children: [new TextRun({ text, size: 21, italics: false })],
    shading: { type: ShadingType.SOLID, color: 'EBF3FB' },
    spacing: { after: 60 },
    indent: { left: 360 },
  });
}

// Formula paragraph
function formula(text) {
  return new Paragraph({
    children: [new TextRun({ text, bold: true, size: 22, color: '833C00', font: 'Courier New' })],
    spacing: { before: 100, after: 100 },
    indent: { left: 720 },
  });
}

// Tip / key note box
function keyNote(text) {
  return new Paragraph({
    children: [new TextRun({ text: `💡 Key Point: ${text}`, bold: true, size: 21, color: '375623' })],
    shading: { type: ShadingType.SOLID, color: 'E2EFDA' },
    spacing: { before: 120, after: 120 },
    indent: { left: 360 },
  });
}

// Simple 2-col comparison table
function twoColTable(rows) {
  return new Table({
    width: { size: 100, type: WidthType.PERCENTAGE },
    rows: rows.map(([left, right]) =>
      new TableRow({
        children: [
          new TableCell({
            children: [new Paragraph({ children: [new TextRun({ text: left, size: 20 })] })],
            width: { size: 50, type: WidthType.PERCENTAGE },
            shading: { type: ShadingType.SOLID, color: 'F2F2F2' },
            margins: { top: 80, bottom: 80, left: 120, right: 120 },
          }),
          new TableCell({
            children: [new Paragraph({ children: [new TextRun({ text: right, size: 20 })] })],
            width: { size: 50, type: WidthType.PERCENTAGE },
            margins: { top: 80, bottom: 80, left: 120, right: 120 },
          }),
        ],
      })
    ),
    spacing: { after: 200 },
  });
}

// PAGE BREAK
function pageBreak() {
  return new Paragraph({ children: [new PageBreak()] });
}

// ─────────────────────────────────────────────
// DOCUMENT CONTENT
// ─────────────────────────────────────────────
const children = [

  // TITLE
  new Paragraph({
    children: [new TextRun({ text: 'UNIT V – Probability', bold: true, size: 48, color: '1F3864' })],
    alignment: AlignmentType.CENTER,
    spacing: { after: 200 },
  }),
  new Paragraph({
    children: [new TextRun({ text: 'Comprehensive Notes with Examples', size: 24, color: '595959', italics: true })],
    alignment: AlignmentType.CENTER,
    spacing: { after: 400 },
  }),

  // ═══════════════════════════════
  // 1. PROBABILITY BASICS
  // ═══════════════════════════════
  h1('1. Probability – Core Concepts'),

  para('Probability measures how likely an event is to occur. It ranges from 0 (impossible) to 1 (certain).'),

  formula('P(Event) = Number of favourable outcomes / Total number of outcomes'),

  keyNote('P(A) + P(not A) = 1 always holds true.'),

  h2('1.1 Types of Events'),

  mixedPara('Independent Events: ', 'The outcome of one event does not affect the other.'),
  exampleTitle('Tossing two coins'),
  exampleBody('Getting Heads on the first toss does NOT change what happens on the second toss.'),
  exampleBody('P(H on 1st) = 1/2, P(H on 2nd) = 1/2, P(both H) = 1/2 × 1/2 = 1/4'),

  mixedPara('Dependent Events: ', 'The outcome of one event affects the probability of the other.'),
  exampleTitle('Drawing cards WITHOUT replacement'),
  exampleBody('A standard deck has 52 cards. P(drawing a King 1st) = 4/52.'),
  exampleBody('If a King is drawn and NOT replaced, P(drawing another King) = 3/51 (deck now has 51 cards).'),

  h2('1.2 Addition Rule'),
  formula('P(A or B) = P(A) + P(B) – P(A and B)'),
  exampleTitle('Rolling a die – get an even OR a number > 4'),
  exampleBody('Even numbers: {2, 4, 6}  → P(Even) = 3/6 = 1/2'),
  exampleBody('Numbers > 4: {5, 6}       → P(>4) = 2/6 = 1/3'),
  exampleBody('Both (even AND >4): {6}   → P(both) = 1/6'),
  exampleBody('P(Even OR >4) = 1/2 + 1/3 – 1/6 = 4/6 = 2/3'),

  h2('1.3 Multiplication Rule'),
  formula('P(A and B) = P(A) × P(B|A)   [for dependent events]'),
  formula('P(A and B) = P(A) × P(B)     [for independent events]'),
  exampleTitle('Bag with 3 Red and 2 Blue balls – draw 2 without replacement'),
  exampleBody('P(1st Red) = 3/5'),
  exampleBody('P(2nd Red | 1st was Red) = 2/4 = 1/2'),
  exampleBody('P(both Red) = 3/5 × 1/2 = 3/10 = 0.30'),

  h2('1.4 Conditional Probability'),
  formula('P(A|B) = P(A ∩ B) / P(B)'),
  para('Read as: "Probability of A, given that B has already occurred."'),
  exampleTitle('Class of 30 students – 12 study Maths, 10 study Science, 5 study both'),
  exampleBody('A student is chosen. Given they study Science, what is P(they also study Maths)?'),
  exampleBody('P(Maths | Science) = P(Maths ∩ Science) / P(Science) = (5/30) / (10/30) = 5/10 = 0.50'),

  pageBreak(),

  // ═══════════════════════════════
  // 2. BAYES THEOREM
  // ═══════════════════════════════
  h1('2. Bayes\' Theorem'),

  para('Bayes\' Theorem updates a prior probability based on new evidence. It answers: "Given what I observed, how likely is each cause?"'),

  formula('P(A|B) = [P(B|A) × P(A)] / P(B)'),

  para('Where:'),
  bullet('P(A) = Prior probability – our initial belief before evidence'),
  bullet('P(B|A) = Likelihood – probability of the evidence given A is true'),
  bullet('P(A|B) = Posterior probability – updated belief after evidence'),
  bullet('P(B) = Marginal probability – total probability of the evidence'),

  h2('2.1 Key Terminology'),

  twoColTable([
    ['Term', 'Meaning'],
    ['Priori Probability P(Eᵢ)', 'Initial probability BEFORE new data is available'],
    ['Posteriori Probability P(Eᵢ|A)', 'Updated probability AFTER new evidence'],
    ['Conditional Probability P(A|B)', 'Probability of A, given B has occurred'],
    ['Joint Probability P(A∩B)', 'Probability of A and B occurring together'],
  ]),

  h2('2.2 Examples'),

  exampleTitle('Medical Test for a Disease'),
  exampleBody('A disease affects 1% of the population. A test for it is 95% accurate (if you have the disease it shows +ve 95% of the time) and has a 5% false-positive rate.'),
  exampleBody(''),
  exampleBody('Given: P(Disease) = 0.01,  P(Positive | Disease) = 0.95,  P(Positive | No Disease) = 0.05'),
  exampleBody(''),
  exampleBody('P(Positive) = P(Pos|Disease)×P(Disease) + P(Pos|No Disease)×P(No Disease)'),
  exampleBody('           = 0.95×0.01 + 0.05×0.99 = 0.0095 + 0.0495 = 0.059'),
  exampleBody(''),
  exampleBody('P(Disease | Positive test) = (0.95 × 0.01) / 0.059 ≈ 0.161 → ~16% chance!'),
  exampleBody('⚠ Despite a 95% accurate test, a positive result only means ~16% chance of actually having the disease (because the disease is rare).'),

  exampleTitle('Factory Quality Control'),
  exampleBody('Factory A produces 60% of items, Factory B produces 40%. Defect rate: Factory A = 2%, Factory B = 5%.'),
  exampleBody('An item is found defective. What is the probability it came from Factory A?'),
  exampleBody(''),
  exampleBody('P(Defective) = 0.02×0.6 + 0.05×0.4 = 0.012 + 0.020 = 0.032'),
  exampleBody('P(Factory A | Defective) = (0.02 × 0.6) / 0.032 = 0.012/0.032 = 0.375 → 37.5%'),
  exampleBody('So even though A makes more items, only 37.5% of defects come from A.'),

  pageBreak(),

  // ═══════════════════════════════
  // 3. RANDOM VARIABLES
  // ═══════════════════════════════
  h1('3. Random Variables'),

  para('A random variable is a variable whose value is determined by the outcome of a random experiment. It converts outcomes into numbers for mathematical analysis.'),

  h2('3.1 Discrete vs Continuous'),

  twoColTable([
    ['Discrete Random Variable', 'Continuous Random Variable'],
    ['Countable values (0, 1, 2, …)', 'Any value in a range (e.g. 1.5, 2.73…)'],
    ['Obtained by COUNTING', 'Obtained by MEASUREMENT'],
    ['Uses Probability Mass Function (PMF)', 'Uses Probability Density Function (PDF)'],
    ['Example: No. of heads in 5 coin tosses', 'Example: Time taken to finish a task'],
    ['Example: No. of defective items in a batch', 'Example: Height of students in a class'],
    ['Example: No. of customers in a queue', 'Example: Daily temperature readings'],
  ]),

  keyNote('For a continuous variable, P(X = exact value) = 0. You can only find P(a ≤ X ≤ b).'),

  h2('3.2 Examples'),

  exampleTitle('Discrete – Number of heads when 3 coins are tossed'),
  exampleBody('Possible values: X = 0, 1, 2, 3'),
  exampleBody('P(X=0) = 1/8 (TTT)'),
  exampleBody('P(X=1) = 3/8 (HTT, THT, TTH)'),
  exampleBody('P(X=2) = 3/8 (HHT, HTH, THH)'),
  exampleBody('P(X=3) = 1/8 (HHH)'),
  exampleBody('Sum of all probabilities = 8/8 = 1 ✓'),

  exampleTitle('Continuous – Time for a customer to be served at a bank'),
  exampleBody('Service time X can be any value: 1 min, 2.3 min, 4.78 min, etc.'),
  exampleBody('We ask: P(1 ≤ X ≤ 3) = probability of being served between 1 and 3 minutes.'),
  exampleBody('This is found from the area under the PDF curve between 1 and 3.'),

  pageBreak(),

  // ═══════════════════════════════
  // 4. PROBABILITY DISTRIBUTIONS
  // ═══════════════════════════════
  h1('4. Probability Distributions'),

  // ──── BINOMIAL ────
  h2('4.1 Binomial Distribution'),

  para('Used when: Fixed number of trials (n), each trial has only 2 outcomes (Success/Failure), constant probability of success (p), trials are independent.'),

  formula('P(X = k) = C(n,k) × p^k × (1–p)^(n–k)'),
  formula('Mean = n×p          Variance = n×p×(1–p)          SD = √(n×p×q)'),

  h3('Properties'),
  bullet('X takes values 0, 1, 2, …, n  (discrete distribution)'),
  bullet('Mean (np) is ALWAYS greater than Variance (npq) since q < 1'),
  bullet('Symmetric when p = q = 0.5; skewed otherwise'),
  bullet('Additive: If X~B(n₁, p) and Y~B(n₂, p), then X+Y ~ B(n₁+n₂, p)'),

  h3('Examples'),
  exampleTitle('Quality Control – Defective Bulbs'),
  exampleBody('A manufacturer knows 10% of bulbs are defective. A box of 20 bulbs is inspected.'),
  exampleBody('n = 20, p = 0.10, q = 0.90'),
  exampleBody('P(exactly 2 defective) = C(20,2) × (0.1)² × (0.9)¹⁸'),
  exampleBody('                       = 190 × 0.01 × 0.1501 ≈ 0.285 → ~28.5% chance'),
  exampleBody('Mean = 20×0.1 = 2 defectives expected per box'),
  exampleBody('Variance = 20×0.1×0.9 = 1.8'),

  exampleTitle('Marketing – Email Response Rate'),
  exampleBody('A company sends 50 promotional emails. Historical response rate = 30%.'),
  exampleBody('n = 50, p = 0.30'),
  exampleBody('Expected responses (Mean) = 50 × 0.30 = 15 customers'),
  exampleBody('Variance = 50 × 0.3 × 0.7 = 10.5,  SD = √10.5 ≈ 3.24'),
  exampleBody('P(exactly 10 respond) = C(50,10) × (0.3)¹⁰ × (0.7)⁴⁰  ← calculate with tables/software'),

  exampleTitle('HR – Job Interview Selections'),
  exampleBody('10 candidates are interviewed. Each has a 40% chance of being selected.'),
  exampleBody('n = 10, p = 0.40'),
  exampleBody('Mean = 4 candidates expected to be selected'),
  exampleBody('P(selecting 0 out of 10) = (0.6)¹⁰ ≈ 0.006 → very unlikely to select nobody'),

  // ──── POISSON ────
  h2('4.2 Poisson Distribution'),

  para('Used when: Counting events in a fixed interval (time/space), events are random and independent, average rate λ (lambda) is known and constant.'),

  formula('P(X = k) = (e^(–λ) × λ^k) / k!'),
  formula('Mean = λ          Variance = λ          (both are equal!)'),

  h3('Examples'),

  exampleTitle('Call Centre – Incoming Calls'),
  exampleBody('A helpline receives an average of 6 calls per hour (λ = 6).'),
  exampleBody('P(exactly 4 calls in the next hour) = (e^(–6) × 6⁴) / 4!'),
  exampleBody('= (0.00248 × 1296) / 24 ≈ 0.134 → ~13.4% chance'),
  exampleBody(''),
  exampleBody('P(0 calls in an hour) = e^(–6) ≈ 0.0025 → almost impossible to have 0 calls'),

  exampleTitle('Traffic Accidents at a Junction'),
  exampleBody('On average, 2 accidents occur per week at a busy junction (λ = 2).'),
  exampleBody('P(no accident in a week) = e^(–2) ≈ 0.135 → ~13.5% chance'),
  exampleBody('P(exactly 3 accidents) = (e^(–2) × 2³) / 3! = (0.135 × 8) / 6 ≈ 0.180'),

  exampleTitle('Website Server – Error Logs'),
  exampleBody('A server averages 3 errors per day (λ = 3).'),
  exampleBody('P(more than 0 errors) = 1 – P(0 errors) = 1 – e^(–3) = 1 – 0.050 = 0.950'),
  exampleBody('There is a 95% chance of at least one error occurring in any given day.'),

  keyNote('When λ is large (>30), Poisson distribution approximates a Normal distribution.'),

  // ──── EXPONENTIAL ────
  h2('4.3 Exponential Distribution'),

  para('Used to model the WAITING TIME between consecutive Poisson events. While Poisson counts "how many," Exponential answers "how long until the next one."'),

  formula('f(x) = λ × e^(–λx)   for x ≥ 0'),
  formula('Mean = 1/λ          Variance = 1/λ²'),

  h3('Memoryless Property'),
  para('The remaining waiting time does not depend on how long you have already waited.'),
  exampleBody('If buses arrive every 10 minutes on average and you have already waited 5 minutes, the expected ADDITIONAL wait is still 10 minutes – the past waiting time is "forgotten."'),

  h3('Examples'),

  exampleTitle('Call Centre – Time Between Calls'),
  exampleBody('Calls arrive at rate λ = 5 per hour. Time between calls follows Exp(λ=5).'),
  exampleBody('Average time between calls = 1/5 hour = 12 minutes'),
  exampleBody('P(next call within 6 minutes = 0.1 hr) = 1 – e^(–5×0.1) = 1 – e^(–0.5) ≈ 0.393'),
  exampleBody('~39% chance the next call arrives within 6 minutes.'),

  exampleTitle('Machine Component Lifespan'),
  exampleBody('A machine component fails on average after 200 hours of use (λ = 1/200).'),
  exampleBody('P(component survives past 300 hours) = e^(–300/200) = e^(–1.5) ≈ 0.223'),
  exampleBody('Only about 22% of components last longer than 300 hours.'),

  pageBreak(),

  // ──── NORMAL ────
  h2('4.4 Normal Distribution'),

  para('The Normal (Gaussian) distribution is the most widely used. It describes many natural phenomena. Its bell-shaped curve is symmetric around the mean (μ).'),

  formula('f(x) = (1 / (σ√(2π))) × e^(–(x–μ)² / (2σ²))'),
  formula('Mean = μ     Variance = σ²     Standard Deviation = σ'),

  h3('Key Properties'),
  bullet('Symmetric: Mean = Median = Mode (all at the centre)'),
  bullet('68% of data lies within μ ± 1σ'),
  bullet('95% of data lies within μ ± 2σ'),
  bullet('99.7% of data lies within μ ± 3σ   (the "68-95-99.7 rule")'),
  bullet('Total area under the curve = 1'),
  bullet('Smaller σ → tall, narrow curve; Larger σ → short, wide curve'),

  h3('Standardisation (Z-score)'),
  para('Any Normal distribution can be converted to a Standard Normal (μ=0, σ=1) using:'),
  formula('Z = (X – μ) / σ'),
  para('Z tells you how many standard deviations X is from the mean. Use Z-tables to find probabilities.'),

  h3('Examples'),

  exampleTitle('Exam Scores in a Class'),
  exampleBody('Average score μ = 70, Standard deviation σ = 10.'),
  exampleBody(''),
  exampleBody('What % of students score between 60 and 80?'),
  exampleBody('60 = μ – 1σ,  80 = μ + 1σ → within 1 SD → 68% of students'),
  exampleBody(''),
  exampleBody('What is the Z-score for a student who scored 85?'),
  exampleBody('Z = (85 – 70) / 10 = 1.5 → 1.5 SD above the mean'),
  exampleBody('From Z-table: P(X < 85) ≈ 0.933 → student scored better than ~93% of class'),

  exampleTitle('Manufacturing – Bottled Water Volume'),
  exampleBody('Bottles filled with mean = 500 ml, SD = 5 ml.'),
  exampleBody('P(bottle contains < 490 ml)?'),
  exampleBody('Z = (490 – 500) / 5 = –2.0'),
  exampleBody('P(Z < –2) = 0.0228 → Only ~2.3% of bottles are underfilled below 490 ml.'),
  exampleBody('This helps in quality control – we know how often under/overfilling will occur.'),

  exampleTitle('Heights of Students'),
  exampleBody('Heights: μ = 165 cm, σ = 8 cm'),
  exampleBody('P(height between 157 and 173)?'),
  exampleBody('= P(165–8 < X < 165+8) = P(μ–σ < X < μ+σ) = 68%'),
  exampleBody('Most students (68%) have heights between 157 cm and 173 cm.'),

  pageBreak(),

  // ═══════════════════════════════
  // 5. CENTRAL LIMIT THEOREM
  // ═══════════════════════════════
  h1('5. Central Limit Theorem (CLT)'),

  para('The CLT states: As sample size (n) increases, the distribution of sample means (x̄) approaches a Normal distribution, regardless of the shape of the original population distribution.'),

  formula('Distribution of x̄:    Mean = μ,    Standard Error (SE) = σ / √n'),

  h2('5.1 Why CLT Is Powerful'),
  bullet('The original data can be skewed, uniform, or any shape – the sample means will still be normally distributed for large n.'),
  bullet('As n increases, the sample means cluster more tightly around the true population mean.'),
  bullet('Standard Error (σ/√n) gets smaller as n grows → larger samples = more precise estimates.'),
  bullet('Enables hypothesis testing and confidence intervals for ANY population distribution.'),

  h2('5.2 Conditions for CLT to Work'),
  bullet('Random Sampling: Every individual has equal chance of selection.'),
  bullet('Independence: Observations do not influence each other (sample < 10% of population).'),
  bullet('Sample Size: n ≥ 30 is the common guideline (larger if population is highly skewed).'),
  bullet('Finite Mean and Variance: Population must have defined μ and σ².'),

  h2('5.3 Examples'),

  exampleTitle('Average Salary in a Company'),
  exampleBody('A company has 5,000 employees with skewed salary distribution (many low, few very high).'),
  exampleBody('Population mean μ = ₹50,000, SD σ = ₹15,000.'),
  exampleBody(''),
  exampleBody('We take random samples of n = 100 employees and calculate average salary each time.'),
  exampleBody('By CLT, the distribution of sample means ~ Normal with:'),
  exampleBody('   Mean = ₹50,000'),
  exampleBody('   SE = 15,000 / √100 = ₹1,500'),
  exampleBody(''),
  exampleBody('P(sample mean > ₹52,000) = P(Z > (52000–50000)/1500) = P(Z > 1.33) ≈ 0.092 → ~9%'),

  exampleTitle('Dice Roll Simulation'),
  exampleBody('A single die has a uniform (NOT normal) distribution: each face (1–6) has P = 1/6.'),
  exampleBody('Population mean μ = 3.5, SD σ ≈ 1.71'),
  exampleBody(''),
  exampleBody('Take 50 samples, each of size n = 30 dice rolls. Compute mean of each sample.'),
  exampleBody('By CLT, those 50 sample means will form an approximately Normal distribution!'),
  exampleBody('SE = 1.71/√30 ≈ 0.312'),
  exampleBody(''),
  exampleBody('This is why polling companies can predict election outcomes from just ~1,000 survey responses.'),

  exampleTitle('Customer Wait Times'),
  exampleBody('A supermarket checkout has exponentially distributed wait times, μ = 4 min, σ = 4 min.'),
  exampleBody('Take 36 random customers. What is P(sample mean wait > 5 minutes)?'),
  exampleBody('SE = 4 / √36 = 4/6 ≈ 0.667'),
  exampleBody('Z = (5 – 4) / 0.667 = 1.5'),
  exampleBody('P(Z > 1.5) = 1 – 0.9332 = 0.0668 → ~6.7% chance'),

  keyNote('CLT requires n ≥ 30. With n < 30, use t-distribution instead for inference.'),

  pageBreak(),

  // ═══════════════════════════════
  // 6. QUICK COMPARISON TABLE
  // ═══════════════════════════════
  h1('6. Quick Reference – All Distributions'),

  new Table({
    width: { size: 100, type: WidthType.PERCENTAGE },
    rows: [
      new TableRow({
        tableHeader: true,
        children: ['Distribution', 'Type', 'Use Case', 'Mean', 'Variance', 'Key Parameter'].map(h =>
          new TableCell({
            children: [new Paragraph({ children: [new TextRun({ text: h, bold: true, size: 20 })] })],
            shading: { type: ShadingType.SOLID, color: '1F3864' },
            margins: { top: 60, bottom: 60, left: 100, right: 100 },
            verticalAlign: VerticalAlign.CENTER,
          })
        ),
      }),
      ...([
        ['Binomial', 'Discrete', 'Fixed trials, 2 outcomes each', 'np', 'npq', 'n, p'],
        ['Poisson', 'Discrete', 'Count events in fixed interval', 'λ', 'λ', 'λ (rate)'],
        ['Exponential', 'Continuous', 'Waiting time between events', '1/λ', '1/λ²', 'λ (rate)'],
        ['Normal', 'Continuous', 'Natural phenomena, CLT', 'μ', 'σ²', 'μ, σ'],
      ]).map((row, idx) =>
        new TableRow({
          children: row.map(cell =>
            new TableCell({
              children: [new Paragraph({ children: [new TextRun({ text: cell, size: 19 })] })],
              shading: { type: ShadingType.SOLID, color: idx % 2 === 0 ? 'F2F2F2' : 'FFFFFF' },
              margins: { top: 60, bottom: 60, left: 100, right: 100 },
            })
          ),
        })
      ),
    ],
  }),

  new Paragraph({ spacing: { after: 200 } }),

  // ═══════════════════════════════
  // 7. MEMORY AIDS
  // ═══════════════════════════════
  h1('7. Memory Aids & Quick Reminders'),

  h2('When to use which distribution?'),
  bullet('Binomial → "How many successes in n fixed trials?" (pass/fail, yes/no, defective/good)'),
  bullet('Poisson → "How many events in a given time/space?" (calls/hour, accidents/week)'),
  bullet('Exponential → "How long until the next event?" (waiting time, lifespan, inter-arrival time)'),
  bullet('Normal → "Data is continuous and bell-shaped" (heights, weights, scores, measurement errors)'),

  h2('Formulas at a Glance'),
  formula('Conditional:    P(A|B) = P(A∩B) / P(B)'),
  formula('Bayes:          P(A|B) = P(B|A) × P(A) / P(B)'),
  formula('Binomial PMF:   P(X=k) = C(n,k) × pᵏ × qⁿ⁻ᵏ'),
  formula('Poisson PMF:    P(X=k) = e⁻λ × λᵏ / k!'),
  formula('Normal Z-score: Z = (X – μ) / σ'),
  formula('CLT Std Error:  SE = σ / √n'),

  keyNote('Poisson mean = variance = λ. This is a unique and testable property!'),
  keyNote('Normal distribution: 68% within ±1σ, 95% within ±2σ, 99.7% within ±3σ'),
  keyNote('Exponential is memoryless: P(X > s+t | X > s) = P(X > t)'),

];

const doc = new Document({
  sections: [{ children }],
  styles: {
    paragraphStyles: [
      {
        id: 'Heading1',
        name: 'Heading 1',
        run: { size: 32, bold: true, color: '1F3864' },
        paragraph: { spacing: { before: 400, after: 200 } },
      },
      {
        id: 'Heading2',
        name: 'Heading 2',
        run: { size: 26, bold: true, color: '2E74B5' },
        paragraph: { spacing: { before: 300, after: 150 } },
      },
      {
        id: 'Heading3',
        name: 'Heading 3',
        run: { size: 23, bold: true, color: '375623' },
        paragraph: { spacing: { before: 200, after: 100 } },
      },
    ],
  },
});

Packer.toBuffer(doc).then(buffer => {
  fs.writeFileSync('/home/daytona/workspace/probability-notes/UNIT_V_Probability_Notes.docx', buffer);
  console.log('Created successfully!');
}).catch(err => {
  console.error('Error:', err);
  process.exit(1);
});
Running Command

cd /home/daytona/workspace/probability-notes && node create_notes.js

Running Command

python3 /home/daytona/skills/docx/scripts/office/validate.py /home/daytona/workspace/probability-notes/UNIT_V_Probability_Notes.docx

Running Command

python3 -c " from pypdf import PdfReader # Quick test to verify the docx file exists and has a reasonable size import os path = '/home/daytona/workspace/probability-notes/UNIT_V_Probability_Notes.docx' size = os.path.getsize(path) print(f'File size: {size} bytes ({size/1024:.1f} KB)') print('File exists and looks valid!' if size > 10000 else 'File seems too small!') "

The notes document is ready. Here's your download link:

UNIT V Probability Notes

Word Document · DOCX


Here's a summary of everything covered in the notes:

What's in the Notes

The document is structured into 7 sections with highlighted examples, formula boxes, shaded example panels, and quick-reference tables:

1. Probability – Core Concepts

  • Basic formula, independent vs dependent events
  • Addition Rule with die-roll example
  • Multiplication Rule with coloured-balls example
  • Conditional Probability with a student-subject example

2. Bayes' Theorem

  • Formula + all key terms (Prior, Posterior, Likelihood, Joint) in a table
  • Medical test example (shows the "base rate fallacy" – a 95% accurate test only gives 16% true-positive chance if disease is rare)
  • Factory defect example (which factory produced the defective item?)

3. Random Variables

  • Discrete vs Continuous comparison table with examples
  • PMF vs PDF explained simply

4. Probability Distributions

DistributionAdded Examples
BinomialDefective bulbs, email marketing, HR interviews
PoissonCall centre, traffic accidents, server error logs
ExponentialTime between calls, machine lifespan
NormalExam scores with Z-scores, bottled water quality control, student heights

5. Central Limit Theorem

  • Why it's powerful, all 4 conditions explained clearly
  • Examples: skewed salary data, dice simulation, supermarket wait times

6. Quick Reference Table

  • All 4 distributions side by side (type, use case, mean, variance, parameters)

7. Memory Aids

  • "When to use which?" decision guide
  • All key formulas in one place
  • 3 highlighted key-point reminders
This is a shared conversation. Sign in to Orris to start your own chat.