Skip to contents

Updates an existing surprise result with new observations. Useful for real-time or streaming data applications.

Usage

update_surprise(
  surprise_result,
  new_observed,
  new_expected = NULL,
  time_value = NULL,
  update_prior = TRUE
)

Arguments

surprise_result

An existing bs_surprise or bs_surprise_temporal object

new_observed

New observed values

new_expected

New expected values (optional)

time_value

Time value for the new observation (for temporal)

update_prior

Update prior with current posterior?

Value

Updated surprise result

Examples

# Initial computation
observed <- c(50, 100, 150)
expected <- c(10000, 50000, 100000)
result <- auto_surprise(observed, expected)

# Update with new data
new_obs <- c(200, 75)
new_exp <- c(80000, 20000)
result <- update_surprise(result, new_obs, new_exp)