bm_logsumexp | R Documentation |
Constructs a mapper
that aggregates elements of exp(state)
, with optional non-negative
weighting, and then takes the log()
, so it can be used e.g.
for v_k=\log[\sum_{i\in I_k} w_i \exp(u_i)]
and v_k=\log[\sum_{i\in I_k} w_i \exp(u_i) / \sum_{i\in I_k} w_i]
calculations. Relies on the input handling methods for
bm_aggregate
, but also allows the weights to be supplied on a
logarithmic scale as log_weights
. To avoid numerical overflow, it uses the
common method of internally shifting the state blockwise;
v_k=s_k+\log[\sum_{i\in I_k} \exp(u_i + \log(w_i)- s_k)]
,
where s_k=\max_{i\in I_k} u_i + \log(w_i)
is the
shift for block k
.
bm_logsumexp(rescale = FALSE, n_block = NULL)
bru_mapper_logsumexp(...)
## S3 method for class 'bm_logsumexp'
ibm_jacobian(mapper, input, state = NULL, ...)
## S3 method for class 'bm_logsumexp'
ibm_eval(mapper, input, state = NULL, log = TRUE, ..., sub_lin = NULL)
rescale |
logical; For
|
n_block |
Predetermined number of output blocks. If |
... |
Arguments passed on to other methods |
mapper |
A mapper S3 object, inheriting from |
input |
Data input for the mapper. |
state |
A vector of latent state values for the mapping,
of length |
log |
logical; control |
sub_lin |
Internal, optional pre-computed sub-mapper information |
ibm_jacobian(bm_logsumexp)
: input
should be a list with elements
block
and weights
. block
should be a vector of the same length as the
state
, or NULL
, with NULL
equivalent to all-1.
If weights
is NULL
, it's interpreted as all-1.
ibm_eval(bm_logsumexp)
: When log
is TRUE
(default), ibm_eval()
for logsumexp
returns the log-sum-weight-exp value. If FALSE
, the
sum-weight-exp
value is returned.
bru_mapper, bru_mapper_generics
Other mappers:
bm_aggregate()
,
bm_collect()
,
bm_const()
,
bm_factor()
,
bm_fmesher()
,
bm_harmonics()
,
bm_index()
,
bm_linear()
,
bm_marginal()
,
bm_matrix()
,
bm_mesh_B()
,
bm_multi()
,
bm_pipe()
,
bm_repeat()
,
bm_scale()
,
bm_shift()
,
bm_sum()
,
bm_taylor()
,
bru_get_mapper()
,
bru_mapper()
,
bru_mapper.fm_mesh_1d()
,
bru_mapper.fm_mesh_2d()
,
bru_mapper_generics
m <- bm_logsumexp()
ibm_eval2(m, list(block = c(1, 2, 1, 2), weights = 1:4), 11:14)
ibm_eval2(m, list(block = c(1, 2, 1, 2), weights = 1:4, n_block = 3), 11:14)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.