Using the information in the picture, answer these questions Define the null and alternative hypotheses in mathematical terms as well as in words. Identify the level of significance. Include the test statistic and the P-value. See Step 2 in the Python script. (Note that Python methods return two tailed P-values. You must report the correct P-value based on the alternative hypothesis.)

MATLAB: An Introduction with Applications
6th Edition
ISBN:9781119256830
Author:Amos Gilat
Publisher:Amos Gilat
Chapter1: Starting With Matlab
Section: Chapter Questions
Problem 1P
icon
Related questions
Question

Using the information in the picture, answer these questions

  1. Define the null and alternative hypotheses in mathematical terms as well as in words.
  2. Identify the level of significance.
  3. Include the test statistic and the P-value. See Step 2 in the Python script. (Note that Python methods return two tailed P-values. You must report the correct P-value based on the alternative hypothesis.)
  4. Provide a conclusion and interpretation of the test: Should the null hypothesis be rejected? Why or why not?
Step 1: Generating sample data
This block of Python code will generate two samples, both of size 50, that you will use in this discussion. The datasets will be unique to you and therefore your
answers will be unique as well. The numpy module in Python allows you to create a data set using a Normal distribution. The data sets will be saved in Python
dataframes and will be used in later calculations.
Click the block of code below and hit the Run button above.
import pandas as pd
import numpy as np
# create 50 randomly chosen values from a normal distribution. (arbitrarily using mean-2.48 and standard deviation-0.500)
diameters_sampled np.random.normal(2.48,0.588,50)
#convert the array into a dataframe with the column name "diameters" using pandas Library
diameters_sampled_df = pd.DataFrame(diameters_samplai, columns=["diameters'])
diameters_sample1_df = diameters_sample1_df.round(2)
# create 50 randomly chosen values from a normal distribution. (arbitrarily using mean-2.50 and standard deviation-0.758)
diameters_sample2 np.random.normal(2.58,0.758,50)
#convert the array into a dataframe with the column name "diameters" using pandas Library
pd.DataFrano(diameters_sample2, columns=["diameters'])
diameters_sample2 df
diameters_sample2_df = diameters_sample2_df.round(2)
# print the dataframe to see the first 5 observations (note that the index of dataframe starts at 8)
print("Diameters data frame of the first sample (showing only the first five observations)")
print(diameters_sample1_df.head())
print()
print("Diameters data frame of the second sample (showing only the first five observations)")
print(diameters_sample2_df.head())
Diameters data frame of the first sample (showing only the first five observations)
diameters
2.56
3.10
2.85
1
2
3
4
1.87
2.15
Diameters data frame of the second sample (showing only the first five observations)
diameters
2.44
2.27
3.88
1.34
2.78
1
2
3
Step 2: Performing hypothesis test for the difference in population proportions
The z-test for proportions can be used to test for the difference in proportions. The proportions_ztest method in statsmodels.stats.proportion submodule runs
this test. The input to this method is a list of counts meeting a certain condition (given in the problem statement) and a list of sample sizes for the two samples.
Counts Python list that is assigned the number of observations in each sample with diameter values less than 2.20.
Python list that is assigned the total number of observations in each sample.
Click the block of code below and hit the Run button above.
from statsmodels.stats.proportion import proportions_ztest
#number of observations in the first sample with diameter values Less than 2.20.
counti len(diameters_sample1_df[diameters_sample1_df["diameters']<2.20])
#number of observations in the second sample with diameter values Less than 2.28.
count2 len(diameters_sample2_df[diameters_sample2_df["diameters']<2.20])
#counts Python List
counts [counti, count2]
#number of observations in the first sample
ni len(diameters_sample1_df)
#number of observations in the second sample
n2 len(diameters_sample2_df)
#n Python List
n = [1, 2]
#perform the hypothesis test. output is a Python tuple that contains test_statistic and the two-sided P_value.
test_statistic, p_value proportions_ztest(counts, n)
print("test-statistic =*, round(test_statistic, 2))
print("two tailed p-value=", round(p_value,4))
test-statistic = 8.69
two tailed p-value - 0.4884
Transcribed Image Text:Step 1: Generating sample data This block of Python code will generate two samples, both of size 50, that you will use in this discussion. The datasets will be unique to you and therefore your answers will be unique as well. The numpy module in Python allows you to create a data set using a Normal distribution. The data sets will be saved in Python dataframes and will be used in later calculations. Click the block of code below and hit the Run button above. import pandas as pd import numpy as np # create 50 randomly chosen values from a normal distribution. (arbitrarily using mean-2.48 and standard deviation-0.500) diameters_sampled np.random.normal(2.48,0.588,50) #convert the array into a dataframe with the column name "diameters" using pandas Library diameters_sampled_df = pd.DataFrame(diameters_samplai, columns=["diameters']) diameters_sample1_df = diameters_sample1_df.round(2) # create 50 randomly chosen values from a normal distribution. (arbitrarily using mean-2.50 and standard deviation-0.758) diameters_sample2 np.random.normal(2.58,0.758,50) #convert the array into a dataframe with the column name "diameters" using pandas Library pd.DataFrano(diameters_sample2, columns=["diameters']) diameters_sample2 df diameters_sample2_df = diameters_sample2_df.round(2) # print the dataframe to see the first 5 observations (note that the index of dataframe starts at 8) print("Diameters data frame of the first sample (showing only the first five observations)") print(diameters_sample1_df.head()) print() print("Diameters data frame of the second sample (showing only the first five observations)") print(diameters_sample2_df.head()) Diameters data frame of the first sample (showing only the first five observations) diameters 2.56 3.10 2.85 1 2 3 4 1.87 2.15 Diameters data frame of the second sample (showing only the first five observations) diameters 2.44 2.27 3.88 1.34 2.78 1 2 3 Step 2: Performing hypothesis test for the difference in population proportions The z-test for proportions can be used to test for the difference in proportions. The proportions_ztest method in statsmodels.stats.proportion submodule runs this test. The input to this method is a list of counts meeting a certain condition (given in the problem statement) and a list of sample sizes for the two samples. Counts Python list that is assigned the number of observations in each sample with diameter values less than 2.20. Python list that is assigned the total number of observations in each sample. Click the block of code below and hit the Run button above. from statsmodels.stats.proportion import proportions_ztest #number of observations in the first sample with diameter values Less than 2.20. counti len(diameters_sample1_df[diameters_sample1_df["diameters']<2.20]) #number of observations in the second sample with diameter values Less than 2.28. count2 len(diameters_sample2_df[diameters_sample2_df["diameters']<2.20]) #counts Python List counts [counti, count2] #number of observations in the first sample ni len(diameters_sample1_df) #number of observations in the second sample n2 len(diameters_sample2_df) #n Python List n = [1, 2] #perform the hypothesis test. output is a Python tuple that contains test_statistic and the two-sided P_value. test_statistic, p_value proportions_ztest(counts, n) print("test-statistic =*, round(test_statistic, 2)) print("two tailed p-value=", round(p_value,4)) test-statistic = 8.69 two tailed p-value - 0.4884
Expert Solution
steps

Step by step

Solved in 4 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
MATLAB: An Introduction with Applications
MATLAB: An Introduction with Applications
Statistics
ISBN:
9781119256830
Author:
Amos Gilat
Publisher:
John Wiley & Sons Inc
Probability and Statistics for Engineering and th…
Probability and Statistics for Engineering and th…
Statistics
ISBN:
9781305251809
Author:
Jay L. Devore
Publisher:
Cengage Learning
Statistics for The Behavioral Sciences (MindTap C…
Statistics for The Behavioral Sciences (MindTap C…
Statistics
ISBN:
9781305504912
Author:
Frederick J Gravetter, Larry B. Wallnau
Publisher:
Cengage Learning
Elementary Statistics: Picturing the World (7th E…
Elementary Statistics: Picturing the World (7th E…
Statistics
ISBN:
9780134683416
Author:
Ron Larson, Betsy Farber
Publisher:
PEARSON
The Basic Practice of Statistics
The Basic Practice of Statistics
Statistics
ISBN:
9781319042578
Author:
David S. Moore, William I. Notz, Michael A. Fligner
Publisher:
W. H. Freeman
Introduction to the Practice of Statistics
Introduction to the Practice of Statistics
Statistics
ISBN:
9781319013387
Author:
David S. Moore, George P. McCabe, Bruce A. Craig
Publisher:
W. H. Freeman