Skip to content

Commit 19c0f83

Browse files
Update weighted_fevzi_bagriacik.py
1 parent 3bfaced commit 19c0f83

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Week03/weighted_fevzi_bagriacik.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import random
22

3-
def weighted_srs(population, weight, k):
4-
return random.choices(population, weight, k=k)
3+
def weighted_srs(population, n, weight, with_replacement=False):
4+
if with_replacement == True or weight != None:
5+
return random.choices(population, weight=weight, k=n)
6+
return random.sample(population, n)

0 commit comments

Comments
 (0)