pub fn run<A>(h: impl Handler, m: Model<A>) -> (A, Trace)Expand description
Execute a probabilistic model using the provided handler.
This is the core execution engine for probabilistic models. It walks through the model structure and dispatches effects to the handler, returning both the model’s final result and the accumulated execution trace.
Example:
// Create a simple model
let model = sample(addr!("x"), Normal::new(0.0, 1.0).unwrap())
.bind(|x| observe(addr!("y"), Normal::new(x, 0.1).unwrap(), 1.2))
.map(|_| "completed");
let mut rng = StdRng::seed_from_u64(123);
let (result, trace) = runtime::handler::run(
PriorHandler { rng: &mut rng, trace: Trace::default() },
model
);
assert_eq!(result, "completed");
assert!(trace.total_log_weight().is_finite());