Skip to contents

Scores each candidate by the KL left after its weight is chosen, so the step rule is an inner optimisation. Considerably more expensive than fw_step(); see oracles.

Usage

lb_step(
  state,
  times = 1L,
  size = c("line-search", "fixed"),
  correct_weights = FALSE,
  record_gap = FALSE,
  until = NULL
)

Arguments

state

A ripr_state.

times

Steps to take.

size

"line-search", or "fixed" for the open-loop schedule.

correct_weights

Re-solve the weights with atoms fixed after each step, by the weight_solver set in ripr_control(), both when scoring candidates and when taking the step. The solve replaces the step size would choose, so setting size alongside it is an error.

record_gap

Sweep the Frank–Wolfe oracle over the produced mixture, filling gap_after and caching it for gap_below() and fw_step(). FALSE by default.

until

Optional predicate function(state, candidate) tested before each step; see predicates.

Value

The updated ripr_state.

See also

Examples

set.seed(1)
fam <- multinomial_family(n_trials = 4L, k = 3L)
plurality <- null_model(
  fam,
  list(
    simplex_region(vertices = rbind(c(0.5, 0.5, 0), c(0, 1, 0), c(0, 0, 1))),
    simplex_region(vertices = rbind(c(0.5, 0, 0.5), c(0, 1, 0), c(0, 0, 1)))
  )
)
Q <- fam(c(0.4, 0.35, 0.25))
state <- ripr_init(Q, plurality) |> lb_step(times = 5L)
state@trace$kl
#> [1] 0.024511510 0.006671614 0.004757894 0.004267527 0.004044894 0.003927877