For some synthetic data, where variance is zero, the ZNormalize may generate NaN values in the Vecs.
// now convert variance to standard deviation
for (int i = 0; i < m; i++)
var[i] = Math.Sqrt(var[i]);
// last, z-score normalize all points
for (int i = 0; i < n; i++)
points[i] = (points[i] - mean) / var;
A simple fix is to make var[i] = 1 if var[i] < EPS, . (if var == 0, the delta from mean is also 0 and it is fine to divide by 1 :) )
For some synthetic data, where variance is zero, the ZNormalize may generate NaN values in the Vecs.
A simple fix is to make var[i] = 1 if var[i] < EPS, . (if var == 0, the delta from mean is also 0 and it is fine to divide by 1 :) )