Gaussian and Binomial Probability Distributions
Project description
problib
Small Python library to calculate and plot probability density functions for Gaussian and Binomial distributions.
Note that this is a test Python package, it works fine but has some issues and solves no new problem. You can totally give it a try though!
Installation with pip
pip install problib
# test.pypi install
pip install -i https://test.pypi.org/simple/ problib==0.2
Use in Python
Gaussian Distribution
from problib import Gaussian
# Create new gaussian distribution with mu=25 and sigma=2
gaussian = Gaussian(25, 2)
gaussian # mean 25, standard deviation 0.5
# Return mean and standard deviation
gaussian.mean # 25.0
gaussian.stdev # 2.0
# Compute probability density function at point x=25
gaussian.pdf(25) # 0.19947
# Add two Gaussian distributions together
gaussian_b = Gaussian(80, 20)
gaussian + gaussian_b # 'mean 105, standard deviation 20.09975'
# Read data from .txt file, recompute mean and stdev
gaussian.read_data_file('numbers.txt')
gaussian.calculate_mean()
gaussian.calculate_stdev()
# Plot data (requires loading data first)
gaussian.plot_histogram()
# Plot normalized histogram of data and probability density function (requires loading data first)
gaussian.plot_histogram_pdf()
Binomial Distribution
The Binomial distribution has the same methods as Gaussian but takes success probability and trial size as required inputs
from problib import Binomial
# Create new Binomial distribution with p=0.4 and n=20
binomial = Binomial(0.4, 20)
binomial.p # 0.4
binomial.n # 20
binomial.mean # 8.0
binomial.stdev # 2.19089
# Compute probability density function for k=5
binomial.pdf(5) # 0.07465
# Read data from .txt file, recalculate properties
binomial.read_data_file('numbers_binomial.txt')
binomial.replace_stats_with_data()
# Plot data and probabilities (works with or without read data)
binomial.plot_bar()
binomial.plot_bar_pdf()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
problib-0.2.tar.gz
(4.2 kB
view details)
File details
Details for the file problib-0.2.tar.gz.
File metadata
- Download URL: problib-0.2.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.1.post20200323 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8bac4b8a03d58a50041cb35e7a510fc87316e66edbebcb7ee121f76f90c7929
|
|
| MD5 |
8cdd09fb0f61248cc2a4c5fa3738c250
|
|
| BLAKE2b-256 |
9bd0f3e51f4a3a87d814299a478d1cd1004f6442c6dbf580ea3ec8b92657a5f8
|