Statistical test for fractional cyclic long memory in time series
Project description
cyclical-fractional-test
cyclical-fractional-test is a research-oriented Python package for detecting
fractional cyclic long memory in time series.
The package implements the full test pipeline around candidate cyclic
frequencies R and fractional parameters D, including deterministic
Chebyshev bases, fractional cyclic filters, candidate scoring, diagnostics,
optional AR residual adjustments, and a small estimator-style wrapper for
prediction.
Features
- Periodogram and autocorrelogram helpers for exploratory analysis.
- Chebyshev deterministic design matrices with contiguous or explicit orders.
- Single-cycle and aggregate multi-cycle stochastic memory candidates.
- Adaptive coarse-to-fine search over
D, plus fixed-grid search when exact Cartesian evaluation is preferred. - White-noise, AR(1), and AR(2) residual error specifications.
TESTandTEST*statistics with top-k candidate ranking.- Diagnostics for the periodogram, search grid, variance definitions, and retained candidates.
CyclicalFractionalModelwithfit,predict, recursive prediction, and prediction intervals.
The runtime dependency footprint is intentionally small: the package depends on NumPy only.
Installation
From PyPI, once released:
python3 -m pip install cyclical-fractional-test
For local development:
git clone https://github.com/aslanda-design/log_memory_cycles.git
cd log_memory_cycles
python3 -m pip install -e ".[dev,docs]"
Python 3.11 or newer is required.
Quickstart
import numpy as np
from cyclical_fractional_test import (
CyclicalTestConfig,
compute_periodogram,
run_cyclical_fractional_test,
)
rng = np.random.default_rng(42)
T = 240
t = np.arange(T, dtype=float)
y = np.cos(2.0 * np.pi * 12 * t / T) + 0.25 * rng.standard_normal(T)
lambdas, periodogram = compute_periodogram(y)
result = run_cyclical_fractional_test(
y,
config=CyclicalTestConfig(
n_deterministic_cycles=4,
r_window=5,
top_k=3,
error_model="ar1",
),
)
best = result.best_result
print(best.cycles)
print(best.test_value)
print(result.diagnostics.n_candidates_evaluated)
By default, the test uses an adaptive D search. To evaluate a fixed Cartesian
grid instead:
result = run_cyclical_fractional_test(
y,
config=CyclicalTestConfig(
d_search_strategy="fixed_grid",
d_grid=np.array([0.0, 0.25, 0.5, 0.75, 1.0]),
r_window=5,
top_k=3,
),
)
Estimator API
CyclicalFractionalModel wraps the test in a scikit-learn-style interface.
from cyclical_fractional_test import CyclicalFractionalModel
model = CyclicalFractionalModel(
n_deterministic_cycles=4,
error_model="ar1",
).fit(y)
in_sample = model.predict(len(y))
forecast = model.predict(len(y) + 20)
lower, upper = model.predict_interval(len(y) + 20, alpha=0.05)
The fitted model exposes selected-cycle attributes such as cycles_, R_,
D_, betas_, ar_coefficients_, innovation_variance_, and result_.
Documentation
Markdown documentation lives in docs/:
- Quickstart
- API reference
- Mathematical background
- Original test mapping
- Data-flow diagram
- Implementation notes
- Development guide
- Publishing guide
Preview the documentation locally with:
python3 -m mkdocs serve
Development
Run tests:
python3 -m pytest
Run tests with coverage:
python3 -m pytest --cov=cyclical_fractional_test --cov-report=term-missing
Build and validate distribution artifacts:
python3 -m build
python3 -m twine check dist/*
Local datasets, notebooks, generated figures, and model artifacts are kept out
of the published package by MANIFEST.in.
Citation
Citation metadata is provided in CITATION.cff.
License
This project is released under the MIT License. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cyclical_fractional_test-0.1.0.tar.gz.
File metadata
- Download URL: cyclical_fractional_test-0.1.0.tar.gz
- Upload date:
- Size: 87.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0e6f9848b2dbeea67c10bda3d2e931bfe9e8645e6e30abd73a2d8b5a3cb44e2
|
|
| MD5 |
902f7a15edf80e9df9048d0635bb5da7
|
|
| BLAKE2b-256 |
008e5d5f0f7417d0e3457052a194b34bf3e3042e2eb4dc33999b4bbdcbcdba81
|
File details
Details for the file cyclical_fractional_test-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cyclical_fractional_test-0.1.0-py3-none-any.whl
- Upload date:
- Size: 50.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65df8039107621a6b85514858c37cba3f5a62e08c39a47df631c0e1ac745862e
|
|
| MD5 |
12c44f87981542b5aa41a5be7fca69a6
|
|
| BLAKE2b-256 |
51794612e82af0b03d64de2397966ab43e4e89ce0e41fbeff974d20d22a3c174
|