Function calculate_mean_in_range

Function Documentation

float calculate_mean_in_range(const std::vector<float> &vector, int start, int end)

Calculates the mean of elements in a specified range of a vector.

This function computes the mean (average) of the elements in the given vector from the index start to the index end (inclusive).

Parameters:
  • vector – The vector containing the elements.

  • start – The starting index of the range (inclusive).

  • end – The ending index of the range (inclusive).

Throws:
  • std::out_of_range – If the start or end indices are out of the vector’s bounds.

  • std::invalid_argument – If the start index is greater than the end index.

Returns:

The mean of the elements in the specified range.