Skip to main content

Average value calculation

Reason this release was yanked:

outdated

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 ehles.pyavg

Key Features

The library offers classes for different average calculation methods, including:

  1. Basic Moving Average (bi_avg.Stat)
  2. Cumulative Average (cumulative.Stat)
  3. Exponential Smoothing (exp_smooth.Stat)
  4. PID Controller-Based Average (pid.Stat)
  5. Ring Buffer for Averaging (ring_buff.Stat)
  6. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

d3d4_pyavg-0.1.1.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

d3d4.pyavg-0.1.1-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file d3d4_pyavg-0.1.1.tar.gz.

File metadata

  • Download URL: d3d4_pyavg-0.1.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.4.24

File hashes

Hashes for d3d4_pyavg-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d3580012242c1ade13ad0efa4cde74179a76d45ce9b70bec7813de8426f9881c
MD5 0b8f3503d266ee972d0ab278aab80484
BLAKE2b-256 bc572086af15ee7c7879683e2f0270682feb60b0944fb89a24697ea9f25a833e

See more details on using hashes here.

File details

Details for the file d3d4.pyavg-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: d3d4.pyavg-0.1.1-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

Hashes for d3d4.pyavg-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 61a74b4c3e69825b4911f57a487b7186e667765726e010f0f2711366319df580
MD5 4ef553356bcf36c817104a44fbd42b87
BLAKE2b-256 fd5d14912b829e184cde8da832c43bfb3f31de7b1913dd06e55f0cb25713d751

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page