PhaseDist is a Python package for fitting phase-type regressions and distributions.
Features
- Fit phase-type regressions containing fixed and random effects.
- Fit continuous and discrete phase-type distributions.
- Fit to uncensored or censored observations.
- Approximate another distribution, e.g. a log-normal distribution, using a phase-type distribution.
- Use built-in methods to check your fit.
- Simulate observations from a phase-type distribution.
A bimodal phase-type distribution fitted using PhaseDist.
Installation
Install directly from PyPI with:
pip install phasedist
Quick start guide
Fitting a phase-type regression
The following shows how to use PhaseDist for fitting a phase-type regression.
The regression model is the phase-type regression of Bladt (2022): $Y \mid x \sim \mathrm{PH}(\pi, e^{\eta} T)$ with $\eta = x^\top \beta$. PhaseDist also supports a random intercept, $\eta = x^\top \beta + b$, which is not used in this example.
(1) Start by loading PhaseDist (and pandas) and reading the data. The data is a clinical trial dataset consisting of a continuous variable dose, a categorical variable group (control vs. treatment), and a response variable time.
import phasedist as ph
import pandas as pd
data = pd.read_csv("https://raw.githubusercontent.com/areenberg/phasedist/main/examples/regression_data.csv")
data["group"] = pd.Categorical(data["group"], categories=["control", "treatment"])
(2) Fit the regression time ~ dose + group with a Coxian distribution containing 2 phases.
fit = ph.fitreg(formula="time ~ dose + group",
data=data,
nphases=2,
dtype="coxian")
(3) Print a summary of the model, with a likelihood-ratio test of each effect.
fit.summary()
#Phase-type regression (coxian, 2 phases)
#Formula: time ~ dose + group
#Observations: 120
#Fixed effects: 2, with 2 coefficients
#
#Likelihood-ratio tests of the fixed effects:
# LR stat df Pr(>Chi)
#dose 15.44 1 <0.001
#group 18.39 1 <0.001
#(The tests of the individual coefficients are given by coeftest(), their confidence intervals by confint())
#
#Log-likelihood: -314.9920 Deviance (-2 log-likelihood): 629.9841
#...
(4) Store the fitted distribution of a patient with dose 5 in the treatment group in the object phdist and compute the mean, variance, and 95% quantile.
phdist = fit.getdist(covariates={"dose": 5.0, "group": "treatment"})
print(phdist.getmean())
#3.210571
print(phdist.getvar())
#13.545293
print(phdist.getquantile(p=0.95))
#10.648819
Find the complete example, including a PP plot to check the fit, in the file examples/regression_example.py.
Fitting a phase-type distribution
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) 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.706465
print(phdist.getquantile(p=0.95))
#3.055168
Find the complete example in the file examples/distribution_example.py.
Documentation
The documentation can be found in the wiki for PhaseDist.
License
PhaseDist is released under the MIT License.
Metadata
Release files for phasedist 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| phasedist-0.3.0.tar.gz | 95.5 kB | With provenance | Details for phasedist-0.3.0.tar.gz |
Built distributions (wheels)
Total release size: 3.1 MB
Release files / phasedist-0.3.0.tar.gz
| Download URL | phasedist-0.3.0.tar.gz |
|---|---|
| Size | 95.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a49da170a395053fc859ac7bc787f3b132c55ab3d616c24feba8ec161e542e7a
|
|
BLAKE2b-256 checksum How to use checksums |
286c5c5c990fd5beded2e81fb09255fec6942b37a9aeef997449ab4b3bca45c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / phasedist-0.3.0-cp312-abi3-win_amd64.whl
| Download URL | phasedist-0.3.0-cp312-abi3-win_amd64.whl |
|---|---|
| Size | 369.4 kB |
| Tags | CPython 3.12 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
338e757bdf5a1f67ee5298f78a28ff2a07662d7f2b0bfa1a6d0123aede940bcb
|
|
BLAKE2b-256 checksum How to use checksums |
e4ef348c54fe0a93f4594cb811fc537f651d1a99f41efcbf6060e336dd279732
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / phasedist-0.3.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | phasedist-0.3.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 165.3 kB |
| Tags | CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
c9343ee472146a1bfe2e8bfd84147f6b728bda338e56d9f10f12ec6f53eb8328
|
|
BLAKE2b-256 checksum How to use checksums |
f441d42c453d6e79aa158ee968b32945679f83b412dbc8d187cac676488717df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / phasedist-0.3.0-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
| Download URL | phasedist-0.3.0-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 161.4 kB |
| Tags | CPython 3.12 Linux glibc 2.26+ ARM64 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
a9372f4f674644134d0ac96107b352e19d23ad783b8073d8ac6d842149747f6e
|
|
BLAKE2b-256 checksum How to use checksums |
e64b6943573898b32ed7ce852b019361207e86ed0564f06335528d8ea0691549
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / phasedist-0.3.0-cp312-abi3-macosx_11_0_arm64.whl
| Download URL | phasedist-0.3.0-cp312-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 155.1 kB |
| Tags | CPython 3.12 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
dafa90b1d261964b14ff6bc783d3a033d3f106f6177f1411b421ee8a161cfaab
|
|
BLAKE2b-256 checksum How to use checksums |
bca08628052548ea5d064265977013146fd2a2faaa3bf973fea102e732d668bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / phasedist-0.3.0-cp312-abi3-macosx_10_15_x86_64.whl
| Download URL | phasedist-0.3.0-cp312-abi3-macosx_10_15_x86_64.whl |
|---|---|
| Size | 157.5 kB |
| Tags | CPython 3.12 abi3 macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
63a35a05f69fc8b89b32c158618d728225cdd7cd367c47c9d08a8067ec0bc16f
|
|
BLAKE2b-256 checksum How to use checksums |
8fca60a3e37e546809ae8e9b388f4e01e0e1617e0f408119399cd0739dd2cb03
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / phasedist-0.3.0-cp311-cp311-win_amd64.whl
| Download URL | phasedist-0.3.0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 370.0 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
13d0ac1847da786ce4739d932d3345255e72dc06f3c48edbf7e679a3c8a1a3b3
|
|
BLAKE2b-256 checksum How to use checksums |
0cf844bebc2864206c86b9406de27c8ba67840d22c45f26bf4547f49f83928c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / phasedist-0.3.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | phasedist-0.3.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 169.3 kB |
| Tags | CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
180fbe6cbfc018a938e6f50727b35c89680c69d2b81539241b93d771ce1ae235
|
|
BLAKE2b-256 checksum How to use checksums |
ea0fcf27b8fff3cdea858723e97bdfe13b523679ccadbe222fd4ce0cbde60fd0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / phasedist-0.3.0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
| Download URL | phasedist-0.3.0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 165.1 kB |
| Tags | CPython 3.11 Linux glibc 2.26+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
9520444f63845523df26632bcaf7946ceb6bd514de2f952e29d59d525a4f88f5
|
|
BLAKE2b-256 checksum How to use checksums |
f5459fa1d3a444228fbf59a31406bc413d3a499c39ebd3cdb9e122bf08809410
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / phasedist-0.3.0-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | phasedist-0.3.0-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 157.2 kB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
96a3d5833c6081ed370a75d554da8beee35fcc4c6580c3de805074dd57b20b06
|
|
BLAKE2b-256 checksum How to use checksums |
a973da00ea7a3bc40f096a7dc3570b5b37cacc3ae03a8c2d14e7d1bcc9c809df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / phasedist-0.3.0-cp311-cp311-macosx_10_15_x86_64.whl
| Download URL | phasedist-0.3.0-cp311-cp311-macosx_10_15_x86_64.whl |
|---|---|
| Size | 159.4 kB |
| Tags | CPython 3.11 macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
d64c82998fae8dc6a5b01cca3ef4a45c496f389de016dc36e9b3076902c22418
|
|
BLAKE2b-256 checksum How to use checksums |
29035710b16ad7b8f7651ecba7cf87431bd1e8e485730032e864082a9791ce44
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / phasedist-0.3.0-cp310-cp310-win_amd64.whl
| Download URL | phasedist-0.3.0-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 369.6 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
3f14d12fe9ee4988ab300b512aa471a44271cd825b318a89386a5d5cebad62a3
|
|
BLAKE2b-256 checksum How to use checksums |
88940c1efeda079030b822efe893aa0ba1f648ade4aaf09104dd52a20a33ea6d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / phasedist-0.3.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | phasedist-0.3.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 169.8 kB |
| Tags | CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
9e2656e64471eca9f8a6dfce792a9e09079cc8506b8b768a7a88936521021af9
|
|
BLAKE2b-256 checksum How to use checksums |
98ae7c41c8bd877305ec9d18da191cc994a6e33a47be9c5513e7bebe2f2cc145
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / phasedist-0.3.0-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
| Download URL | phasedist-0.3.0-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 165.5 kB |
| Tags | CPython 3.10 Linux glibc 2.26+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
59493c426287a48de707729df46935c3cdffd1070871ad014c57fbfa5f1e8eb6
|
|
BLAKE2b-256 checksum How to use checksums |
2e4fa6a8321108c8a82b47c0c1e8193ce7bac0e2aeabbe03920c2261100f2668
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / phasedist-0.3.0-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | phasedist-0.3.0-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 157.5 kB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
7fa4b038d74e5e52e2c124641220f435278613004ccee5a5384796517e1a3cbd
|
|
BLAKE2b-256 checksum How to use checksums |
1b4be8916a0e4e3d86d79b23df7992fe29ad5ca1f447d83cb00d67bd8d58b406
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / phasedist-0.3.0-cp310-cp310-macosx_10_15_x86_64.whl
| Download URL | phasedist-0.3.0-cp310-cp310-macosx_10_15_x86_64.whl |
|---|---|
| Size | 159.8 kB |
| Tags | CPython 3.10 macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
4a9182b5b153203a7708c68dd36700935b02bede60ec4955073d49f34c5f07ae
|
|
BLAKE2b-256 checksum How to use checksums |
4887002115e94f453f20c570336c1ab3ac35a7544a6486b9fb984abffbcbc85a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logSecurity for phasedist 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 16 files in this release have been uploaded with provenance metadata.
Attestation for phasedist-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.