Skip to contents

Updates the prior probability distribution over models given observed data, using Bayes' rule.

Usage

bayesian_update(model_space, observed, region_idx = NULL, ...)

Arguments

model_space

A bs_model_space object

observed

Numeric vector of observed values

region_idx

Optional integer index for region-specific likelihood

...

Additional arguments passed to likelihood functions

Value

Updated bs_model_space with posterior probabilities

Details

Applies Bayes' rule: $$P(M|D) \propto P(D|M) \cdot P(M)$$

where P(D|M) is the likelihood of data D given model M, and P(M) is the prior.

Examples

# Create a model space
space <- model_space(
  bs_model_uniform(),
  bs_model_gaussian()
)

# Update with observed data
observed <- c(10, 20, 30, 40, 50)
updated <- bayesian_update(space, observed)
print(updated)
#> <bs_model_space>
#>   Models: 2 
#>    1. Uniform (prior: 0.5, posterior: 1)
#>    2. Gaussian (prior: 0.5, posterior: 0)