diff --git "a/Week03/weighted_\305\236erif_Burak_Kalkan.py" "b/Week03/weighted_\305\236erif_Burak_Kalkan.py" new file mode 100644 index 0000000..326c0b5 --- /dev/null +++ "b/Week03/weighted_\305\236erif_Burak_Kalkan.py" @@ -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