One way analysis of variance (ANOVA) tests whether multiple groups all belong to the same population or not.

If a conclusion is reached that the groups do not all belong to the same population, further tests may be utilised to identify the differences.

import numpy as np
import scipy.stats as stats
# Create four random groups of data with a mean difference of 1
mu, sigma = 10, 3 # mean and standard deviation
group1 = np.random.normal(mu, sigma, 50)
mu, sigma = 11, 3 # mean and standard deviation
group2 = np.random.normal(mu, sigma, 50)
mu, sigma = 12, 3 # mean and standard deviation
group3 = np.random.normal(mu, sigma, 50)
mu, sigma = 13, 3 # mean and standard deviation
group4 = np.random.normal(mu, sigma, 50)
# Test whether all groups belong to the same population
F_statistic, pVal = stats.f_oneway(group1, group2, group3, group4)
print ('P value:')
print (pVal)
OUT:
P value:
7.905723172217297e-09

An applied health service researcher, currently working for the NHS and the University of Exeter. Committed to all work being performed in Free and Open Source Software (FOSS), and as much source data being made available as possible.
GitHub page: https://github.com/MichaelAllen1966
View all posts by Michael Allen

Published

One thought on “54. Statistics: Analysis of variance (ANOVA)”

## One thought on “54. Statistics: Analysis of variance (ANOVA)”