Module 10 · Financial Time-Series Foundations Lesson 99 of 120

Smoothing, Baselines, and Naive Forecasts

Giving an advanced forecast a simple baseline to beat.

2:31 clip5:16:38–5:19:09 in the full courseWatch on YouTube

Transcript

20 sentences · select one to jump there

Check your understanding

Do these in-sample smoothed values establish forecasting superiority?

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.

099-smoothing-baselines-and-naive-forecasts.ts
Start from GitHub
/**
 * Fintech Math Bootcamp · Lesson 099 of 120
 * Smoothing, Baselines, and Naive Forecasts
 * Module 10: Financial Time-Series Foundations
 *
 * Scenario: Giving an advanced forecast a simple baseline to beat
 * Rule:     SES levelₜ=αxₜ+(1−α)levelₜ₋₁
 *
 * Try it:   Do these in-sample smoothed values establish forecasting superiority?
 *
 * Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/financial-time-series-foundations/smoothing-baselines-and-naive-forecasts/
 * Free course:    https://courses.thefintechbuilder.com
 * Synthetic teaching example, not financial advice or a production library.
 */

export function lesson099() {
  const x=[10,12,9,11],alpha=.5;
  let level=x[0]; const levels=[level];
  for(const value of x.slice(1)){level=alpha*value+(1-alpha)*level;levels.push(level);}
  const result={levels,naiveNext:x.at(-1)!,sesNext:level};
  return result;
}

export const checkedResult = {"levels":[10,11,10,10.5],"naiveNext":11,"sesNext":10.5};

// Run this file directly: npx tsx lessons/10-financial-time-series-foundations/099-smoothing-baselines-and-naive-forecasts.ts
if (process.argv[1] && import.meta.url.endsWith(process.argv[1].replace(/\\/g, "/").split("/").pop()!)) {
  console.log(JSON.stringify(lesson099(), null, 2));
}

Your output

Press Run to execute the code in your browser.

Expected output

{
  "levels": [
    10,
    11,
    10,
    10.5
  ],
  "naiveNext": 11,
  "sesNext": 10.5
}

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

Lesson notes

The rule

SES levelₜ=αxₜ+(1−α)levelₜ₋₁