Skip to content
8 changes: 8 additions & 0 deletions Week02/weighted_buse_cici.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import random
def weighted_srs(data, n, weights, with_replacement = False):
if with_replacement :
return random.choices(data, weights = weights, k = n)
if weights is None :
return random.sample(data, n)
else :
return random.sample(data, n, counts = weights)
Loading