---
title: Statistical Prediction
slug: litmusedge/statistical-prediction
docTags: 
createdAt: 2024-08-06T18:57:15.600Z
---

The Statistical Prediction processor forecasts future values by applying a Fast Fourier Transform (FFT) to a time series signal.

## Why use Statistical Prediction

Use this processor when a signal has a repeating or cyclical pattern that a straight-line trend, like Linear Prediction's, wouldn't capture, for example, forecasting a signal with seasonal or periodic behavior using its underlying frequency components.

## How it works

The processor applies an FFT to the signal, uses that to remove the trend from the data, and generates a sine-cosine waveform that approximates the signal. It then extrapolates that waveform forward to produce the prediction.

Because live data streams in continuously, the processor first fills a window of values it can analyze, then produces a prediction for a future time. No output is expected until the window is full; once it is, the processor outputs a prediction and its timestamp on every subsequent input. The processor assumes the input tag polls once per second.

Two parameters shape the frequency analysis:

- **Frequency Difference** sets the sampling rate for the frequency analysis. With a 10-value window, a difference of `1` produces up to 10 frequency samples, and a difference of `2` produces up to five. Since this is a time series signal already sampled once per second, `1` is usually the right choice.
- **Number of Harmonics** sets how many waves are added to the fundamental wave to approximate the signal. Some signals, such as square waves, need a very large number of harmonics to approximate well. Start with a low number and increase it only as needed, rather than entering a high number from the start.

## Parameters

| **Parameter**                           | **Details**                                                                                                            |
| --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| Display Prediction On Current Timestamp | When enabled, displays the prediction using the payload's current timestamp instead of the predicted future timestamp. |
| Window Size                             | How many values the processor observes before making each prediction, assuming the input polls once per second.        |
| Number of Predictions                   | How many seconds into the future the processor predicts, assuming the input polls once per second.                     |
| Frequency Difference                    | The frequency sampling distance (in seconds) that sets the resolution of the frequency analysis.                       |
| Number of Harmonics                     | How many waves the processor adds to the fundamental wave to approximate the signal.                                   |
| Pass Through Value                      | Determines whether the processor's output is the predicted value or the original unchanged input value.                |

# Related topics

- [Use the Statistical Prediction Function](docId\:mUpb8RycuvJ6KDEmFUsev)
