Nov-05-2024, 01:10 AM
I wrote a Python code for what's called rerandomization in statistics. See below:
I call this function somewhere downstream and then use what it returns for the function compute_mean(list_treatment, list_control)
Gracias.
number_data = int(input("Enter size of data for each group (they will be same): "))
sim_size = int(input("Enter number of sims: "))
alpha = float(input("Set alpha/significance level: "))
print()
list_treatment = []
list_control = []
def collect_data(number_data):
print("Enter treatment data points")
for i in range(number_data):
entry = float(input("Enter treatment data point: "))
list_treatment.append(entry)
print()
print("Enter control data points")
for i in range(number_data):
entry = float(input("Enter control data point: "))
list_control.append(entry)
return list_treatment, list_controlSo the above chunk of code (function) returns list_treatment and list_controlI call this function somewhere downstream and then use what it returns for the function compute_mean(list_treatment, list_control)
collect_data(number_data) print() difference = compute_mean(list_treatment, list_control)I was really worried that I'll get an error message but I didn't. It works. Just wondering if this is ok per the standards of good coding practice or worse, it can lead to errors that I haven't encountered because my code was simple.
Gracias.
