FAQ: One-Sample T-Tests in SciPy - Implementing a One-Sample T-Test

This community-built FAQ covers the “Implementing a One-Sample T-Test” exercise from the lesson “One-Sample T-Tests in SciPy”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Master Statistics with Python

FAQs on the exercise Implementing a One-Sample T-Test

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!
You can also find further discussion and get answers to your questions over in Language Help.

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head to Language Help and Tips and Resources. If you are wanting feedback or inspiration for a project, check out Projects.

Looking for motivation to keep learning? Join our wider discussions in Community

Learn more about how to use this guide.

Found a bug? Report it online, or post in Bug Reporting

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

P-values are probabilities, so they should be between 0 and 1. This p-value is the probability of observing an average purchase price less than 980 OR more than 1020 among a sample of 50 purchases. If you run the test correctly, you should see a p-value of 0.49 or 49%.

Given that the mean purchase price in this sample was 980, which is not very far from 1000, we probably expect this p-value to be relatively large. The only reason it COULD be small (eg., <.05) is if purchase prices had very little variation (eg., they were all within a few Rupees of 980). We can see from the data print out that this is not the case. Therefore, a p-value around 0.49 makes sense!

  1. In this case, how does this result affect our hypothesis:
  • Null: The average cost of a BuyPie order is 1000 Rupees
  • Alternative: The average cost of a BuyPie order is not 1000 Rupees.
  1. What will happen if we change the order of the hypothesis?
  • Null: The average cost of a BuyPie order is not 1000 Rupees.
  • Alternative: The average cost of a BuyPie order is 1000 Rupees

Thank you in advance

The null hypothesis is always one that states that there is no change to the assumption. If the population is 1000, we assume the null will be “The average cost of a BuyPie order is 1000 Rupees” aka there was no change.

What I dont understand is the logic on the t_test where " The average cost of a BuyPie order is not 1000 Rupees." means finding the probability that the mean is less than 980 or more than 1020. I get where those numbers come from but not the logic

Hi,

i have a question about the t-test function : as seen in the lesson, the ttest is runned knowing the mean of the distribution and using the CLT to compute the value for a normal distribution (i understood). In this exercice this is clearly the case BUT as we don’t use a real population in this exercice, how can the t-test be relevant without taking into account the standard deviation of the normal distribution drawn from the simulation ?

have a nice day,
Etienne