Posterior-draw functions
On this page
Numerical kernels for posterior draws. See Posterior draws for shapes, tolerances, and failure behavior.
Kernels
draws_moments()
Weighted mean and covariance of posterior draws.
- Weights are normalized internally.
normalization: 'unbiased'treats them as reliability weights, never frequency counts. - A singular covariance is a valid result.
- Rows are draws and columns are parameters. Row order is kept; no row is dropped and no intercept is added.
null,NAN,INF, and nonnumeric elements are rejected.
Phit\draws_moments( array $draws, ?array $weights = NULL, string $normalization = 'population',): array| Parameter | Type | Default | Description |
|---|---|---|---|
$draws |
array |
required | Draws: one row per draw and one column per parameter |
$weights |
?array |
NULL |
Nonnegative weights, one per draw, normalized internally; null weights draws equally |
$normalization |
string |
'population' |
'population' or 'unbiased' (reliability weights) |
Returns array{mean: list<float>, covariance: list<list<float>>}
Errors Exception: a code from 1001 to 1005 for an input or numerical error.
See also Details
draws_covariance_map()
Matrix A with A · source · Aᵀ = target, from Cholesky factors and triangular solves.
- Both covariances must be finite, symmetric, positive definite, and of equal size. Failure throws; there is no regularization.
null,NAN,INF, and nonnumeric elements are rejected.
Phit\draws_covariance_map( array $sourceCovariance, array $targetCovariance,): array| Parameter | Type | Default | Description |
|---|---|---|---|
$sourceCovariance |
array |
required | Symmetric positive-definite covariance of the source draws |
$targetCovariance |
array |
required | Symmetric positive-definite target covariance, of the same size |
Returns array{matrix: list<list<float>>, log_abs_det: float}
Errors Exception: a code from 1001 to 1005 for an input or numerical error.
See also Details
draws_affine()
Applies y = A·x + b to every draw: Y = X·Aᵀ + b.
matrixmust be square and invertible. Also returns log |det(A)|.- Rows are draws and columns are parameters. Row order is kept; no row is dropped and no intercept is added.
null,NAN,INF, and nonnumeric elements are rejected.
Phit\draws_affine( array $draws, array $matrix, array $shift,): array| Parameter | Type | Default | Description |
|---|---|---|---|
$draws |
array |
required | Draws: one row per draw and one column per parameter |
$matrix |
array |
required | Square invertible matrix A |
$shift |
array |
required | Shift b, one value per parameter |
Returns array{draws: list<list<float>>, log_abs_det: float}
Errors Exception: a code from 1001 to 1005 for an input or numerical error.
See also Details