pyUTSAlgorithms (Unevenly Spaced Time Series Algorithms) Python package computes rolling statistics for uneven time series data.
Project description
pyUTSAlgorithms
Unevenly Spaced Time Series Algorithms
Unevenly Spaced Time Series (UTS) algorithms for moving averages, rolling operators, and peak detection. This repository provides a comprehensive set of tools to handle time series where observations are not recorded at regular intervals.
This library started as a conversion of the C++ code from andreas50/utsAlgorithms. It has since been expanded with additional algorithms specifically designed for unevenly spaced data.
Features
- Exponential Moving Averages (EMA): Supports
last,next, andlinearinterpolation schemes for numerical stability in UTS. - Simple Moving Averages (SMA): Efficient rolling window averages for uneven grids using
last,next, andlinearinterpolation. - Gradient Computation: Central first and second-order derivatives, and arbitrary order derivatives via Fornberg's algorithm.
- Peak and Valley Detection:
- Basic peak/valley identification.
- Significant peaks based on Z-score, Kneedle algorithm, or peak prominence.
- Rolling Operators: Generic rolling statistics (mean, variance, max, min, product, etc.) on unevenly spaced time intervals.
- Thresholding & Z-Score: Specialized utilities (like ISODATA) for data analysis and noise reduction in UTS.
Quick Start
import numpy as np
import uts.ema as ema
# Sample unevenly spaced data: (time, value)
data = np.array([
[0.0, 10.0],
[1.5, 12.0],
[2.1, 11.0],
[4.5, 15.0],
[5.0, 14.0]
])
# Compute EMA with a tau (half-life) of 1.0 using linear interpolation
results = ema.linear(data, tau=1.0)
print("Original Data:\n", data)
print("EMA Results:\n", results)
Running Unit Tests
Several unit tests were written to validate corner cases and ensure accuracy. The unit tests use the standard unittest framework.
python -m unittest
Documentation
The library is documented using Google-style docstrings. Detailed API documentation is available here.
To generate the documentation locally:
pip install pdoc
pdoc --math -d google -o docs src/uts
Installation
From PyPI
Install the latest version directly from PyPI:
pip install pyUTSAlgorithms
From Source
To install the library locally:
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install .
Authors
- Mário Antunes - mariolpantunes
License
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2020 Mário Antunes
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Project details
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 pyutsalgorithms-0.2.0.tar.gz.
File metadata
- Download URL: pyutsalgorithms-0.2.0.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bef593d6039f49d098be061f32f286d7bd79e442122d67542a4a56081b24549
|
|
| MD5 |
0297a1fa830432f6be4df2e599b1ad5f
|
|
| BLAKE2b-256 |
1e3686499368a0e2d37e17c9acae066b754a730bde9076ea5edb58f43c648626
|
File details
Details for the file pyutsalgorithms-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pyutsalgorithms-0.2.0-py3-none-any.whl
- Upload date:
- Size: 15.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
feb32c3c1e23fecf00dd59ffc16c4f3469ba1dd32c325ec3e7a24259c8950d6c
|
|
| MD5 |
9b47ee84cb1f4eac74c31e6806e255fa
|
|
| BLAKE2b-256 |
1a0d8de18fec246c04a4cd56af952517282dee4494ed1be00806a96f1432f98e
|