44 for (i = 0; i < n_elements; i++) {
45 sum += (float)array[i];
48 return (
int32_t)(sum / n_elements);
77 float sumX = 0.f, sumY = 0.f, sumXY = 0.f;
81 for (i = 0; i < n_elements; i++) {
82 sumX += (float)array1[i];
83 sumY += (float)array2[i];
84 sumXY += (float)(array1[i]) * (float)(array2[i]);
87 return (
int32_t)(sumXY / n_elements - sumX * sumY / (n_elements * n_elements));
104 for (i = 0; i < n_elements; i++) {
108 return (sum / n_elements);
135 float sumX = 0.f, sumY = 0.f, sumXY = 0.f;
139 for (i = 0; i < n_elements; i++) {
142 sumXY += arr1[i] * arr2[i];
145 return (sumXY / n_elements - sumX * sumY / (n_elements * n_elements));
int32_t variance_i(int32_t *array, uint32_t n_elements)
Compute the variance of an array of values (integer).
float mean_f(float *array, uint32_t n_elements)
Compute the mean value of an array (float)
int32_t covariance_i(int32_t *array1, int32_t *array2, uint32_t n_elements)
Compute the covariance of two arrays V(X) = E[(X-E[X])(Y-E[Y])] = E[XY] - E[X]E[Y] where E[X] is the ...
float covariance_f(float *arr1, float *arr2, uint32_t n_elements)
Compute the covariance of two arrays V(X) = E[(X-E[X])(Y-E[Y])] = E[XY] - E[X]E[Y] where E[X] is the ...
float variance_f(float *array, uint32_t n_elements)
Compute the variance of an array of values (float).
int32_t mean_i(int32_t *array, uint32_t n_elements)
Compute the mean value of an array This is implemented using floats to handle scaling of all variable...