Skip to content

Commit 020c488

Browse files
authored
Merge pull request #82 from akoalp/patch-1
Create weighted_alp_ozdemir.py
2 parents d57b17b + 54d4891 commit 020c488

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Week03/weighted_alp_ozdemir.py

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

0 commit comments

Comments
 (0)