Skip to main content

Periodicity Detection

Detect the dominant period in univariate, equidistant time series data.

CI Documentation Status codecov PyPI package License: MIT python version 3.10|3.11|3.12|3.13|3.14 Downloads


Toolbox for detecting the dominant period in univariate, equidistant time series data. The toolbox contains the following methods:

  • Autocorrelation
  • AutoPeriod
  • Fast Fourier Transform (FFT)
  • find_length
  • Python-adaption of the R package forecast's findfrequency function
  • Number of Peaks-method

📖 Periodicity Detection's documentation is hosted at https://periodicity-detection.readthedocs.io.

Recommended reading: Window Size Selection In Unsupervised Time Series Analytics: A Review and Benchmark: Workshop paper that compares the Autocorrelation, FFT (DFT in the paper), and AutoPeriod methods to three other methods (Code).

Installation

You can install Periodicity Detection as a package or from source.

Prerequisites

  • python >= 3.10, < 3.15
  • pip >= 20
pip install periodicity-detection

Installation from source

git clone git@github.com:CodeLionX/periodicity-detection.git
cd periodicity-detection
pip install .

Usage

Periodicity Detection can be used as a Python library or as a command line tool. Please refer to the package documentation for more information.

API

import numpy as np
import periodicity_detection as pyd

# Create sample data
data = np.sin(np.linspace(0, 40 * np.pi, 1000)) + np.random.default_rng(42).random(1000)

# Calculate period size using a specific method
period_size = pyd.findfrequency(data, detrend=True)
assert period_size == 50

# Calculate period size using the default method
period_size = pyd.estimate_periodicity(data)
assert period_size == 50

Plot of the example dataset:

Example dataset

CLI

$> periodicity --help
usage: periodicity [-h] [--version] [--use-initial-n USE_INITIAL_N]
                   [--channel CHANNEL]
                   dataset_path
                   {find-length,number-peaks,autocorrelation,fft,autoperiod,findfrequency}
                   ...

Detect the dominant period in univariate, equidistant time series data.

positional arguments:
  dataset_path          Path to the dataset for which the dominant period size
                        should be estimated.
  {find-length,number-peaks,autocorrelation,fft,autoperiod,findfrequency}
    find-length         Determine period size based on ACF as in the TSB-UAD
                        repository.
    number-peaks        Calculates the number of peaks of at least support n
                        in the time series and the time series length divided
                        by the number of peaks defines the period size.
    autocorrelation     Determine period size based on ACF.
    fft                 Determine period size based on FFT.
    autoperiod          AUTOPERIOD method calculates the period size in a two-
                        step process. First, it extracts candidate periods
                        from the periodogram. Then, it uses the circular
                        autocorrelation to validate the candidate periods.
    findfrequency       Determine period size using the method findfrequency
                        from the R forecast package. Re-implementation!

optional arguments:
  -h, --help            show this help message and exit
  --version             Show version number.
  --use-initial-n USE_INITIAL_N
                        Only use the n initial points of the dataset to
                        calculate the estimated period size.
  --channel CHANNEL     If the dataset is multivariate, use the channel on
                        this integer position. The first dimension is always
                        assumed to be the index and skipped over!

Metadata

Release files for periodicity-detection 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for periodicity-detection 0.2.0
File Size Uploaded
periodicity_detection-0.2.0.tar.gz 19.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for periodicity-detection 0.2.0
File Interpreter ABI Platform
periodicity_detection-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 41.0 kB

Release files / periodicity_detection-0.2.0.tar.gz

Download URL periodicity_detection-0.2.0.tar.gz
Size 19.3 kB
Tags Source
SHA-256 checksum
How to use checksums
02f3d3057bdacebc1a17cf077da13b218d4ab13703e265db398fef323637e7a4
BLAKE2b-256 checksum
How to use checksums
c74640f2fdd6a4fdaad1a05465e70d4f07899fe4e7f3cc18d26afdb81e1dd28f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 12, 2026.

Transparency log

Release files / periodicity_detection-0.2.0-py3-none-any.whl

Download URL periodicity_detection-0.2.0-py3-none-any.whl
Size 21.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6a6abe12f55bffe1c058d988c145c48319c8396c6a9564ca483ac1769a6d21ef
BLAKE2b-256 checksum
How to use checksums
29a8c910ce0790a36d702193ad31b96708d9cebc6bf75207b5eb040f85c0a8fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 12, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page