Skip to main content

Compute and plot PMFs for Binomial, Geometric, Negative Binomial and Poisson distributions.

Project description

Discrete PMF — Python Module for Plotting PMFs of Discrete Distributions

Discrete PMF is a lightweight and easy-to-use Python module for computing and visualizing Probability Mass Functions (PMFs) of common discrete probability distributions. It is ideal for educators, data scientists, statisticians, and learners who want to visualize and interact with probability distributions in Python.


Supported Distributions

  • Binomial Distribution
  • Geometric Distribution
  • Negative Binomial Distribution
  • Poisson Distribution

Each function:

  • Computes the PMF for a given distribution
  • Optionally generates a matplotlib stem plot
  • Returns the PMF values as a dictionary for further processing

Requirements

  • Python ≥ 3.6
  • matplotlib (for plotting)
  • Standard Library: math

Install dependencies with:

pip install matplotlib

Or if you're using Poetry:

poetry add matplotlib

Function Overview

🔹 binom_pmf(x_values, n, p_list, plot=True)

Compute and (optionally) plot the Binomial PMF.

Parameters:

  • x_values (List[int]): Values of the random variable X (e.g., [0, 1, 2, ..., n])
  • n (int): Number of trials
  • p_list (List[float]): List of success probabilities (e.g., [0.3, 0.7])
  • plot (bool): If True, displays a matplotlib stem plot (default: True)

Returns:

  • Dict[float, List[float]]: Mapping from each p to its list of PMF values.

Example:

from discrete_pmf import binom_pmf

x = list(range(0, 6))
n = 5
p_values = [0.3, 0.7]

binom_pmf(x_values=x, n=n, p_list=p_values, plot=True)

📚 Documentation

Each function includes Python docstrings explaining:

  • Function purpose
  • Parameters and types
  • Return values
  • Example usage

📝 License

MIT License. See LICENSE file for details.


🤝 Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change or add.

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

discrete_pmf-0.1.4.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

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

discrete_pmf-0.1.4-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file discrete_pmf-0.1.4.tar.gz.

File metadata

  • Download URL: discrete_pmf-0.1.4.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.12.2 Linux/6.11.0-26-generic

File hashes

Hashes for discrete_pmf-0.1.4.tar.gz
Algorithm Hash digest
SHA256 eacfc83c2fcd5f4bfca480f33a4e52eed708b696f11fc844d31ceaf5b8367ea2
MD5 83489a533c1158a2c117334e9c3e5c03
BLAKE2b-256 492f17be6ac372b9ef1b97aa76c30e46e464006b591492eb861d60ccad9db76f

See more details on using hashes here.

File details

Details for the file discrete_pmf-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: discrete_pmf-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.12.2 Linux/6.11.0-26-generic

File hashes

Hashes for discrete_pmf-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 650490aa709fd89c033822d107cd42f47004811728c06bda85dbe882f41a8347
MD5 ab61efe15d31b32d21e1d6a1f101b556
BLAKE2b-256 ffd925aa9fe52a5b9687683439a7dc91ce87a48a6697b7a377a6e0a309a72fd1

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