normalized mean squared error = mse(a, b) / mse(a, 0)
| 175 | |
| 176 | // normalized mean squared error = mse(a, b) / mse(a, 0) |
| 177 | static double nmse(const float * a, const float * b, size_t n) { |
| 178 | double mse_a_b = 0.0; |
| 179 | double mse_a_0 = 0.0; |
| 180 | |
| 181 | for (size_t i = 0; i < n; i++) { |
| 182 | float a_i = a[i]; |
| 183 | float b_i = b[i]; |
| 184 | |
| 185 | mse_a_b += (a_i - b_i) * (a_i - b_i); |
| 186 | mse_a_0 += a_i * a_i; |
| 187 | } |
| 188 | |
| 189 | return mse_a_b / mse_a_0; |
| 190 | } |
| 191 | |
| 192 | // maximum absolute asymmetry between a and b |
| 193 | // asymmetry: (a - b) / (a + b) |