Fit continuous and discrete phase-type distributions
Project description
PhaseDist is a Python package for fitting continuous and discrete phase-type distributions.
Features
- Fit continuous and discrete phase-type distributions using EM algorithms.
- Use built-in methods to easily check the fitted distribution.
- Evaluate various metrics, such as the mean, density, quantile function, AIC and more.
- Simulate observations from phase-type distributions.
- Approximate another distribution, e.g. a log-normal distribution, using a phase-type distribution.
Installation
Install directly from PyPI with:
pip install phasedist
Quick start guide
The following shows how to use PhaseDist for fitting a continuous phase-type distribution from observed data.
(1) Start by loading PhaseDist (and NumPy) and defining the observed data.
import phasedist as ph
import numpy as np
obs = np.array([1.48246359,1.13468709,0.66779536,0.61823347,0.8888217,1.10124776,0.1424737,2.1228061,
1.73924933,0.9849647,1.4828275,1.97188842,2.56132465,1.58038807,1.27567082,2.7754917,1.42516854,0.4602795,
1.93701091,2.50633135,1.92906099,1.60935023,1.41949599,1.14870169,0.79146146,1.31530543,1.81352371,1.17079096,
0.78948314,1.39528837,1.62003755,1.52143826,0.46665594,1.37913488,3.10066725,0.76942733,1.42849783,1.61511175,
2.94617609,1.53719196,1.01144357,2.00466269,0.56886361,1.62237618,0.41023332,0.78733512,4.01849928,1.27761144,
1.09426382,1.36946933])
(2) Fit the data to a generalized Erlang distribution with 3 phases.
fit = ph.fit(obs=obs,
nphases=3,
dtype="generlang")
(3) Compare the CDF of the fitted distribution to the empirical CDF.
fit.plot()
(4) Store the fitted distribution in the object phdist and compute the mean, variance, and 95% quantile.
phdist = fit.getdist()
print(phdist.getmean())
#1.455814
print(phdist.getvar())
#0.706466
print(phdist.getquantile(p=0.95))
#3.055169
Find the complete example in the file quickstart_example.py.
Documentation
The documentation can be found in the wiki for PhaseDist.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file phasedist-0.1.6.tar.gz.
File metadata
- Download URL: phasedist-0.1.6.tar.gz
- Upload date:
- Size: 22.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ac6140d125098ddc95e688c90eb11c27bd24f5aa11d6889b73f96187a31d1fc
|
|
| MD5 |
edde95adcbbb930f9c15720721b7b85f
|
|
| BLAKE2b-256 |
3bf3d7788b41b5d00a8dcc6e48b7c4a723a0f7e1cfa2fefa97d15761db362682
|
File details
Details for the file phasedist-0.1.6-py3-none-any.whl.
File metadata
- Download URL: phasedist-0.1.6-py3-none-any.whl
- Upload date:
- Size: 24.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8797dbec9105b51b12ed32afaeab30353992e122c71ef1cf0f6d26eb13d02b7
|
|
| MD5 |
91d70abf8bd329c4a067772dc93febd3
|
|
| BLAKE2b-256 |
46f8508126f744282aa8a9e85bca07a15e702e36edb4295f3d05615cea9bd332
|