42 if (n_elements == 0) {
49 for (i = 0; i < n_elements; i++) {
50 sum += (float)
array[i];
52 return (
int32_t)(sum / n_elements);
80 if (n_elements == 0) {
85 float sumX = 0.f, sumY = 0.f, sumXY = 0.f;
89 for (i = 0; i < n_elements; i++) {
90 sumX += (float)array1[i];
91 sumY += (float)array2[i];
92 sumXY += (float)(array1[i]) * (float)(array2[i]);
94 return (
int32_t)(sumXY / n_elements - sumX * sumY / (n_elements * n_elements));
111 for (i = 0; i < n_elements; i++) {
124 if (n_elements == 0) {
128 return (
sum_f(
array, n_elements) / n_elements);
154 if (n_elements == 0) {
159 float sumX = 0.f, sumY = 0.f, sumXY = 0.f;
163 for (i = 0; i < n_elements; i++) {
166 sumXY += arr1[i] * arr2[i];
168 return (sumXY / n_elements - sumX * sumY / (n_elements * n_elements));
float sum_f(float *array, uint32_t n_elements)
Compute the sum array elements (float)
int32_t variance_i(int32_t *array, uint32_t n_elements)
Compute the variance of an array of values (integer).
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 ...
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...
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 mean_f(float *array, uint32_t n_elements)
Compute the mean value of an array (float)
float variance_f(float *array, uint32_t n_elements)
Compute the variance of an array of values (float).
int int32_t
Typedef defining 32 bit int type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.