Learn

In this lesson, we’ll walk through the implementation of a one-sample t-test in Python. One-sample t-tests are used for comparing a sample average to a hypothetical population average. For example, a one-sample t-test might be used to address questions such as:

  • Is the average amount of time that visitors spend on a website different from 5 minutes?
  • Is the average amount of money that customers spend on a purchase more than 10 USD?

As an example, let’s imagine the fictional business BuyPie, which sends ingredients for pies to your household so that you can make them from scratch. Suppose that a product manager wants online BuyPie orders to cost around 1000 Rupees on average. In the past day, 50 people made an online purchase and the average payment per order was less than 1000 Rupees. Are people really spending less than 1000 Rupees on average? Or is this the result of chance and a small sample size?

Instructions

1.

We have provided a small dataset called prices, representing the purchase prices of customers to BuyPie.com in the past day.

First, print out prices to the console and examine the numbers. How much variation is there in the purchase prices? Can you estimate the mean by looking at these numbers?

2.

Calculate the mean of prices using np.mean(). Store it in a variable called prices_mean and print it out.

What is the average purchase price for these 50 purchases? Is it a lot less than 1000? Or only a little less?

Sign up to start coding

By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.
Already have an account?