bentobox
A fast, allocation-free Monte Carlo model of a top-N podium finish in racing events. Derives probabilities for placing in arbitrary positions given only win probabilities. Also derives joint probability of multiple runners with arbitrary (exact and top-N) placings.
Performance
Circa 20M simulations/sec on a top-4 podium over 14 runners using the tinyrand RNG. Roughly 80% of time is spent in the RNG routine.
Example
Sourced from examples/multi.rs
.
use mc;
use SliceExt;
use Selection;
use StdRand;
use ;
// probs taken from a popular website
let mut probs = vec!;
// force probs to sum to 1 and extract the approximate overround used (multiplicative method assumed)
let overround = probs.normalize;
println!;
println!;
// create an MC engine for reuse
let mut engine = default
.with_iterations
.with_probabilities
.with_podium_places
.with_rand;
// simulate top-N rankings for all runners
// NOTE: rankings and runner numbers are zero-based
for runner in 0..probs.len
// simulate a same-race multi for a chosen selection vector
let selections = vec!;
let frac = engine.simulate;
println!;