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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!