# Spec AverageAccumulator
Accumulator for computing averages.

Extends | Accumulator
All Extended | Accumulator
Defined in | <seqan/misc/accumulators.h>
Signature | `template <typename TValue> struct Accumulator<TValue, AccuAverage>;`

## Template Parameters

`TValue` | The type of the values to compute the average of.

## Interface Function Overview

- `TResult average(acc);`
  Return the average of the included values.
- `TResult count(acc);`
  Return the number of included values.
- `TResult sum(acc);`
  Return the sum of the included values.

### Interface Functions Inherited From Accumulator

- `clear`
- `push`

## Interface Metafunction Overview

### Interface Metafunctions Inherited From Accumulator

- `Result`
- `Value`

## Detailed Description

The average of an empty sequence is defined to be 0.

### Examples

This program shows how to use the Average Accumulator.

    Accumulator<int, AccuAverage> acc;
    push(acc, 1);
    push(acc, 2);
    push(acc, 3);
    std::cout << "average: " << average(acc) << "\n"
              << "sum:     " << sum(acc) << "\n"
              << "count:   " << count(acc) << "\n";

The output is then:

    average: 2
    sum:     6
    count:   3

## Interface Functions Detail

### `TResult average(acc);`

Return the average of the included values.

#### Parameters

`acc` | The Accumulator to compute the average for.

#### Returns

`TResult` | The average of the values (Metafunction: Result).

#### Data Races

If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.

### `TResult count(acc);`

Return the number of included values.

#### Parameters

`count` | The number of values pushed to the accumulator.

#### Returns

`TResult` | The number of pushed values (Metafunction: Result).

#### Data Races

If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.

### `TResult sum(acc);`

Return the sum of the included values.

#### Parameters

`acc` | The Accumulator to compute the sum for.

#### Returns

`TResult` | The sum of the values (Metafunction: Result).

#### Data Races

If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.

#### Dox Sources

    /*!
     * @class AverageAccumulator
     *
     * @extends Accumulator
     *
     * @headerfile <seqan/misc/accumulators.h>
     *
     * @brief Accumulator for computing averages.
     *
     * @signature template <typename TValue> struct Accumulator<TValue,
     *            AccuAverage>;
     *
     * @tparam TValue The type of the values to compute the average of.
     *
     * The average of an empty sequence is defined to be 0.
     *
     * @section Examples
     *
     * This program shows how to use the Average Accumulator.
     *
     * @code{.cpp}
     * Accumulator<int, AccuAverage> acc;
     * push(acc, 1);
     * push(acc, 2);
     * push(acc, 3);
     * std::cout << "average: " << average(acc) << "\n"
     *           << "sum:     " << sum(acc) << "\n"
     *           << "count:   " << count(acc) << "\n";
     * @endcode
     *
     *
     * The output is then:
     *
     * @code{.console}
     * average: 2
     * sum:     6
     * count:   3
     * @endcode
     *
     *
     * @fn AverageAccumulator#average
     *
     * @brief Return the average of the included values.
     *
     * @signature TResult average(acc);
     *
     * @param[in] acc The Accumulator to compute the average for.
     *
     * @return TResult The average of the values (Metafunction: @link
     *                 Accumulator#Result @endlink).
     *
     * @fn AverageAccumulator#sum
     *
     * @brief Return the sum of the included values.
     *
     * @signature TResult sum(acc);
     *
     * @param[in] acc The Accumulator to compute the sum for.
     *
     * @return TResult The sum of the values (Metafunction: @link Accumulator#Result
     *                 @endlink).
     *
     * @fn AverageAccumulator#count
     *
     * @brief Return the number of included values.
     *
     * @signature TResult count(acc);
     *
     * @param[in] count The number of values pushed to the accumulator.
     *
     * @return TResult The number of pushed values (Metafunction: @link
     *                 Accumulator#Result @endlink).
     */