Skip to Content

ONEWAY_ANOVA

Overview

The ONEWAY_ANOVA function performs a one-way analysis of variance (ANOVA) to determine whether there are statistically significant differences between the means of up to three independent groups. This test is commonly used in statistics to compare the means of different samples and is based on the F-distribution. The function uses the scipy.stats package for computation. For more information, see the scipy.stats.f_oneway documentation.

This example function is provided as-is without any representation of accuracy.

Usage

To use the function in Excel:

=ONEWAY_ANOVA(group_one, group_two, [group_three])
  • group_one (2D list of float, required): First group of sample data.
  • group_two (2D list of float, required): Second group of sample data.
  • group_three (2D list of float, optional): Third group of sample data.

The function returns a 2D list with one row: [F-statistic, p-value], both as floats. If an error occurs, a 2D list of strings describing the error is returned.

Examples

Example 1: Compare Three Groups

Suppose you have three groups of data:

Group 1Group 2Group 3
233025
202927
223126
213224
242823

In Excel:

=ONEWAY_ANOVA({23;20;22;21;24}, {30;29;31;32;28}, {25;27;26;24;23})

Expected output:

F-statisticp-value
32.670.00001

This means there is a statistically significant difference between the group means.

Example 2: Compare Two Groups

Group 1Group 2
1015
1214
1116
1315

In Excel:

=ONEWAY_ANOVA({10;12;11;13}, {15;14;16;15})

Expected output:

F-statisticp-value
21.00.0038

A low p-value indicates a significant difference between the two groups.

Example 3: No Significant Difference

Group 1Group 2
55
66
77
88

In Excel:

=ONEWAY_ANOVA({5;6;7;8}, {5;6;7;8})

Expected output:

F-statisticp-value
0.01.0

This means there is no significant difference between the group means.

Example 4: Three Groups, Small Sample

Group 1Group 2Group 3
135
246

In Excel:

=ONEWAY_ANOVA({1;2}, {3;4}, {5;6})

Expected output:

F-statisticp-value
12.00.0761

This means the difference is not statistically significant at the 0.05 level.

Python Code

import scipy.stats def oneway_anova(group_one, group_two, group_three=None): """ Performs a one-way ANOVA test to compare the means of two or three independent groups. Args: group_one: 2D list of float, required. First group of sample data. group_two: 2D list of float, required. Second group of sample data. group_three: 2D list of float, optional. Third group of sample data. Returns: list: [[F-statistic (float), p-value (float)]] if successful, otherwise list of list of str with error message. This example function is provided as-is without any representation of accuracy. """ def flatten(group): if not isinstance(group, list): return None flat = [] for row in group: if isinstance(row, list): flat.extend(row) else: flat.append(row) return flat groups = [] for g in [group_one, group_two, group_three]: if g is not None: flat = flatten(g) if flat is None or not all(isinstance(x, (int, float)) for x in flat): return [["Each group must be a 2D list of numbers."]] groups.append(flat) if len(groups) < 2: return [["At least two groups are required."]] try: f_stat, p_val = scipy.stats.f_oneway(*groups) return [[round(float(f_stat), 2), round(float(p_val), 5)]] except Exception as e: return [[str(e)]]

Live Notebook

Edit this function in a live notebook.

Live Demo

Last updated on