Skip to main content

mathdistops

Mathdistops is a statistical package crafted to facilitate in-depth analysis and visualization of normal and exponential distributions, pivotal for a wide array of statistical modeling and data analysis tasks. It features a core set of functions (pnorm, qnorm, pexp, and qexp) capable of calculating cumulative probabilities and quantiles, while simultaneously generating plots of both the probability density function (PDF) and the cumulative distribution function (CDF) for each distribution. Thus, this package stands out as an indispensable tool for statisticians, data scientists, and researchers seeking to derive meaningful insights from their data.

ci-cd codecov Python 3.9.0 Documentation Status codesize version release License: MIT Project Status: Active – The project has reached a stable, usable state and is being actively developed.

Contributors

Our team listed in alphabetical order:

  • Katherine Chen
  • Kun Ya
  • Oak Chong
  • Sandra Gross

Functions

Description

  • pexp(q, rate=1, graph=True): Represents the Cumulative Distribution Function (CDF) of the exponential distribution characterized by a given parameter rate. The function calculates the cumulative probability for a given quantile q and plots the corresponding probability distribution (PDF) and the CDF.

  • qexp(p, rate=1, graph=True): Quantile Function of an exponential distribution, characterized by a given rate parameter rate. The function calculates the quantile corresponding to given cumulative probability p in an exponential distribution. Optionally, it can also generate and return a visualization of the PDF and the CDF.

  • pnorm(q, mean = 0, std_dev =1, graph = True): Cumulative Distribution Function of the normal distribution with specified mean and standard deviation. It will return the cumulative probability up to the given value q. Optionally, it can generate and return a visualization of the distributions, the PDF and the CDF.

  • qnorm(p, mean=0, std_dev=1, graph=True): Calculates the quantile (Inverse Cumulative Distribution Function) corresponding to a specified cumulative probability p of the normal distribution with specified mean and standard deviation. The function can additionally create and provide a graphical representation of the PDF and the CDF.

A detailed documentation of the functions can be found here.

Documentation

A detailed guide and tutorial for using these functions can be found on ReadTheDocs. For specific vignettes on the norm functions, please visit: https://mathdistops.readthedocs.io/en/latest/example_norm.html. Additionally, for comprehensive examples on the usage of qexp and pexp, refer to: https://mathdistops.readthedocs.io/en/latest/example_exp.html.

Installation

For Users

In order to install the package you can run the following command from the terminal:

pip install mathdistops

For Developers

This package uses Poetry for dependency management and packaging. To install and use this package, please follow these steps:

  1. To create a new virtual environment in Conda with Python, use the following commands in the terminal:
conda create --name mathdistops python=3.9.0 -y
  1. Activate the installed environment via:
conda activate mathdistops
  1. Please install and set up poetry:
conda install poetry
  1. Install the Package with Poetry: Use Poetry to install the package and its dependencies.
poetry install
  1. Now you are ready to use the mathdistops package!

Usage

Using this package

To use this package, you can import and call its functions in your Python scripts. Here's an example:

# Run this on jupyter notebook to import pnorm and qnorm function
from mathdistops import pnorm, qnorm

# Using pnorm to get the cumulative probability and plot for a normal distribution
df_pnorm, fig_pnorm = pnorm(1, mean=0, std_dev=1)
print(df_pnorm)
fig_pnorm

The following image displays a sample usage in a Jupyter Notebook:

Similar to pnorm for the normal distribution, pexp offers functionality for the exponential distribution. Here's how you can use pexp in a Jupyter Notebook:

# Run this on jupyter notebook to import pexp and qexp function
from mathdistops import pexp, qexp

# Using pexp to get the cumulative probability and plot for an exponential distribution
df_pexp, fig_pexp = pexp(1, rate=1)
print(df_pexp)
fig_pexp

Below is an illustration of its usage in a Jupyter Notebook:

Regarding qnorm and qexp, these functions operate similarly, generating a DataFrame that summarizes the data and also producing plots for the PDF and CDF, with the calculated results indicated on the graphs. However, unlike their counterparts, they accept quantiles as inputs instead of probabilities.

Running unit tests

To run unit tests for this package, add pytest to the environment file, which was created during the installation process via:

conda install pytest

Execute the following in the project root directory:

poetry run pytest

To get a the code coverage reporting, run this command:

poetry run pytest --cov=mathdistops
poetry run pytest --cov-branch --cov=mathdistops

Python Ecosystem Integration

While python has relevant functions for normal and exponential distribution in the scipy.stats package, this package offer an in-built additional functionality of returning the plot to help with visualization and understanding the problem.

Related Packages:

  • scipy.stats.norm is an official scipy package to represent a normal continuous random variable.
  • scipy.stats.expon is an official scipy package to represent an exponential continuous random variable.

However, these functions do not inherently produce visual outputs, requiring additional steps with a plotting library like Matplotlib for visualization. This stresses the unique selling point of the mathdistops, which is its ability to encapsulate both the computational and visual aspects of statistical analysis into cohesive functions tailored for normal and exponential distributions.

Dependencies

This package necessitates a Python version of 3 or higher. Additional required packages can be found in the environment file of this repository.

Contributing

Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms. Please check our contributing file

Code of Conduct

Welcome to our project! We appreciate your interest in contributing. Please follow our code of conduct

License

mathdistops was created by Katherine Chen, Kun Ya, Oak Chong, Sandra Gross. It is licensed under the terms of the MIT license.

Credits

mathdistops was created with a template tool cookiecutter and the py-pkgs-cookiecutter template.

Metadata

Release files for mathdistops 3.0.0

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

Source distribution (sdist)

Source distribution for mathdistops 3.0.0
File Size Uploaded Provenance Actions
mathdistops-3.0.0.tar.gz 10.3 kB Without provenance Details for mathdistops-3.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mathdistops 3.0.0
File Interpreter ABI Platform Actions
mathdistops-3.0.0-py3-none-any.whl Python 3 none any Details for mathdistops-3.0.0-py3-none-any.whl

Total release size: 21.7 kB

Release files / mathdistops-3.0.0.tar.gz

Download URL mathdistops-3.0.0.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1d6b93590f59140fc2bfa53539c4cdd0b856937fa52837d6d3ca4ab11a0468d9
BLAKE2b-256 checksum
How to use checksums
71a1dc5965947f3d4203233511b6b24ac20aec1d59692f34342f5a3f9e0b6213
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / mathdistops-3.0.0-py3-none-any.whl

Download URL mathdistops-3.0.0-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
20f24d2726752273a204303f6abdcd7b914509223bd056e84a9199babe89ed86
BLAKE2b-256 checksum
How to use checksums
173d658b4ff3798f793c268ea1a4388d2ba6500c36b3c826eca43bb4b77814dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Security for mathdistops 3.0.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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