Get startedGet started for free

Your first t-test

Now you will perform your first statistical test! We want to compare the mean heights in cm of the Sample_A group with a given value. We want to see whether the mean weight of the people in this sample is significantly different from the chosen cut-off point of 65 kg. You'll use a one-sample t-test, which allows you to compare the mean of a sample with a chosen value. You'll perform this test on the sample provided versus the crucial value of 65 kg, and test its significance by comparing the value of alpha to the p-value. scipy.stats has been loaded into the workspace as stats.

This exercise is part of the course

Performing Experiments in Python

View Course

Exercise instructions

  • Perform a one-sample t-test comparing the mean of Sample_A to 65; assign the output to t_result and print it.
  • Using a standard alpha value of 0.05, test the statistical significance of the result by comparing the p-value to alpha and print the appropriate message.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Perform t-test and print result
t_result=stats.ttest_1samp(____, ____)
print(t_result)

# Test significance
alpha= 0.05
if (____ < alpha):
    print("mean value of Sample A differs from given value")
else:
	print("No significant difference found")
Edit and Run Code