Home /
Expert Answers /
Computer Science /
question-2-1-define-a-function-one-sample-mean-its-arguments-should-be-table-the-name-of-a-tabl-pa882
(Solved):
Question 2.1. Define a function one_sample_mean. Its arguments should be table (the name of a tabl ...
Question 2.1. Define a function one_sample_mean. Its arguments should be table (the name of a table), (the label of the column containing the variable), and sample_size (the number of employees in the sample). It should sample with replacement from the table and return the mean of the column of the sample. def one_sample_mean(table, label, sample_size): new_sample = table.sample(with_replacement=True, k=sample_size) new_sample_mean = np.mean (new_sample.column(label)) return new_sample_mean
Question 2.2. Use one_sample_mean to define a function simulate_sample_mean. The arguments are the name of the table, the label of the column containing the variable, the sample_size, and the number of simulations (repetitions ). The function should sample with replacement from the table and calculate the mean of each sample. It should save the sample means in an array called The remaining code in the function displays an empirical histogram of the sample means. Note: We round all values to 2 decimal places because we are working with salaries.
print all relevant quantities - don't change this! size\}; \{repetitions\} Resamples'.format(sample_size=sample_size, repetitions=repetitions)) (table.column(label)). round(2))