Skip to main content

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

Project description

mathdistops

This package provides statistical functions for normal and exponential distributions, including pnorm, qnorm, pexp, and qexp. Each function not only performs the respective statistical calculation but also generates the corresponding plot of the distribution, offering both numerical results and visual outputs.

ci-cd codecov Python 3.9.0 Documentation Status codesize version License: MIT

Contributors

Our team listed in alphabetical order:

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

Installation

This package uses Poetry for dependency management and packaging. It is not yet available for installation via pip. To install and use this package, please follow these steps:

  1. Install Poetry and Conda: If you don't have Poetry or Conda installed, install them by following the official installation guide for Poetry and Conda.

  2. Clone the Repository: Clone this repository to your local machine.

    git clone https://github.com/UBC-MDS/mathdistops.git
    cd mathdistops
    
  3. Install the virtual environment:

     conda env create -f environment.yaml
    
  4. Activate the installed environment:

     conda activate mathdistops
    
  5. Install the Package with Poetry: Use Poetry to install the package and its dependencies.

    poetry install
    

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 show the altair object
from mathdistops import pnorm

df, fig = pnorm(1, mean=0, std_dev=1)
print(df)
fig

Below is a sample usage on Jupyter Notebook.

Running unit tests

To run unit tests for this package, 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

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.

Documentation

A comprehensive guide and tutorial on utilizing these functions are available on ReadTheDocs. To access it, click the "docs" button located at the top of the README.

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.

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-2.0.3.tar.gz (8.6 kB view hashes)

Uploaded Source

Built Distribution

mathdistops-2.0.3-py3-none-any.whl (10.3 kB view hashes)

Uploaded Python 3

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