Skip to content

Create weighted_ozge_ucar.py #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
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
7 changes: 7 additions & 0 deletions Week03/weighted_ozge_ucar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import random
def weight_srs(data , n,weights, with_replacement = False):#i create a function which named weight_srs take 4 parameter
if with_replacement == True or weights != None:
random_list= random.choices(data , k=n, weights=weights)#random_list variable hold a random choices from data set with weights
else:
random_list=random.sample(data,n)#if there is no weights then random_list variable hold just random elenments of data set
return random_list#the function weight_srs return the random_list