Skip to main content

Python package for software reliability analysis and modeling

Project description

pysrat

Python implementation of NHPP (non-homogeneous Poisson process) software reliability models with a C/pybind11 core and a Pythonic estimator API.

Features

  • Scikit-learn–style estimators: model.fit(data) and params_/llf_/aic_
  • NHPP data helpers: NHPPData.from_intervals(...), from_counts(...), from_fault_times(...)
  • Fast EM updates in C via pybind11
  • CF1 (canonical phase-type) NHPP model and distribution helpers
  • Simple plotting helpers (plot_mvf, plot_dmvf, plot_rate)

Installation

python -m pip install -U pip
pip install -e .

Notes:

  • A C++20-capable compiler is required to build the CF1 extension module.

Quick start

import numpy as np
from pysrat import NHPPData, ExponentialNHPP, plot_mvf

data = NHPPData.from_intervals(time=[1, 1, 1, 1], fault=[0, 1, 0, 5])

model = ExponentialNHPP().fit(data)
print(model.params_)
print(model.aic_)

plot_mvf(data, model)

CF1 example:

import numpy as np
from pysrat import NHPPData
from pysrat.models.cf1 import CanonicalPhaseTypeNHPP

data = NHPPData.from_intervals(time=[1, 2, 1.5], fault=[1, 0, 2], type=[0, 1, 0])
model = CanonicalPhaseTypeNHPP(3).fit(data)
print(model.params_)

API overview

Data

  • NHPPData.from_intervals(time=..., fault=..., type=..., te=...)
  • NHPPData.from_counts(fault=...)
  • NHPPData.from_fault_times(times=..., te=...)

Models

  • ExponentialNHPP (exponential)
  • TruncatedNormalNHPP, Pareto2NHPP, GammaNHPP, LogNormalNHPP
  • TruncatedLogisticNHPP, LogLogisticNHPP
  • TruncatedExtremeValueMaxNHPP, LogExtremeValueMaxNHPP
  • TruncatedExtremeValueMinNHPP, LogExtremeValueMinNHPP
  • CanonicalPhaseTypeNHPP (CF1)

Model comparison

from pysrat import compare, ExponentialNHPP, NHPPData

data = NHPPData.from_counts([0, 1, 0, 5])
fitted, best = compare([ExponentialNHPP()], data, criterion="AIC")

Distributions

R-like helpers live under pysrat.dists, e.g.:

from pysrat.dists import dcf1, pcf1, rcf1

alpha = [0.4, 0.3, 0.3]
rate = [0.5, 1.0, 1.5]
print(dcf1([0.1, 0.5], alpha=alpha, rate=rate))
print(pcf1([0.1, 0.5], alpha=alpha, rate=rate))
print(rcf1(5, alpha=alpha, rate=rate))

Plotting

  • plot_mvf(data, model_or_results)
  • plot_dmvf(data, model_or_results)
  • plot_rate(data, model_or_results)

Note: Only the plot_* functions above are exported; legacy aliases like mvfplot, dmvfplot, and rateplot are not provided.

model_or_results can be an NHPPModel, a dict[str, NHPPModel], or a list of models.

Hyperparameters

Models expose sklearn-style hyperparameters via get_params()/set_params(). For example:

model = ExponentialNHPP(omega0=1.0, rate0=1.0)
model.set_params(rate0=0.5)

Development

python -m pip install -U pip
pip install -e .[dev]
pytest -q

Release

Tag and push to trigger the PyPI release workflow:

git tag v0.1.0
git push --tags

Set either:

  • PYPI_API_TOKEN secret for token-based upload, or
  • Trusted Publishing (OIDC) in PyPI and keep the workflow permissions as-is.

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

pysrat-0.1.0.tar.gz (345.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysrat-0.1.0-cp39-cp39-macosx_26_0_arm64.whl (229.2 kB view details)

Uploaded CPython 3.9macOS 26.0+ ARM64

File details

Details for the file pysrat-0.1.0.tar.gz.

File metadata

  • Download URL: pysrat-0.1.0.tar.gz
  • Upload date:
  • Size: 345.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for pysrat-0.1.0.tar.gz
Algorithm Hash digest
SHA256 46184147f419c2199fd2e7392c6e892893e412da547d6fdb36711831524ad163
MD5 a38a0901004064b21f4c373be35d98c8
BLAKE2b-256 410822d8298209fc1f54f74f54233453625cc784b2305813c2c97f522e117aa2

See more details on using hashes here.

File details

Details for the file pysrat-0.1.0-cp39-cp39-macosx_26_0_arm64.whl.

File metadata

File hashes

Hashes for pysrat-0.1.0-cp39-cp39-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 8d3df0f3c8d2290de8afee4963b74f685732c3ce0f27126ad1a6384980508609
MD5 b7554faaa97333a7f4529af18e46d653
BLAKE2b-256 1e31e90d976a1dddb8ce5917c0a97092f43ebddfcf0d5376419d447960a30022

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page