View source: R/nested_laplace.R
| tulpa_normalise_weights_safe | R Documentation |
The single weight normaliser for every outer hyperparameter grid: softmax
of lm (optionally plus a per-cell log quadrature weight) into weights
summing to 1. Non-finite nodes (an inner Newton diverging in a grid
corner) are dropped from the max-shift and zeroed before renormalising
over the finite cells; an all-non-finite grid returns all-NA with a
warning rather than NaN. Intended for reconstructing a fit's outer-grid
posterior weights (with tulpa_theta_matrix() and
tulpa_grid_log_quad()) when the fit doesn't already carry fit$weights.
tulpa_normalise_weights_safe(lm, what = "grids / data", log_quad = NULL)
lm |
Numeric vector of per-cell log-marginal-likelihood values. |
what |
Label for the grid, used only in the degenerate-case warning. |
log_quad |
Optional per-cell log quadrature weight (prior mass) of
the outer grid, e.g. from |
Numeric vector of posterior cell weights summing to 1, the same
length as lm, or all-NA if no cell carries finite mass.
tulpa_theta_matrix(), tulpa_grid_log_quad()
tulpa_normalise_weights_safe(c(-1, 0, -2))
# With per-cell log quadrature weights (cell prior masses):
tulpa_normalise_weights_safe(c(-1, 0, -2), log_quad = log(c(0.2, 0.5, 0.3)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.