Create a population of 5000 individuals and their number of phone pick-ups per day to be used for later sampling. Here's the code I came up with:
def get_population(pickups, pop_size, std):
pop = np.random.randint(0, pickups, 5000)
mean = np.mean(pop)
std = np.std(pop)
return pop, mean, std
I used the given assertion errors to come up with the function, so I'm not even sure what I should be returning:
pop_pickups, pop_mean, pop_std = get_population(45, 5000, 42)
assert np.abs(pop_mean - 45) < 0.5, "Get population problem, testing pop_mean, population mean returned does not match expected population mean"
assert np.abs(pop_std - np.sqrt(45)) < 0.5, "Get population problem, testing pop_std, population standard deviation returned does not match expected standard deviation"
I assumed I needed to generate the population, then take the mean and std of said pop. But my code triggered the assertion error for incorrect mean. The ultimate goal is to visualize the bootstrap of a single mean.