Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Let's hypothesize that the mean tip percentage in the population is 1 7 % . Use sample _ mean, standard _ error, and the hypothesized

Let's hypothesize that the mean tip percentage in the population is 17%. Use sample_mean, standard_error, and the hypothesized value to calculate the t-statistic. Then use scipy.stats's norm.cdf function to calculate the p-value. Finally, decide whether you reject or fail to reject the hypothesis. Store your answers in the variables t_stat, p_val, and reject_or_not. The variable reject_or_not should either be the string 'reject' or the string 'fail to reject'. Remember to look at the units of the variable tip_percentage (in the output of taxi.head() above) in order to set the hypothesized value correctly. my code is wrong: import numpy as np
import pandas as pd
from scipy.stats import norm
taxi = pd.read_csv('assets/taxi.csv')
tip_percentages = taxi['tip_percentage']
hypothesized_mean =0.17
sample_mean = np.mean(tip_percentages)
sample_size = len(tip_percentages)
sample_var = np.var(tip_percentages, ddof=1)
standard_error = np.sqrt(sample_var / sample_size)
t_stat =(sample_mean - hypothesized_mean)/ standard_error
p_val =2* norm.cdf(-np.abs(t_stat))
alpha =0.05 # Significance level
reject_or_not = 'reject' if p_val < alpha else 'fail to reject'
print(f"t-statistic: {t_stat}")
print(f"p-value: {p_val}")
print(f"Decision: {reject_or_not}") error code: 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: Problem 2.1:Your answer for t_stat does not match the official answer.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications Dasfaa 2023 International Workshops Bdms 2023 Bdqm 2023 Gdma 2023 Bundlers 2023 Tianjin China April 17 20 2023 Proceedings Lncs 13922

Authors: Amr El Abbadi ,Gillian Dobbie ,Zhiyong Feng ,Lu Chen ,Xiaohui Tao ,Yingxia Shao ,Hongzhi Yin

1st Edition

3031354141, 978-3031354144

More Books

Students also viewed these Databases questions