FUNCTION
Trim_Mean
Calculates the mean of the interior of data set.
Interface
#include <codecogs/statistics/moments/trim_mean.h>
using namespace Statistics::Moments;
TrimMean calculates the mean taken by excluding a percentage of data points from the top and bottom tails of a data set. You can use this function when you wish to exclude outlying data from your analysis. TrimMean rounds the number of excluded data points down to the nearest multiple of 2. If percent = 0.1, 10 percent of 30 data points equals 3 points. For symmetry, TrimMean excludes a single value from the top and bottom of the data set.
Example 1
#include <codecogs/statistics/moments/trim_mean.h>
#include <iostream>
int main()
{
int x[8]={1, 2, 3, 4, 5, 6, 7, 8};
double tm = Stats::Moments::trimmean<int>(8, x, 0.5);
std::cout << "The mean of the interior of the x array is: " << tm<< std::endl;
return 0;
}Output:
The mean of the interior of the x array is: 4.5Parameters
n
the size of the array
data
is the array or range of values to trim and average
p
is the fractional number of data points to exclude from the calculation
Returns
the mean of the interior of the given data set
This function's source code is only visible to registered users — documentation and the calculator above are free to use either way. Sign in to see it.