# Average Aggregation

A single-value metrics aggregation that computes the average of numeric values that are extracted from the aggregated documents.

arithmetic mean, also called the mathematical expectation or average, is the central value of a discrete set of numbers: specifically, the sum of the values divided by the number of values. 1

Type Description Example Result
Mean (or Average) Sum of values of a data set divided by number of values (1+2+2+3+4+7+9) / 7 4
Median Middle value separating the greater and lesser halves of a data set 1, 2, 2, 3, 4, 7, 9 3
Mode Most frequent value in a data set 1, 2, 2, 3, 4, 7, 9 2

## Structuring

The following snippet captures the structure of average aggregations:

``````"<aggregation_name>": {
"_avg": {
"_field": "<field_name>"
},
...
}
``````

### Field

The `<field_name>` in the `_field` parameter defines the specific field from which the numeric values in the documents are extracted and used to compute the returned average.

Assuming the data consists of documents representing bank accounts, as shown in the sample dataset of Data Exploration section, computing the average age of all account holders:

The above aggregation computes the average grade over all documents. The above will return the following:

``````{
"aggregations": {
"_doc_count": 1000,
"avg_age": {
"_avg": 30.042
}
}, ...
}
``````

The name of the aggregation (`avg_grade` above) also serves as the key by which the aggregation result can be retrieved from the returned response.