fintech-algorithms
Using a coding agent? Give it the skill: npx skills add IslamBaraka90/Fintech-Algorithms-Library What it does →

Central Limit Theorem

Install and import#

bash
npm install fintech-algorithms
ts
import { centralLimitTheorem } from "fintech-algorithms/foundations/sampling-estimation-and-statistical-inference/central-limit-theorem";

Signature#

centralLimitTheorem(input)

Standardises the replicated estimates in input.estimates by subtracting populationMean and dividing by their spread, then checks how close the standardised values sit to zero.

Parameters#

NameTypeNotes
inputD00InputOne record. estimates holds one sample mean per replication and populationMean is the value they are centred on. sample and alpha are validated for the whole family before dispatch.
sample: non-empty list of finite numbers, at least two of them · estimates: non-empty list of finite numbers · alpha: strictly between 0 and 1

Returns#

D00Output

An object with standardizedMeans (one per replication), center (their mean) and approximatelyCentered (true when center is within 0.5 of zero).

Errors#

  • When sample or estimates is missing, empty, or contains a non-finite number — both are parsed for every topic in the family, whether or not the topic uses them — throws RangeError
  • When sample holds fewer than two observations — throws RangeError
  • When alpha is not strictly between zero and one — throws RangeError
  • When estimates holds fewer than two values — throws RangeError

Complexity: time O(n + m), space O(n + m).

Worked example#

verified This is the worked example published in the article, replayed by the test suite on every run. The output cannot drift.

Input#

input
{
  "sample": [2, 3, 4, 3, 4],
  "estimates": [3, 3.1, 3.2, 3.3, 3.4],
  "populationMean": 3.2,
  "alpha": 0.05,
  "mseBenchmark": 0.1,
  "nullMean": 3,
  "alternativeMean": 3.5,
  "practicalThreshold": 0.1,
  "comparisons": 5
}

Call#

centralLimitTheorem(input)

Returns#

object with 2 fields: standardizedMeans, center

{
  "standardizedMeans": [
    -1.2649110640673535,
    -0.6324555320336768,
    0,
    0.6324555320336739,
    1.2649110640673507
  ],
  "center": -1.1546319456101628e-15
}

Diagrams#

Central Limit Theorem — article hero
Central Limit Theorem — calculation ledger
Central Limit Theorem — concept anatomy
Central Limit Theorem — failure boundary
Central Limit Theorem — method map
Central Limit Theorem — scenario contrast

How it works#

This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.

Read the article →

References#

The rest of the Sampling, Estimation, and Statistical Inference family#