We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 020c488 + 23fa7a7 commit 8d271d4Copy full SHA for 8d271d4
Week03/weighted_tufan_sengel.py
@@ -0,0 +1,8 @@
1
+import random
2
+
3
+def weighted_srs(data, n, weights, with_replacement = False):
4
+ if(with_replacement):
5
+ sample = random.choices(data, weights=weights, k=n)
6
+ else:
7
+ sample = random.sample(data, n, counts=weights)
8
+ return sample
0 commit comments