Module 4 · Location, Ranking, and Exploratory Summaries Lesson 32 of 120

Arithmetic Mean

The mean as a balance point, not a typical actual observation.

2:29 clip1:43:01–1:45:30 in the full courseWatch on YouTube

Transcript

20 sentences · select one to jump there

Check your understanding

If one observation increases by 10 in a five-row sample, how much does the mean increase?

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.

032-arithmetic-mean.ts
Start from GitHub
/**
 * Fintech Math Bootcamp · Lesson 032 of 120
 * Arithmetic Mean
 * Module 04: Location, Ranking, and Exploratory Summaries
 *
 * Scenario: The mean as a balance point, not a typical actual observation
 * Rule:     mean = Σx/n
 *
 * Try it:   If one observation increases by 10 in a five-row sample, how much does the mean increase?
 *
 * Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/location-ranking-and-exploratory-summaries/arithmetic-mean/
 * Free course:    https://courses.thefintechbuilder.com
 * Synthetic teaching example, not financial advice or a production library.
 */

export function lesson032() {
  const hours = [1, 2, 2, 4, 9];
  const total = hours.reduce((s,x) => s+x,0);
  const average = total / hours.length;
  const centeredSum = hours.reduce((s,x) => s+x-average,0);
  const result = {average, centeredSum};
  return result;
}

export const checkedResult = {"average":3.6,"centeredSum":-4.440892098500626e-16};

// Run this file directly: npx tsx lessons/04-location-ranking-and-exploratory-summaries/032-arithmetic-mean.ts
if (process.argv[1] && import.meta.url.endsWith(process.argv[1].replace(/\\/g, "/").split("/").pop()!)) {
  console.log(JSON.stringify(lesson032(), null, 2));
}

Your output

Press Run to execute the code in your browser.

Expected output

{
  "average": 3.6,
  "centeredSum": -4.440892098500626e-16
}

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

Lesson notes

The rule

mean = Σx/n