avg /= (double)klass.size();
variances[i][j] = avg;
}
}
GaussianParams result = new GaussianParams();
result.setDensity(vectorLength);
result.setMeans(means);
result.setVariances(variances);
result.setWeight((double)klass.size() / (double)allDataCount);
result.setDeterminant(Matrix.determinant(variances));
double[][] inv = new double[vectorLength][vectorLength];
for(int i = 0; i < vectorLength; i++) {
for(int j = 0; j < vectorLength; j++) {
inv[i][j] = variances[i][j];
}
}
Matrix.invert(inv);
result.setInvertedVariances(inv);
result.setMinMax(SearchUtils.getMinMax(allData));
return result;
}