# Fast Fourier Transform Periodogram

`D09-F05-A05` · 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/fast-fourier-transform-periodogram/
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 { fftPeriodogram } from "fintech-algorithms/statistical-time-series/decomposition-and-cycles/fast-fourier-transform-periodogram";
```

## Signature

```ts
fftPeriodogram(values, sampleFrequency, detrend, window)
```

Estimates spectral power by frequency. Peaks suggest periodicity — but a trend leaks power across every frequency, which is why detrending is a parameter here rather than an afterthought.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `values` | `number[]` | yes | Observation series. |
| `sampleFrequency` | `number` | yes | Observations per unit time, which sets the units of the returned frequencies. · min: 0 |
| `detrend` | `boolean` | yes | Remove a linear trend before transforming. Leaving a trend in produces a spurious peak at the lowest frequency. |
| `window` | `string` | yes | Taper applied before the transform, reducing spectral leakage at the cost of resolution. |

## Returns

`{ frequencies, power, dominant_frequency, … }`

Power per frequency with the dominant one identified.

## Errors

- When sampleFrequency is not positive, or the window is unrecognised — throws

## Complexity

Time `O(n log 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.

`sampleFrequency`:

```json
1
```

`detrend`:

```json
"linear"
```

`window`:

```json
"boxcar"
```

### Call

```ts
fftPeriodogram(values, sampleFrequency, detrend, window)
```

### Returns

object with 12 fields: frequency, power_density, nfft, sample_frequency, window, detrend, removed_mean, removed_slope_per_observation, …

```json
{
  "frequency": [0, 0.00390625, 0.0078125, 0.01171875, 0.015625, 0.01953125],
  "power_density": [
    1.0488462970643929e-25,
    1.6358893918182345,
    4.265767680939771,
    5.308886555246375,
    0.7314454315603167,
    3.8642684877953584
  ],
  "nfft": 256,
  "sample_frequency": 1,
  "window": "boxcar",
  "detrend": "linear",
  "removed_mean": 103.83348592556456,
  "removed_slope_per_observation": 0.03635627769934048,
  "dominant_index": 21,
  "dominant_frequency": 0.08203125,
  "dominant_period": 12.19047619047619,
  "peak_power_share": 0.4300600995492311
}
```

## Other exports

`stlDecompose`, `hpFilter`, `bkFilter`, `cfFilter`, `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/fast-fourier-transform-periodogram/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/statistical-time-series/decomposition-and-cycles/fast-fourier-transform-periodogram/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
