normalized mean squared error = mse(a, b) / mse(a, 0)
| 276 | |
| 277 | // normalized mean squared error = mse(a, b) / mse(a, 0) |
| 278 | static double nmse(const float * a, const float * b, size_t n) { |
| 279 | double mse_a_b = 0.0; |
| 280 | double mse_a_0 = 0.0; |
| 281 | |
| 282 | for (size_t i = 0; i < n; i++) { |
| 283 | float a_i = a[i]; |
| 284 | float b_i = b[i]; |
| 285 | |
| 286 | mse_a_b += (a_i - b_i) * (a_i - b_i); |
| 287 | mse_a_0 += a_i * a_i; |
| 288 | } |
| 289 | |
| 290 | return mse_a_b / mse_a_0; |
| 291 | } |
| 292 | |
| 293 | // difference between 2 sets (Jaccard distance, 0 - no difference, 1 - no overlap) |
| 294 | template <typename T> |