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 columQuestion 2.2. Use one_sample_mean to define a function simulate_sample_mean. The arguments are the name of the table, the labprint all relevant quantities - dont change this!
size\}; \{repetitions\} Resamples.format(sample_size=sample_size, repetit

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))


We have an Answer from Expert

View Expert Answer

Expert Answer


Question 2.1Here's an implementation of the one_sample_mean function in Python, using the pandas library:import numpy as npimport pandas as pddef one_
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe