Module 7 · Probability Distributions and Simulation Basics Lesson 69 of 120

Mixture Distributions, Multimodality, and Fat Tails

Separating customer groups instead of forcing one average distribution.

2:41 clip3:38:00–3:40:41 in the full courseWatch on YouTube

Transcript

20 sentences · select one to jump there

Check your understanding

Why is average component variance insufficient?

Choose one answer

Code lab

Run it yourself

The lesson source in 7 languages. Edit it, run TypeScript and Python right here, and compare with the expected output.

069-mixture-distributions-multimodality-and-fat-tails.ts
Start from GitHub
/**
 * Fintech Math Bootcamp · Lesson 069 of 120
 * Mixture Distributions, Multimodality, and Fat Tails
 * Module 07: Probability Distributions and Simulation Basics
 *
 * Scenario: Separating customer groups instead of forcing one average distribution
 * Rule:     mixture mean = Σwμ; variance = Σw[σ²+(μ−μmix)²]
 *
 * Try it:   Why is average component variance insufficient?
 *
 * Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/probability-distributions-and-simulation-basics/mixture-distributions-multimodality-and-fat-tails/
 * Free course:    https://courses.thefintechbuilder.com
 * Synthetic teaching example, not financial advice or a production library.
 */

export function lesson069() {
  const weights=[.8,.2], means=[1,5], variances=[1,1];
  const mean=weights.reduce((s,w,i)=>s+w*means[i],0);
  const variance=weights.reduce((s,w,i)=>s+w*(variances[i]+(means[i]-mean)**2),0);
  const result={mean,variance};
  return result;
}

export const checkedResult = {"mean":1.8,"variance":3.560000000000001};

// Run this file directly: npx tsx lessons/07-probability-distributions-and-simulation-basics/069-mixture-distributions-multimodality-and-fat-tails.ts
if (process.argv[1] && import.meta.url.endsWith(process.argv[1].replace(/\\/g, "/").split("/").pop()!)) {
  console.log(JSON.stringify(lesson069(), null, 2));
}

Your output

Press Run to execute the code in your browser.

Expected output

{
  "mean": 1.8,
  "variance": 3.560000000000001
}

Prefer your own machine? Every file is in the course repository · open it in Codespaces.

Lesson notes

The rule

mixture mean = Σwμ; variance = Σw[σ²+(μ−μmix)²]