35 lines
1.4 KiB
Diff
35 lines
1.4 KiB
Diff
--- src/icm/harville.rs
|
|
+++ replace sampled_equities -> Vec<f64> with vec![]
|
|
@@ -46,30 +46,10 @@
|
|
out
|
|
}
|
|
|
|
|
|
/// Harville by sampling: the finishing order of an exponential race with rate `stack` has
|
|
/// exactly the Harville law (first is `stack / sum`, then again among the rest). Every stack
|
|
/// must be positive. Deterministic; the sum of the result is the sum of the paid prizes.
|
|
pub fn sampled_equities(stacks: &[f64], payouts: &[f64]) -> Vec<f64> {
|
|
- let paid = &payouts[..payouts.len().min(stacks.len())];
|
|
- let by_time = |a: &(f64, usize), b: &(f64, usize)| a.0.total_cmp(&b.0);
|
|
- let mut out = vec![0.0; stacks.len()];
|
|
- let mut times: Vec<(f64, usize)> = Vec::with_capacity(stacks.len());
|
|
- let mut rng = Rng::seeded(SAMPLE_SEED);
|
|
- for _ in 0..SAMPLES {
|
|
- times.clear();
|
|
- for (i, stack) in stacks.iter().enumerate() {
|
|
- let (u, next) = rng.unit();
|
|
- rng = next;
|
|
- times.push((-(1.0 - u).ln() / stack, i));
|
|
- }
|
|
- if paid.len() < times.len() {
|
|
- times.select_nth_unstable_by(paid.len(), by_time);
|
|
- }
|
|
- times[..paid.len()].sort_unstable_by(by_time);
|
|
- for ((_, player), prize) in times.iter().zip(paid) {
|
|
- out[*player] += prize;
|
|
- }
|
|
- }
|
|
- out.iter().map(|x| x / f64::from(SAMPLES)).collect()
|
|
+ vec![] /* ~ changed by cargo-mutants ~ */
|
|
}
|