# Christiano-Fitzgerald Filter

`D09-F05-A04` · Statistical Time Series → Decomposition and Cycles · archetype `record-transform` · difficulty 4/5 · verification **contract**

Full page: https://docs.thefintechbuilder.com/statistical-time-series/decomposition-and-cycles/christiano-fitzgerald-filter/
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 { cfFilter } from "fintech-algorithms/statistical-time-series/decomposition-and-cycles/christiano-fitzgerald-filter";
```

## Signature

```ts
cfFilter(values, low, high, drift)
```

An asymmetric band-pass filter that uses the whole sample, so unlike Baxter-King it produces values at the ends. The trade is that the filter weights differ at each observation, which makes it non-stationary by construction.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `values` | `number[]` | yes | Observation series. |
| `low` | `number` | yes | Shortest cycle length to retain. · min: 1, integer: true |
| `high` | `number` | yes | Longest cycle length to retain. · min: 1, integer: true |
| `drift` | `boolean` | no | Whether to remove a linear drift before filtering. |

## Returns

`{ cycle, trend }`

The cycle component over the full sample length.

## Errors

- When low ≥ high — throws

## Complexity

Time `O(n²)`, space `O(n)`.

## Worked example

Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.

### Input

`values`:

```json
[
  100.0901805654,
  101.3367333472,
  102.4083163971,
  102.9128416721,
  103.198587938,
  102.4311805579
]
```

Showing 6 of 192 elements.

`low`:

```json
6
```

`high`:

```json
32
```

`drift`:

```json
true
```

### Call

```ts
cfFilter(values, low, high, drift)
```

### Returns

object with 7 fields: cycle, trend, drift_line, low_period, high_period, drift_removed_before_filtering, reconstruction_max_error

```json
{
  "cycle": [
    -0.9710232193903039,
    -0.24888106131204424,
    0.6369705111805075,
    1.3312619134532966,
    1.5158058129594352,
    1.0859129088320714
  ],
  "trend": [
    101.06120378479031,
    101.58561440851204,
    101.77134588591949,
    101.58157975864671,
    101.68278212504057,
    101.34526764906794
  ],
  "drift_line": [
    0,
    0.03320258794921465,
    0.0664051758984293,
    0.09960776384764396,
    0.1328103517968586,
    0.16601293974607326
  ],
  "low_period": 6,
  "high_period": 32,
  "drift_removed_before_filtering": true,
  "reconstruction_max_error": 7.105427357601002e-15
}
```

## Other exports

`stlDecompose`, `hpFilter`, `bkFilter`, `fftPeriodogram`, `haarWavelet`, `runTopic`. Every module additionally exports `run` as an alias of its primary
function, and a `meta` object carrying its catalog id, domain, family, shape and article URL.

## Verification and provenance

Tier: **contract**.

The module loads, the entry point is callable and its declared signature matches the compiled code. The example below is real captured output, but no independently published figure asserts the numbers.

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.1.
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/statistical-time-series/decomposition-and-cycles/christiano-fitzgerald-filter/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/statistical-time-series/decomposition-and-cycles/christiano-fitzgerald-filter/impl.ts
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/statistical-time-series/llms.txt
