simpm.dist — SimPM’s Probability Distributions components
Probability distributions and fitting helpers used throughout SimPM.
The functions in this module wrap common SciPy distributions with a lightweight API tailored for simulation modeling. They make it easy to sample, plot, and fit distributions while keeping consistent return types for downstream components.
- simpm.dist.fit(data: Iterable[float], dist_type: str, method: str = 'mle') FitResult
Fit a distribution on data and return a structured result.
Parameters
- dataarray_like
The data to fit the distribution to.
- dist_typestr
The type of distribution to fit. Supported types are
"triang","norm","beta","trapz", and"expon".- methodstr, optional
The method to use for fitting the distribution. Default is
"mle"(maximum likelihood estimation).
Returns
- FitResult
Structured fitting result containing the SciPy distribution, wrapper instance, and Kolmogorov–Smirnov statistic.
Raises
- ValueError
If the distribution type is not recognized or the input data are invalid.
- class simpm.dist.beta(a, b, minp, maxp)
Defines a beta distribution.
- class simpm.dist.distribution
Lightweight wrapper around SciPy distributions.
All concrete distribution classes inherit from this base to expose a common API for sampling, plotting, and computing summary statistics.
- cdf(x)
Evaluate the cumulative distribution function at
x.
- mean()
Return the distribution mean.
- pdf(x)
Evaluate the probability density function at
x.
- percentile(q)
Return the value at percentile
q(0–100).
- plot_cdf()
Plot the cumulative distribution function using matplotlib.
- plot_pdf()
Plot the probability density function using matplotlib.
- sample()
Draw a single random variate from the distribution.
- samples(n)
Draw
nrandom variates from the distribution.
- std()
Return the distribution standard deviation.
- var()
Return the distribution variance.
- class simpm.dist.empirical(data)
Defines an empirical distribution based on observed data.
- cdf(x)
Evaluates the cumulative distribution function (CDF) of the empirical distribution at the given point.
- cdf_xy()
Returns x, y numpy arrays for plotting the cumulative distribution function (CDF).
- pdf(x)
Evaluates the probability density function (PDF) of the empirical distribution at the given point.
- pdf_xy()
Returns x, y numpy arrays for plotting the probability density function (PDF).
- percentile(q)
Calculates the value corresponding to the given percentile of the empirical distribution.
- plot_cdf()
Plots the cumulative distribution function (CDF) of the empirical distribution.
- plot_pdf()
Plots the probability density function (PDF) of the empirical distribution.
- sample()
Generates a single random sample from the empirical distribution.
- samples(n)
Generates random samples from the empirical distribution.
- class simpm.dist.expon(mean)
Defines an exponential distribution.
- class simpm.dist.norm(mean, std)
Defines a normal distribution.
- class simpm.dist.trapz(a, b, c, d)
Defines a trapezoidal distribution.
- class simpm.dist.triang(a, b, c)
Defines a triangular distribution.
- class simpm.dist.uniform(a, b)
Uniform distribution defined by lower/upper bounds.