Module 8 · Sampling, Estimation, and Statistical Inference Lesson 73 of 120

Estimator Bias, Consistency, Efficiency, and Robustness

Comparing estimators on error rather than a fashionable label.

2:44 clip3:54:35–3:57:20 in the full courseWatch on YouTube

Transcript

23 sentences · select one to jump there

Check your understanding

Does shifting every estimate by one change its variance?

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.

073-estimator-bias-consistency-efficiency-and-robustness.ts
Start from GitHub
/**
 * Fintech Math Bootcamp · Lesson 073 of 120
 * Estimator Bias, Consistency, Efficiency, and Robustness
 * Module 08: Sampling, Estimation, and Statistical Inference
 *
 * Scenario: Comparing estimators on error rather than a fashionable label
 * Rule:     MSE = variance + bias²
 *
 * Try it:   Does shifting every estimate by one change its variance?
 *
 * Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/sampling-estimation-and-statistical-inference/estimator-bias-consistency-efficiency-and-robustness/
 * Free course:    https://courses.thefintechbuilder.com
 * Synthetic teaching example, not financial advice or a production library.
 */

export function lesson073() {
  const truth=10, estimates=[9,10,11];
  const avg=(a:number[])=>a.reduce((s,x)=>s+x,0)/a.length;
  const mean=avg(estimates), bias=mean-truth;
  const variance=avg(estimates.map(x=>(x-mean)**2));
  const mse=avg(estimates.map(x=>(x-truth)**2));
  const result={bias,variance,mse};
  return result;
}

export const checkedResult = {"bias":0,"variance":0.6666666666666666,"mse":0.6666666666666666};

// Run this file directly: npx tsx lessons/08-sampling-estimation-and-statistical-inference/073-estimator-bias-consistency-efficiency-and-robustness.ts
if (process.argv[1] && import.meta.url.endsWith(process.argv[1].replace(/\\/g, "/").split("/").pop()!)) {
  console.log(JSON.stringify(lesson073(), null, 2));
}

Your output

Press Run to execute the code in your browser.

Expected output

{
  "bias": 0,
  "variance": 0.6666666666666666,
  "mse": 0.6666666666666666
}

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

Lesson notes

The rule

MSE = variance + bias²