Module 5 · Dispersion, Shape, and Robust Statistics Lesson 48 of 120

Z-Score, Robust Z-Score, and Standardization

Standardizing alerts without turning unusual into fraudulent.

2:32 clip2:30:13–2:32:45 in the full courseWatch on YouTube

Transcript

17 sentences · select one to jump there

Check your understanding

Does a robust z-score of 4.72 prove the transaction is fraudulent?

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.

048-z-score-robust-z-score-and-standardization.ts
Start from GitHub
/**
 * Fintech Math Bootcamp · Lesson 048 of 120
 * Z-Score, Robust Z-Score, and Standardization
 * Module 05: Dispersion, Shape, and Robust Statistics
 *
 * Scenario: Standardizing alerts without turning unusual into fraudulent
 * Rule:     z = (x−mean)/s; robust z = 0.67448975(x−median)/MAD
 *
 * Try it:   Does a robust z-score of 4.72 prove the transaction is fraudulent?
 *
 * Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/dispersion-shape-and-robust-statistics/z-score-robust-z-score-and-standardization/
 * Free course:    https://courses.thefintechbuilder.com
 * Synthetic teaching example, not financial advice or a production library.
 */

export function lesson048() {
  const observed = 9, mean = 3.6, sd = Math.sqrt(10.3);
  const median = 2, rawMAD: number = 1;
  const result = {z:(observed-mean)/sd,
    robustZ: rawMAD===0 ? null : .67448975*(observed-median)/rawMAD};
  return result;
}

export const checkedResult = {"z":1.6825777726943407,"robustZ":4.72142825};

// Run this file directly: npx tsx lessons/05-dispersion-shape-and-robust-statistics/048-z-score-robust-z-score-and-standardization.ts
if (process.argv[1] && import.meta.url.endsWith(process.argv[1].replace(/\\/g, "/").split("/").pop()!)) {
  console.log(JSON.stringify(lesson048(), null, 2));
}

Your output

Press Run to execute the code in your browser.

Expected output

{
  "z": 1.6825777726943407,
  "robustZ": 4.72142825
}

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

Lesson notes

The rule

z = (x−mean)/s; robust z = 0.67448975(x−median)/MAD