# mean (Descriptive Statistics) 1.x.x.x

### Import

#include <archr/stats/mean.h>
#include <archr/stats/mean.hpp>
import archr.stats
atomsLoads('archr')

### Synopsis

  float archr_stats_mean_f32(const float *first, size_t nbelem);  (1)  double archr_stats_mean_f64(const double *first, size_t nbelem);  (2)
  float mean(const float *first, size_t nbelem);  (1)  double mean(const double *first, size_t nbelem);  (2)  double mean(const float *first, const float *last);  (3)  double mean(const double *first, const double *last);  (4) template double mean(const Range& data);  (5)
 subroutine archr_stats_mean_f32(real(4) :: r, real(4), dimension(*), parameter :: first, integer(4) :: nbelem)  (1) subroutine archr_stats_mean_f64(real(8) :: r, real(8), dimension(*), parameter :: first, integer(4) :: nbelem)  (2)
 def mean(first): return r  (1)
 function r = archr_stats_mean(first)  (1)

### Description

This function computes the mean of the elements stored in:

• (1,2) the [first, last[ range
• (3,4) the [first, first+nbelem[ range

### Parameters

 first the beginning of the range of elements to average. last the end of the range of elements to average. nbelem the number of elements to average.

### Return value

The mean of the elements in the given range.

### Example

#include <archr/stats/mean.h>
#include <stdio.h>

int main()
{
float v[] = {1,2,3,4,5,6};

printf("mean(1,2,3,4,5,6) = %f\n", archr_stats_mean_f32(&v[0],6) );

return 0;
}


### Possible Output

mean(1,2,3,4,5,6) = 3.500000
mean(1,2,3,4)     = 2.500000

#include <archr/stats/mean.hpp>
#include <iostream>
#include <vector>

int main()
{
std::vector<float> v{1,2,3,4,5,6};

std::cout << "mean(1,2,3,4,5,6) = " << archr::stats::mean(v) << "\n";
std::cout << "mean(1,2,3,4,5)   = " << archr::stats::mean(v.data(), 5) << "\n";
std::cout << "mean(1,2,3,4)     = " << archr::stats::mean(v.data(), v.data() + 4) << "\n";

return 0;
}


### Possible Output

mean(1,2,3,4,5,6) = 3.5
mean(1,2,3,4,5)   = 3
mean(1,2,3,4)     = 2.5