Module 3 · Data, Variables, Samples, and Measurement Lesson 27 of 120

Missing, Nonfinite, Censored, and Truncated Values

Unknown, nonfinite, censored, and absent from the sample.

2:40 clip1:24:18–1:26:59 in the full courseWatch on YouTube

Transcript

24 sentences · select one to jump there

Check your understanding

Is “income above 100,000” an exact value of 100,000?

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.

027-missing-nonfinite-censored-and-truncated-values.ts
Start from GitHub
/**
 * Fintech Math Bootcamp · Lesson 027 of 120
 * Missing, Nonfinite, Censored, and Truncated Values
 * Module 03: Data, Variables, Samples, and Measurement
 *
 * Scenario: Unknown, nonfinite, censored, and absent from the sample
 * Rule:     missing ≠ 0; censored ≠ truncated
 *
 * Try it:   Is “income above 100,000” an exact value of 100,000?
 *
 * Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/data-variables-samples-and-measurement/missing-nonfinite-censored-and-truncated-values/
 * Free course:    https://courses.thefintechbuilder.com
 * Synthetic teaching example, not financial advice or a production library.
 */

export function lesson027() {
  const values: unknown[] = [10, null, Infinity, "unknown", 20];
  const accepted = values.filter((x): x is number =>
    typeof x === "number" && Number.isFinite(x));
  const result = {accepted, excluded: values.length - accepted.length};
  return result;
}

export const checkedResult = {"accepted":[10,20],"excluded":3};

// Run this file directly: npx tsx lessons/03-data-variables-samples-and-measurement/027-missing-nonfinite-censored-and-truncated-values.ts
if (process.argv[1] && import.meta.url.endsWith(process.argv[1].replace(/\\/g, "/").split("/").pop()!)) {
  console.log(JSON.stringify(lesson027(), null, 2));
}

Your output

Press Run to execute the code in your browser.

Expected output

{
  "accepted": [
    10,
    20
  ],
  "excluded": 3
}

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

Lesson notes

The rule

missing ≠ 0; censored ≠ truncated