A small package for statistical distributions
Project description
minimal-stats
This is a simple python package for statistical distributions. Currently this package calcuates Binomial and Gaussian distribution.
Installation
pip install minimal-stats
Gaussian Distribution
We can directly provide the mean and standard deviation of data (or read data from a file) and add two gaussain distribution.
>>> from distributions import Gaussian
>>> g1 = Gaussian(180, 34)
>>> g1
g = Gaussian(mean=180, stdev=34)
>> str(g1)
'mean 180, standard deviation 34'
>>> g2 = Gaussian(180, 34)
>>> g1 + g2
g = Gaussian(mean=360, stdev=48.08326112068523)
Here, we read data from a file, calculate mean, standard deviation and probability density function of gaussian distribution and then see graphical output
>>> from distributions import Gaussian
>>> g = Gaussian()
>>> g.read_data_file(r'\tests\input\numbers.txt')
>>> g.calculate_mean()
78.0909090909091
>>> g.calculate_stdev()
92.87459776004906
>>> g.pdf(5)
0.0031515485379333356
>>> g.plot_histogram_pdf()
Binomial Distribution
We can directly provide the n and p of data (or read from file as before) and calculate mean, standard deviation and probability mass function of binomial distribution.
>>> from distributions import Binomial
>>> b = Binomial(0.15, 60)
>>> b
b = Binomial(p=0.15, n=60)
>>> b.calculate_mean()
9.0
>>> b.calculate_stdev()
2.765863337187866
>>> b.pmf(7)
0.11985659270959788
>>> a = Binomial(0.15, 50)
>>> a + b
b = Binomial(p=0.15, n=110)
Here, we read data from a file, `b.replace_stats_with_data()calculate mean, standard deviation, n and p of Binomial distribution and then we plot bar graph of pmf.
>>> from distributions import Binomial
>>> b.read_data_file(r'\tests\input\numbers_binomial.txt')
>>> b.replace_stats_with_data()
>>> str(b)
'mean 8.0, standard deviation 1.7541160386140584, p 0.6153846153846154, n 13'
>>> b.plot_bar_pmf()
Contribution
We appreciate feedback and contribution to this repo! Before you get started, please see the following:
License
This project is licensed under the MIT License - see the LICENSE file for details
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
Built Distribution
File details
Details for the file minimal-stats-1.0.0.tar.gz
.
File metadata
- Download URL: minimal-stats-1.0.0.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c84f15d30c6e8479db4e4172f74548b27da8b1322a2b2bdfc2377ab5d2cdd71 |
|
MD5 | f2c1fbdb661a6936259bffa3ee3fe0fd |
|
BLAKE2b-256 | 0b02ffeb9cedd2e37e96659663e9f3990415ef875a87e5882e7c1832a44d4b28 |
File details
Details for the file minimal_stats-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: minimal_stats-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7c40b1a423d4e83d4411542396d95cc8e2a9169ddbef3d199ad582dc250b75b |
|
MD5 | 2a42163dede81d1b7aee3f52d5e0a449 |
|
BLAKE2b-256 | 724d45450e02908d6307800143f9bb7cb8e28385b647fae6b4b1f9d698dae3bc |