# t test formula

# t-test definition

**Student t test** is a **statistical test** which is widely used to compare the mean of two groups of samples. It is therefore to evaluate whether the means of the two sets of data are statistically **significantly** different from each other.

There are many types of **t test** :

- The
**one-sample t-test**, used to compare the mean of a population with a theoretical value. - The
**unpaired two sample t-test**, used to compare the mean of two**independent samples**. - The
**paired t-test**, used to compare the means between two related groups of samples.

The aim of this article is to describe the different **t test formula**. **Student’s t-test** is a **parametric test** as the **formula** depends on the **mean** and the **standard deviation** of the data being compared.

**t-test calculator**is available here to compute

**t-test statistics**without any installation.

# One-sample t-test formula

As mentioned above, **one-sample t-test** is used to compare the mean of a population to a specified **theoretical mean** (\(\mu\)).

Let X represents a set of values with size n, with **mean** m and with **standard deviation** S. The comparison of the **observed mean (m) of the population** to a **theoretical value** \(\mu\) is performed with the formula below :

\[ t = \frac{m-\mu}{s/\sqrt{n}} \]

To evaluate whether the difference is statistically significant, you first have to read in **t test table** the **critical value of Student’s t distribution** corresponding to the **significance level alpha** of your choice (5%). The **degrees of freedom** (df) used in this test are :

\[ df = n - 1 \]

If the absolute value of the **t-test statistics** (|t|) is greater than the critical value, then the difference is significant. Otherwise it isn’t. The **level of significance** or (**p-value**) corresponds to the risk indicated by the **t test table** for the calculated |t| value.

The **t test** can be used only when the data are normally distributed.

# Independent two sample t-test

## What is independent t-test ?

**Independent (or unpaired two sample) t-test** is used to compare the means of two unrelated groups of samples.

As an example, we have a cohort of 100 individuals (50 women and 50 men). The question is to test whether the average weight of women is significantly different from that of men?

In this case, we have two independents groups of samples and **unpaired t-test** can be used to test whether the means are different.

## Independent t-test formula

- Let A and B represent the two groups to compare.
- Let \(m_A\) and \(m_B\) represent the means of groups A and B, respectively.
- Let \(n_A\) and \(n_B\) represent the sizes of group A and B, respectively.

The **t test statistic value** to test whether the means are different can be calculated as follow :

\[ t = \frac{m_A - m_B}{\sqrt{ \frac{S^2}{n_A} + \frac{S^2}{n_B} }} \]

\(S^2\) is an estimator of the common **variance** of the two samples. It can be calculated as follow :

\[ S^2 = \frac{\sum{(x-m_A)^2}+\sum{(x-m_B)^2}}{n_A+n_B-2} \]

Once **t-test statistic value** is determined, you have to read in **t-test table** the **critical value of Student’s t distribution** corresponding to the **significance level alpha** of your choice (5%). The **degrees of freedom** (df) used in this test are :

\[ df = n_A + n_B -2 \]

If the absolute value of the **t-test statistics** (|t|) is greater than the critical value, then the difference is significant. Otherwise it isn’t. The **level of significance** or (**p-value**) corresponds to the risk indicated by the **t-test table** for the calculated |t| value.

The test can be used only when the two groups of samples (A and B) being compared follow bivariate **normal distribution** with equal **variances**.

If the variances of the two groups being compared are different, the **Welch t test** can be used.

# Paired sample t-test

## What is paired t-test ?

**Paired Student’s t-test** is used to compare the means of two related samples. That is when you have two values (pair of values) for the same samples.

For example, 20 mice received a treatment X for 3 months. The question is to test whether the treatment X has an impact on the weight of the mice at the end of the 3 months treatment. The weight of the 20 mice has been measured before and after the treatment. This gives us 20 sets of values before treatment and 20 sets of values after treatment from measuring twice the weight of the same mice.

In this case, **paired t-test** can be used as the two sets of values being compared are related. We have a pair of values for each mouse (one before and the other after treatment).

## Paired t-test formula

To compare the means of the two paired sets of data, the differences between all pairs must be, first, calculated.

Let d represents the differences between all pairs. The average of the difference d is compared to 0. If there is any significant difference between the two pairs of samples, then the mean of d is expected to be far from 0.

**t test statistisc value** can be calculated as follow :

\[ t = \frac{m}{s/\sqrt{n}} \]

**m** and **s** are the **mean** and the **standard deviation** of the difference (d), respectively. **n** is the size of d.

Once **t value** is determined, you have to read in **t-test table** the **critical value of Student’s t distribution** corresponding to the **significance level alpha** of your choice (5%). The **degrees of freedom** (df) used in this test are :

\[ df = n - 1 \]

If the absolute value of the **t-test statistics** (|t|) is greater than the critical value, then the difference is significant. Otherwise it isn’t. The **level of significance** or (**p-value**) corresponds to the risk indicated by the **t-test table** for the calculated |t| value.

The test can be used only when the difference d is normally distributed.

# Online t-test calculator

You no longer need SPSS or Excel to perform **t-test**.

An **online t-test calculator** is available here to perform **Student’s t-test** without any installation.

Depending on the types of **Student’s t-test** you want to do, click the following links :

# Infos

This analysis has been done using R (ver. 3.1.0).

Show me some love with the like buttons below... Thank you and please don't forget to share and comment below!!

Montrez-moi un peu d'amour avec les like ci-dessous ... Merci et n'oubliez pas, s'il vous plaît, de partager et de commenter ci-dessous!

## Recommended for You!

## Recommended for you

This section contains best data science and self-development resources to help you on your path.

### Coursera - Online Courses and Specialization

#### Data science

- Course: Machine Learning: Master the Fundamentals by Standford
- Specialization: Data Science by Johns Hopkins University
- Specialization: Python for Everybody by University of Michigan
- Courses: Build Skills for a Top Job in any Industry by Coursera
- Specialization: Master Machine Learning Fundamentals by University of Washington
- Specialization: Statistics with R by Duke University
- Specialization: Software Development in R by Johns Hopkins University
- Specialization: Genomic Data Science by Johns Hopkins University

#### Popular Courses Launched in 2020

- Google IT Automation with Python by Google
- AI for Medicine by deeplearning.ai
- Epidemiology in Public Health Practice by Johns Hopkins University
- AWS Fundamentals by Amazon Web Services

#### Trending Courses

- The Science of Well-Being by Yale University
- Google IT Support Professional by Google
- Python for Everybody by University of Michigan
- IBM Data Science Professional Certificate by IBM
- Business Foundations by University of Pennsylvania
- Introduction to Psychology by Yale University
- Excel Skills for Business by Macquarie University
- Psychological First Aid by Johns Hopkins University
- Graphic Design by Cal Arts

### Books - Data Science

#### Our Books

- Practical Guide to Cluster Analysis in R by A. Kassambara (Datanovia)
- Practical Guide To Principal Component Methods in R by A. Kassambara (Datanovia)
- Machine Learning Essentials: Practical Guide in R by A. Kassambara (Datanovia)
- R Graphics Essentials for Great Data Visualization by A. Kassambara (Datanovia)
- GGPlot2 Essentials for Great Data Visualization in R by A. Kassambara (Datanovia)
- Network Analysis and Visualization in R by A. Kassambara (Datanovia)
- Practical Statistics in R for Comparing Groups: Numerical Variables by A. Kassambara (Datanovia)
- Inter-Rater Reliability Essentials: Practical Guide in R by A. Kassambara (Datanovia)

#### Others

- R for Data Science: Import, Tidy, Transform, Visualize, and Model Data by Hadley Wickham & Garrett Grolemund
- Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow: Concepts, Tools, and Techniques to Build Intelligent Systems by Aurelien Géron
- Practical Statistics for Data Scientists: 50 Essential Concepts by Peter Bruce & Andrew Bruce
- Hands-On Programming with R: Write Your Own Functions And Simulations by Garrett Grolemund & Hadley Wickham
- An Introduction to Statistical Learning: with Applications in R by Gareth James et al.
- Deep Learning with R by François Chollet & J.J. Allaire
- Deep Learning with Python by François Chollet