ParameterSet

params.ParameterSet(distributions, correlation=None)

A named collection of parameter distributions with optional correlation.

Parameters

Name Type Description Default
distributions Mapping[str, AnyDistribution] Mapping of parameter name to a univariate Distribution or a Dirichlet (which expands to one column per component, named name[component]). required
correlation CorrelationSpec Target Spearman rank correlations between scalar parameter columns. Either a symmetric DataFrame labelled by column names, or a mapping of (name_a, name_b) -> rho pairs (unlisted pairs are independent). None means independent. None

Example

from heormodel.params import Beta, Gamma, ParameterSet ps = ParameterSet( … {“p_sick”: Beta.from_mean_se(0.2, 0.05), … “c_sick”: Gamma.from_mean_se(1000, 150)}, … correlation={(“p_sick”, “c_sick”): 0.5}, … ) draws = ps.sample(1000, seed=42) list(draws.columns) [‘p_sick’, ‘c_sick’] draws.index.name ‘iteration’

Attributes

Name Description
names Expanded scalar column names of the draw matrix.

Methods

Name Description
at_means Wrap the analytic means as a one-row base-case draw matrix.
correlation_matrix The target Spearman correlation matrix over scalar columns.
means Analytic means of each scalar column (Dirichlet components included).
sample Draw the parameter matrix for n iterations.
spec Human-readable provenance record of each distribution spec.

at_means

params.ParameterSet.at_means()

Wrap the analytic means as a one-row base-case draw matrix.

Equivalent to single_draw(self.means().to_dict()): the deterministic run at point values that sits next to the probabilistic analysis.

Example

from heormodel.params import Fixed, ParameterSet ParameterSet({“a”: Fixed(2.0)}).at_means().shape (1, 1)

correlation_matrix

params.ParameterSet.correlation_matrix()

The target Spearman correlation matrix over scalar columns.

means

params.ParameterSet.means()

Analytic means of each scalar column (Dirichlet components included).

Example

from heormodel.params import Fixed, ParameterSet float(ParameterSet({“a”: Fixed(2.0)}).means()[“a”]) 2.0

sample

params.ParameterSet.sample(n, seed=None)

Draw the parameter matrix for n iterations.

Uses a Gaussian copula: correlated standard normals are mapped to uniforms and pushed through each marginal quantile function, so marginals are exact and rank correlations approximate the target (the Spearman target is converted to the equivalent normal correlation via 2 * sin(pi * rho / 6)).

Parameters

Name Type Description Default
n int Number of iterations (rows). required
seed int | np.random.Generator | None Integer seed or numpy Generator for reproducibility. None

Returns

Name Type Description
pd.DataFrame DataFrame with RangeIndex named "iteration" and one
pd.DataFrame column per scalar parameter.

Example

from heormodel.params import Normal, ParameterSet ps = ParameterSet({“x”: Normal(0, 1)}) ps.sample(5, seed=7).shape (5, 1)

spec

params.ParameterSet.spec()

Human-readable provenance record of each distribution spec.

Example

from heormodel.params import Normal, ParameterSet ParameterSet({“x”: Normal(0, 1)}).spec() {‘x’: ‘Normal(mean_=0, sd_=1)’}