diff --git a/Week03/weighted_ozgun_kasapoglu.py b/Week03/weighted_ozgun_kasapoglu.py new file mode 100644 index 0000000..9f1efcd --- /dev/null +++ b/Week03/weighted_ozgun_kasapoglu.py @@ -0,0 +1,9 @@ +import random + + +def weighted_srs(data, n, weights, with_replacement = False): + + if with_replacement: + return random.choices(data, weights=weights, k=n) + else: + return random.sample(data, n)