Browse Source

code for median

master
fdai7968 11 months ago
parent
commit
4409190300
  1. 8
      src/average_median/average_median.c

8
src/average_median/average_median.c

@ -10,3 +10,11 @@ double average(const double *data, int n) {
} }
return sum / n; return sum / n;
} }
double median(double *data, int n) {
if (n % 2 == 0) {
return (data[n / 2 - 1] + data[n / 2]) / 2.0;
} else {
return data[n / 2];
}
}
Loading…
Cancel
Save