Skip to content

Commit d0ccf6a

Browse files
authored
Merge pull request #124 from kilic-mustafa/patch-1
Create weighted_mustafa_kilic.py
2 parents 842b3e7 + 68cb58a commit d0ccf6a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Week03/weighted_mustafa_kilic.py

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

0 commit comments

Comments
 (0)