Skip to main content

Statistics for humans

Project description

Statistics for Humans

CI

Install

From PyPi

pip install verysimplestats

From GitHub (with pip)

pip install git+https://github.com/PierreSelim/verysimplestats.git

Tests

Doctests are embedded in the source. Run with:

uv run pytest --cov=verysimplestats --cov-report=term-missing

Examples

Mean value

>>> import verysimplestats as stats
>>> stats.mean([1, 2, 3, 4, 5])
3.0

Median value

>>> import verysimplestats as stats
>>> stats.median([5, 2, 6, 4, 1, 3])
3.5

Linear regression

>>> import verysimplestats as stats
>>> lm = stats.linear_regression([1, 2, 3], [1, 3, 4.5])
>>> (lm.slope, lm.intercept, lm.rsquared)
(1.7499999999999984, -0.6666666666666634, 0.9932432432432422)
>>> [round(e, 4) for e in lm.residuals]
[-0.0833, 0.1667, -0.0833]

Variance is computed only for list of length greater or equal to 2

>>> import verysimplestats as stats
>>> stats.variance([1])
Traceback (most recent call last):
    ...
ValueError: Variance only exists for list with at least 2 elements [1]

Supported functions

Functions Examples
mean(x: list) -> float mean([1, 2, 3, 4, 5])
median(x: list) -> float median([5, 2, 6, 4, 1, 3])
variance(x: list) -> float variance([1, 2, 3, 4, 5])
standard_deviation(x: list) -> float standard_deviation([1, 2, 3, 4, 5])
covariance(x: list, y: list) -> float covariance([1, 2, 3, 4, 5], [1, 2, 3, 4, 5])
correlation(x: list, y: list) -> float correlation([1, 2, 3, 4, 5], [1, 2, 3, 4, 5])
rsquared(x: list, y: list) -> float rsquared([1, 2, 3], [1, 3, 4.5])
ordinary_least_square(x: list, y: list) -> (float, float) ordinary_least_square([1, 2, 3], [1, 3, 4.5])
linear_forecast(slope: float, intercept: float, value: float) -> float linear_forecast(2, -1, 3)
residuals(slope: float, intercept: float, x: float, y: float) -> float residuals(1.75, -0.667, [1, 2, 3], [1, 3, 4.5])
linear_regression(x: list, y: list) -> LinearRegressionFit linear_regression([1, 2, 3], [1, 3, 4.5])

License (MIT)

The MIT License (MIT)

Copyright (c) 2016 Pierre-Selim

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

verysimplestats-2.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

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

verysimplestats-2.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file verysimplestats-2.0.tar.gz.

File metadata

  • Download URL: verysimplestats-2.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.4 {"installer":{"name":"uv","version":"0.11.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for verysimplestats-2.0.tar.gz
Algorithm Hash digest
SHA256 5e250095578daae28866428c585c04ae0d886ea71b1cd96a24c07b56da4663d0
MD5 4085d055b0475c75fd961b17560236c9
BLAKE2b-256 6099772b070999a6e96340168fb09b54e2c76b4a2499a9991a021f224235fbca

See more details on using hashes here.

File details

Details for the file verysimplestats-2.0-py3-none-any.whl.

File metadata

  • Download URL: verysimplestats-2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.4 {"installer":{"name":"uv","version":"0.11.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for verysimplestats-2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3642b8e0520332c6f1e6779305508d3638f3bd38927cc6c46bb9d581c24ea569
MD5 76c8aec07aa81a529e96f10e264d34f2
BLAKE2b-256 8549014e38103ba2eb5fe91ca812d114310d53f1aa2c05c81f95046a380ee4ed

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