From 0fde35d584a4ff19db60e632ed0896848934659d Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 15 Mar 2024 17:40:18 +0100 Subject: random practice: just bring all chars to same proba, no overcompensation --- src/server.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/server.rs b/src/server.rs index 14368e0..76911f6 100644 --- a/src/server.rs +++ b/src/server.rs @@ -382,10 +382,8 @@ where } counted += 1; - // compensate twice for rare characters - // - once to bring all chars to equal probability of sampling - // - once to over-sample rare chars because we need to see them more - let weight = 1f64 / (*f * *f) as f64; + // compensate for rare characters + let weight = 1f64 / (*f) as f64; total_weight += weight; let rand: f64 = rng.gen(); if rand < weight / total_weight { -- cgit v1.2.3