Average value calculation
Project description
pyavg
pyavg is a Python library that provides a set of classes for calculating averages from input data using various methods. It supports both basic and specialized smoothing and filtering algorithms.
Installation
You can install the library via PyPI:
pip install d3d4.pyavg
Key Features
The library offers classes for different average calculation methods, including:
- Basic Moving Average (bi_avg.Stat)
- Cumulative Average (cumulative.Stat)
- Exponential Smoothing (exp_smooth.Stat)
- PID Controller-Based Average (pid.Stat)
- Ring Buffer for Averaging (ring_buff.Stat)
- Advanced Smoothing Algorithms (smooth.Stat)
Each class implements a common interface, making it easy to switch between methods as needed.
Usage Examples
Basic Moving Average
from pyavg import BiAvgStat
# Create an object for moving average calculation
stat = BiAvgStat(window_size=5)
# Add values
stat.add(10)
stat.add(20)
stat.add(30)
# Get the current average
print(stat.get_average()) # -> 20.0
Cumulative Average
from pyavg import CumulativeStat
# Create an object for cumulative average calculation
stat = CumulativeStat()
# Add values
stat.add(10)
stat.add(20)
stat.add(30)
# Get the current average
print(stat.get_average()) # -> 20.0
Exponential Smoothing
from pyavg import ExpSmoothStat
# Create an object for exponential smoothing
stat = ExpSmoothStat(alpha=0.5)
# Add values
stat.add(10)
stat.add(20)
stat.add(30)
# Get the current smoothed value
print(stat.get_average()) # -> smoothed value
Documentation
Each class provides the following key methods:
add(value: float):adds a new value to the calculation.get_average() -> float:returns the current average.
For details on implementation and additional parameters, refer to the source code or library documentation.
Requirements
- Python 3.6 or higher.
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Contribution
If you’d like to contribute or add a new average calculation method, feel free to submit a Pull Request or reach out through GitHub Issues.
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 d3d4_pyavg-0.1.2.tar.gz.
File metadata
- Download URL: d3d4_pyavg-0.1.2.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.4.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac71ae4bd7049c885969398fa419a0c765558ba459d3a46f8091ba11c4aed8bc
|
|
| MD5 |
74a45b0ddf21e7be0582ad68c5fcad65
|
|
| BLAKE2b-256 |
ded0a6556b6418ef46712267b1ee25c533d9e04cd478b080339f341140435d3e
|
File details
Details for the file d3d4.pyavg-0.1.2-py3-none-any.whl.
File metadata
- Download URL: d3d4.pyavg-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.4.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa1cb3416efc2ab40d5e9703f43fdb66a9386e335e71db6850a40bff11a7ec62
|
|
| MD5 |
68fbaa7bd1f743d7cd7e67c13a6694d2
|
|
| BLAKE2b-256 |
6af068e865f982a0cd324fdb9f90f758e05703c5384e6c3b8f2df03a290f6b34
|