11import IsoSpecPy
22
33
4- from random import uniform , choice
5- from numpy .random import binomial
6- from math import inf , nan
74
85
96def _beta_1_b (b ):
@@ -30,7 +27,7 @@ def sample_isospec(formula, count, precision):
3027 #for x in population:
3128 # yield x
3229 '''Performs sampling with replacement from population argument, with
33- associated probabilities from second argument. The probabilities must
30+ associated probabilities from second argument. The probabilities must
3431 sum to 1. Yields a stream of tuples: (population_member, times_chosen).
3532 Accepts generators as first and second argument. May return duplicate
3633 tuples and tuples with times_chosen == 0.
@@ -49,7 +46,7 @@ def sample_isospec(formula, count, precision):
4946 while (pprob - cprob ) * count / (1.0 - cprob ) < 1.0 :
5047 cprob += _beta_1_b (count ) * (1.0 - cprob )
5148 while pprob < cprob :
52- if accumulated > 0 :
49+ if accumulated > 0 :
5350 yield (pop_next , accumulated )
5451 accumulated = 0
5552 pop_next , prob_next = next (iso_iter )
@@ -213,6 +210,10 @@ def sample_ciic(formula, count, precision):
213210
214211
215212if __name__ == '__main__' :
213+ from random import uniform , choice
214+ from numpy .random import binomial
215+ from math import inf , nan
216+
216217 from IsoSpecPy .Formulas import *
217218 from scipy .stats import chisquare
218219 import sys
0 commit comments