ClickHouse/docs/en/sql-reference/aggregate-functions/reference/analysis_of_variance.md

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

46 lines
1.2 KiB
Markdown
Raw Normal View History

2024-05-10 18:19:32 +00:00
---
slug: /en/sql-reference/aggregate-functions/reference/analysis_of_variance
sidebar_position: 6
---
# analysisOfVariance
Provides a statistical test for one-way analysis of variance (ANOVA test). It is a test over several groups of normally distributed observations to find out whether all groups have the same mean or not.
**Syntax**
```sql
analysisOfVariance(val, group_no)
```
Aliases: `anova`
**Parameters**
- `val`: value.
- `group_no` : group number that `val` belongs to.
:::note
Groups are enumerated starting from 0 and there should be at least two groups to perform a test.
2024-05-15 14:22:25 +00:00
There should be at least one group with the number of observations greater than one.
2024-05-10 18:19:32 +00:00
:::
**Returned value**
2024-05-15 14:22:25 +00:00
- `(f_statistic, p_value)`. [Tuple](../../data-types/tuple.md)([Float64](../../data-types/float.md), [Float64](../../data-types/float.md)).
2024-05-10 18:19:32 +00:00
**Example**
Query:
```sql
2024-05-15 14:22:25 +00:00
SELECT analysisOfVariance(number, number % 2) FROM numbers(1048575);
2024-05-10 18:19:32 +00:00
```
Result:
```response
2024-05-15 14:22:25 +00:00
┌─analysisOfVariance(number, modulo(number, 2))─┐
│ (0,1) │
└───────────────────────────────────────────────┘
2024-05-10 18:19:32 +00:00
```