mix_draws
params.mix_draws(*sources, n=None, seed=None)Combine draw matrices from different sources into one matrix.
Each source is resampled to n rows by drawing whole rows, so the joint structure within a source (for example, a calibrated posterior’s correlation) is preserved while sources stay independent of each other.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| sources | pd.DataFrame | Two or more draw matrices with disjoint column names. Valid inputs are ParameterSet.sample output, heormodel.calibrate.CalibrationResult.posterior, or any external draw matrix indexed by iteration. |
() |
| n | int | None |
Rows in the mixed matrix. Defaults to the shortest source’s length. Sources shorter than n are resampled with replacement; sources at least as long are subsampled without replacement. |
None |
| seed | int | np.random.Generator | None |
Integer seed or numpy Generator for the resampling. |
None |
Returns
| Name | Type | Description |
|---|---|---|
| pd.DataFrame | DataFrame with a fresh RangeIndex named "iteration" and every |
|
| pd.DataFrame | column from every source. |
Raises
| Name | Type | Description |
|---|---|---|
ValueError |
If no sources are given, a source is empty, n is not positive, or column names collide across sources. |
Example
import pandas as pd from heormodel.params import mix_draws lit = pd.DataFrame({“u”: [0.6, 0.7, 0.8]}) post = pd.DataFrame({“beta”: [0.1, 0.2]}) mixed = mix_draws(lit, post, n=4, seed=0) list(mixed.columns) [‘u’, ‘beta’] mixed.index.name ‘iteration’ len(mixed) 4