This repository contains the code of a Python package that implements Gaussian and Binomial distributions.
This package requires:
- Python (>= 3.7.4)
- seaborn (>=0.11.1)
- matplotlib.pyplot (>=3.3.3)
- numpy (>=1.19.5)
To install the package use pip as follows:
$ pip3 install shay-dists
from distributions import Gaussian, Binomial
The constructor receives the mean and standard deviation:
gaussian = Gaussian(25, 6)
The constructor receives the probability of an event ocurring and the size of the distribution:
binomial = Binomial(0.7, 10)
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
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()
.
For the Gaussian class use the method plot_histogram()
and for the Binomial classe use plot_bar()
.
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)
.