Gaussian and Binomial distribution classes.
Project description
This repository contains the code of a Python package that implements Gaussian and Binomial distributions.
Download
Dependencies
This package requires:
- Python (>= 3.7.4)
- seaborn (>=0.11.1)
- matplotlib.pyplot (>=3.3.3)
- numpy (>=1.19.5)
Installation
To install the package use pip as follows:
$ pip3 install shay-dists
How to use
from distributions import Gaussian, Binomial
Making a Gaussian instance
The constructor receives the mean and standard deviation:
gaussian = Gaussian(25, 6)
Making a Binomial instance
The constructor receives the probability of an event ocurring and the size of the distribution:
binomial = Binomial(0.7, 10)
Adding two distributions
Due to Python magic methods, it's possible to sum two Gaussians and it outputs a new Gaussian class with the updated mean and standard deviation. The same applies to Binomial class.
gaussian_one = Gaussian(10, 3)
gaussian_two = Gaussian(32, 7)
gaussian_one + gaussian_two
Reading data from a file
You can load data from a .txt file using the method read_data_file() in both classes:
gaussian = Gaussian()
gaussian.read_data_file('numbers.txt')
And calculate the mean and standard deviation from the data using the methods calculate_mean() and calculate_stdev(), respectively.
In the Binomial class, to update the probability of an event ocurring from the dataset, use the method replace_stats_with_data().
Plotting histogram
For the Gaussian class use the method plot_histogram() and for the Binomial classe use plot_bar().
Probability density function
In the Binomial class, you can calculate the probability of k positive events ocurring in a sample of size n using the method pdf(k).
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
File details
Details for the file shay-dists-1.1.tar.gz.
File metadata
- Download URL: shay-dists-1.1.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.7 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7cec5879fa227fef745497d89e8e4d74f47c4d552276492bb25326ec0399c19f
|
|
| MD5 |
a86638cbbec87ef1b93e66571081db19
|
|
| BLAKE2b-256 |
7d498b30281b667846f6734d4b3edb959d5a14ed217d5af5d2777697ae233f2b
|