Skip to content

Commit 21d0e1d

Browse files
authored
Merge pull request #249 from denizakgl/patch-2
Create weighted_deniz_akgul.py
2 parents 8112eb5 + 25dac0c commit 21d0e1d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Week02/weighted_deniz_akgul.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import random
2+
def weighted_srs(data, n, weights, with_replacement=False):
3+
if with_replacement or weights:
4+
return random.choices(data, weights=weights, k=n)
5+
return random.sample(data, n)

0 commit comments

Comments
 (0)