# Estimator Bias, Consistency, Efficiency, and Robustness

`D00-F08-A03` · Financial Mathematics, Statistics, and Data Foundations → Sampling, Estimation, and Statistical Inference · archetype `record-transform` · difficulty 1/5 · verification **verified**

Full page: https://docs.thefintechbuilder.com/foundations/sampling-estimation-and-statistical-inference/estimator-bias-consistency-efficiency-and-robustness/
Agent skill: `npx skills add IslamBaraka90/Fintech-Algorithms-Library` — https://docs.thefintechbuilder.com/guides/agent-skill/

## Install and import

```bash
npm install fintech-algorithms
```

```ts
import { estimatorBiasConsistencyEfficiencyAndRobustness } from "fintech-algorithms/foundations/sampling-estimation-and-statistical-inference/estimator-bias-consistency-efficiency-and-robustness";
```

## Signature

```ts
estimatorBiasConsistencyEfficiencyAndRobustness(input)
```

Scores an estimator against a known truth: the average error of the replicated `estimates`, their mean squared error, a robust median estimate, and whether the mean squared error clears `mseBenchmark`.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `input` | `D00Input` | yes | One record. `estimates` holds one value per replication, `populationMean` is the truth they are scored against, and `mseBenchmark` is the mean squared error a competing estimator achieves. `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 `bias` (mean estimate minus `populationMean`), `mse`, `robustMedianEstimate` (the median of the estimates) and `efficient` (true when `mse` is at or below `mseBenchmark`).

## 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 log m)`, space `O(n + m)`.

## Worked example

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

### Input

`input`:

```json
{
  "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

```ts
estimatorBiasConsistencyEfficiencyAndRobustness(input)
```

### Returns

object with 2 fields: bias, mse

```json
{
  "bias": 0,
  "mse": 0.019999999999999983
}
```

## Verification and provenance

Tier: **verified** (via input-expected).

The worked example below is the figure published in this algorithm's article, replayed and asserted by the test suite on every build. The arithmetic cannot drift without the build failing.

Both tiers guarantee the signature. Full explanation: https://docs.thefintechbuilder.com/guides/verification/

Generated from the docs.json payload shipped inside fintech-algorithms@0.13.0.
The signature and parameter list are checked against the compiled implementation at build time,
so a description that contradicts the code fails the build rather than reaching this file.

## Links

- Article (how it works, step by step): https://thefintechbuilder.com/foundations/sampling-estimation-and-statistical-inference/estimator-bias-consistency-efficiency-and-robustness/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/foundations/sampling-estimation-and-statistical-inference/estimator-bias-consistency-efficiency-and-robustness/impl.ts
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/foundations/llms.txt
