diff --git a/Week03/weighted_hakan_magat.py b/Week03/weighted_hakan_magat.py new file mode 100644 index 00000000..609421d0 --- /dev/null +++ b/Week03/weighted_hakan_magat.py @@ -0,0 +1,8 @@ +import random + +def weighted_srs(data, n, weights, with_replacement = False): + if with_replacement == True or weights != None: + randomlist = random.choices(data, k = n, weights = weights) + else: + randomlist = random.sample(data, n) + return randomlist