Skip to content

Commit d57b17b

Browse files
authored
Merge pull request #95 from Apexq/main
Create weighted_besir_secilmis.py
2 parents cfb6e08 + ca54247 commit d57b17b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Week03/weighted_besir_secilmis.py

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

0 commit comments

Comments
 (0)