Key Concepts

Review core concepts you need to learn to master this subject

Two-Sample T-Test

from scipy.stats import ttest_ind #separate out claw lengths for two species grizzly_bear = data.claw_length[data.species=='grizzly'] black_bear = data.claw_length[data.species=='black'] #run the t-test here: tstat, pval = ttest_ind(grizzly_bear, black_bear)

We can test an association between a quantitative variable and a binary categorical variable by using a two-sample t-test. The null hypothesis for a two-sample t-test is that the difference in group means is equal to zero. A two-sample t-test can be implemented in Python using the ttest_ind() function from scipy.stats. The example code shows a two-sample t-test for testing an association between claw length and species of bear (grizzly or black).

Hypothesis Testing: Associations
Lesson 1 of 1
  1. 1
    In this lesson, we’ll use hypothesis tests to make inference about population-level associations between two variables. We will cover four different hypothesis tests: * Two Sample T-Tests (for a…
  2. 2
    Suppose that a company is considering a new color-scheme for their website. They think that visitors will spend more time on the site if it is brightly colored. To test this theory, the company sho…
  3. 3
    In the previous exercise, we used a two-sample t-test to investigate an association between a quantitative variable (time spent on a website) and a binary categorical variable (an old color scheme …
  4. 4
    In the last exercise, we ran three separate 2-sample t-tests to investigate an association between a quantitative variable (amount spent per sale) and a non-binary categorical variable (location of…
  5. 5
    Let’s say that we have performed an ANOVA to compare sales at the three VeryAnts stores. We calculated a p-value less than 0.05 and concluded that there is a significant difference between at least…
  6. 6
    Before we use a two sample t-test, ANOVA, or Tukey’s range test, we need to be sure that the following things are true: #### 1. The observations should be independently randomly sampled from the p…
  7. 7
    If we want to understand whether the outcomes of two categorical variables are associated, we can use a Chi-Square test. It is useful in situations like: * An A/B test where half of users were sho…
  8. 8
    Before we use a Chi-Square test, we need to be sure that the following things are true: #### 1. The observations should be independently randomly sampled from the population This is also true of 2…
  9. 9
    In this lesson, we have reviewed a few different ways to run a hypothesis test for an association between two variables: * Two Sample T-Tests (for an association between a quantitative variable an…

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo