Question: B 2 [ 1 pt ] Let's do a slightly different hypothesis test and let's do it in one step. Use the ttest _ 1

B2[1 pt] Let's do a slightly different hypothesis test and let's do it in one step. Use the ttest_1samp function to test the hypothesis that the mean tip percentage in the population is
17.1%. Store the results of the ttest_1samp function in the variable hypo_results. Use hypo_results and an if-else structure to define the variable reject_or_not. Again, the
variable reject_or_not should either be the string 'reject' or the string 'fail to reject'.
ln[14]:
Student's answer
hypo_results = None
reject_or_not = Noneimport pandas as pd
import numpy as np
from scipy.stats import ttest_1samp
import scipy.stats as stats
hypo_results = stats.ttest_1samp(tips_df['tip_percentage'],17.1) # Test against the population mean of 17.1%
if hypo_results.pvalue 0.05: # Standard significance level
reject_or_not = 'reject'
else:
reject_or_not = 'fail to reject'
print(f"Hypothesis test result: {reject_or_not}")
#raise NotImplementedError()
NameError
Traceback (most recent call last)
Cell In[14], line 12
7 from scipy.stats import ttest_1samp
9 import scipy.stats as stats
--->12 hypo_results = stats.ttest_1samp(tips_df['tip_percentage'],17.1) # Test against the population mean of 17.1%
15 if hypo_results.pvalue 0.05: # standard significance level
17 reject_or_not = 'reject'
NameError: name 'tips_df' is not defined
ln [15]:
#Hidden tests for Question B2 are within this cell.
You have failed this test due to an error. The traceback has been removed because it may contain hidden tests. This is the exception that was thrown:
AssertionError: Question B2: Your answer for reject_or_not does not match the official answer.
B 2 [ 1 pt ] Let's do a slightly different

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 Programming Questions!