Skip to main content
Loss of provenance

A previous release had provenance metadata, but this release does not. View details.

Robust Average

A Python package that intelligently selects the most robust average (mean, median, or mode) for price analysis based on outlier and skewness detection.

Installation

pip install robust-average

Quick Start

from robust_average import robust_average

# Example with clean data
prices = [97.87, 109.99, 129.99, 89.99, 119.99]
result = robust_average(prices)
print(f"Selected average: {result['value']} (method: {result['method']})")
# Output: Selected average: 109.99 (method: mean)

# Example with outliers
prices_with_outlier = [97.87, 109.99, 129.99, 89.99, 119.99, 500.00]
result = robust_average(prices_with_outlier)
print(f"Selected average: {result['value']} (method: {result['method']})")
# Output: Selected average: 109.99 (method: median)

Features

  • Automatic Method Selection: Intelligently chooses between mean, median, or mode
  • Outlier Detection: Uses IQR method to identify and handle outliers
  • Skewness Analysis: Measures data distribution asymmetry
  • Transparent Results: Returns the method used and supporting statistics
  • Business Ready: Ensures accurate price reporting for contracts and compliance

How It Works

The function uses a systematic approach to select the most appropriate average:

  1. Outlier Detection (IQR Method):

    • Calculates Q1 (25th percentile) and Q3 (75th percentile)
    • Defines outliers as values outside [Q1 - 1.5×IQR, Q3 + 1.5×IQR]
  2. Skewness Analysis:

    • Calculates skewness coefficient using scipy.stats.skew()
    • Values close to 0 indicate symmetric distribution
  3. Decision Criteria:

    • Use MEAN if: No outliers AND |skewness| < 0.5
    • Use MEDIAN if: Outliers present OR |skewness| ≥ 0.5
    • Use MODE if: A single value appears in >50% of the dataset

🛠️ Process Flow

Robust Average Process Flow

API Reference

robust_average(prices, return_all_stats=False)

Parameters:

  • prices (list or pd.Series): List or Series of numeric prices
  • return_all_stats (bool): If True, returns all computed statistics

Returns:

{
    'value': selected_average_value,
    'method': 'mean' | 'median' | 'mode',
    'mean': mean_value,
    'median': median_value,
    'mode': mode_value_or_None,
    'std': standard_deviation,
    'skew': skewness,
    'outliers': list_of_outlier_values,
    'count': number_of_prices
}

Use Cases

  • Price Analysis: Ensure accurate average prices for reporting
  • Contract Negotiations: Use defensible statistics in pricing discussions
  • Compliance Reporting: Meet regulatory requirements with robust averages
  • Data Quality: Automatically handle messy, real-world price data

Requirements

  • Python >= 3.8
  • numpy >= 1.20.0
  • pandas >= 1.3.0
  • scipy >= 1.7.0

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Metadata

Release files for robust-average 0.1.6

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

Loss of provenance

These files do not have provenance metadata, despite files in a prior release including this data.

We recommend further investigation before installing these files. View details.

Source distribution (sdist)

Source distribution for robust-average 0.1.6
File Size Uploaded Provenance Actions
robust_average-0.1.6.tar.gz 6.8 kB Without provenance Details for robust_average-0.1.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for robust-average 0.1.6
File Interpreter ABI Platform Actions
robust_average-0.1.6-py3-none-any.whl Python 3 none any Details for robust_average-0.1.6-py3-none-any.whl

Total release size: 12.4 kB

Release files / robust_average-0.1.6.tar.gz

Loss of provenance

This file belongs to a release without provenance metadata, despite a prior release including this data.

We recommend further investigation before installing this file. View details.

Download URL robust_average-0.1.6.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8e796b88f9a461a809acb6e2f1242d05e7ea07dcf4f3b596ded824b4e22ad96d
BLAKE2b-256 checksum
How to use checksums
a393b761cfa3a86bebdd7665a959283f1a6166360574730d083295b60ba2dbe1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release files / robust_average-0.1.6-py3-none-any.whl

Loss of provenance

This file belongs to a release without provenance metadata, despite a prior release including this data.

We recommend further investigation before installing this file. View details.

Download URL robust_average-0.1.6-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
51266878027134927a905735395bbfb66ef79a1f56e605e9c39bb1d316d4f848
BLAKE2b-256 checksum
How to use checksums
bd7953defe24b8e4f8487fcd6e5db9279ff2ac12f353b1ea8e06803af2742af2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Security for robust-average 0.1.6

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.

Loss of provenance

A previous release of these files had provenance metadata, but this release does not.

While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.

Release comparison

  • Removed 0.1.0 2 files With provenance
  • Added 0.1.6 2 files Without provenance

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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