Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Week03/weighted_Şerif_Burak_Kalkan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import random
# Şerif Burak Kalkan - 210315023
def weighted_srs(data, n, weights, with_replacement):
if not with_replacement:
raise ValueError("Weighted simple random sampling without replacement is not supported.")
sample = []
for _ in range(n):
choice = random.choices(data, weights=weights)[0]
sample.append(choice)
return sample