From 67ae3acb2c14353c8a12468ad15db2807e404733 Mon Sep 17 00:00:00 2001 From: Austin Bowen Date: Sat, 11 Feb 2023 20:25:48 -0500 Subject: [PATCH] Replace random.uniform(0, 1) with faster equivalent random.random() --- vose_sampler/vose_sampler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vose_sampler/vose_sampler.py b/vose_sampler/vose_sampler.py index ef8d9d5..70b282f 100755 --- a/vose_sampler/vose_sampler.py +++ b/vose_sampler/vose_sampler.py @@ -71,7 +71,7 @@ def alias_generation(self): col = random.choice(self.table_prob_list) # Determine which outcome to pick in that column - if self.table_prob[col] >= random.uniform(0,1): + if self.table_prob[col] >= random.random(): return col else: return self.table_alias[col]