Skip to main content

This package provides function for calculating pnorm, qnorm, pexp and qexp.

Project description

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.

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

mathdistops-3.0.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

mathdistops-3.0.0-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file mathdistops-3.0.0.tar.gz.

File metadata

  • Download URL: mathdistops-3.0.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for mathdistops-3.0.0.tar.gz
Algorithm Hash digest
SHA256 1d6b93590f59140fc2bfa53539c4cdd0b856937fa52837d6d3ca4ab11a0468d9
MD5 f33d1fe25fad88044aad89cb1e22654c
BLAKE2b-256 71a1dc5965947f3d4203233511b6b24ac20aec1d59692f34342f5a3f9e0b6213

See more details on using hashes here.

File details

Details for the file mathdistops-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: mathdistops-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for mathdistops-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 20f24d2726752273a204303f6abdcd7b914509223bd056e84a9199babe89ed86
MD5 3f8c10906fbb1983911075bdc184b4fd
BLAKE2b-256 173d658b4ff3798f793c268ea1a4388d2ba6500c36b3c826eca43bb4b77814dd

See more details on using hashes here.

Supported by

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