[Solved] How to calculate a decaying average? [closed]
Here’s a simplistic implementation of what you asking. #include <stddef.h> #include <stdlib.h> #include <stdio.h> int normalize_weights(double *weights, size_t num_weights) { double sum = 0; for (size_t i = 0; i < num_weights; ++i) { if (weights[i] < 0) return -1; sum += weights[i]; } if (sum == 0) return -1; for (size_t i = 0; … Read more