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

Lognormal Distribution and Positive Quantities

Modeling positive amounts in log space.

2:37 clip3:30:08–3:32:46 in the full courseWatch on YouTube

Transcript

20 sentences · select one to jump there

Check your understanding

What does exp(mu) represent for this lognormal model?

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.

066-lognormal-distribution-and-positive-quantities.ts
Start from GitHub
/**
 * Fintech Math Bootcamp · Lesson 066 of 120
 * Lognormal Distribution and Positive Quantities
 * Module 07: Probability Distributions and Simulation Basics
 *
 * Scenario: Modeling positive amounts in log space
 * Rule:     Y=exp(X), X~Normal(μ,σ²)
 *
 * Try it:   What does exp(mu) represent for this lognormal model?
 *
 * Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/probability-distributions-and-simulation-basics/lognormal-distribution-and-positive-quantities/
 * Free course:    https://courses.thefintechbuilder.com
 * Synthetic teaching example, not financial advice or a production library.
 */

export function lesson066() {
  const mu=Math.log(100), sigma=.2;
  const result={median:Math.exp(mu),
    mean:Math.exp(mu+sigma*sigma/2),
    mode:Math.exp(mu-sigma*sigma)};
  return result;
}

export const checkedResult = {"median":100.00000000000004,"mean":102.02013400267558,"mode":96.07894391523236};

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

Your output

Press Run to execute the code in your browser.

Expected output

{
  "median": 100.00000000000004,
  "mean": 102.02013400267558,
  "mode": 96.07894391523236
}

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

Lesson notes

The rule

Y=exp(X), X~Normal(μ,σ²)