Question
# Create an empty array to hold our simulated differences differences = np.array([]) # Set number of repetitions repetitions = 10000 # Combine the two
# Create an empty array to hold our simulated differences differences = np.array([]) # Set number of repetitions repetitions = 10000 # Combine the two arrays into a single array all_birthweights = np.append(nonsmoker_births, smoker_births)
for i in np.arange(repetitions): # Permute all_birthweights shuffled_birthweights = ... # Make the simulated smoker and non-smoker group sim_nonsmoker_births = shuffled_birthweights[:len(nonsmoker_births)] sim_smoker_births = shuffled_birthweights[len(nonsmoker_births):] # Calculate test statistics sim_difference = np.average(sim_nonsmoker_births) - np.average(sim_smoker_births) # Save the test statistics in differences differences = observed_difference - sim_difference
differences
Question:
What should I write in the places with three dots to generate a random sample?
I have tried sample(), choice(), but it always showsnumpy.ndarrary object has no attribute random
Thank you!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started