/** * Generates a table with all the marginal probabilities for each value for all features. * * This table is kept in memory so the marginal probability is computed only one time. */ void ProbTable::calculate() { Histogram histogram = Histogram(rawData); int i = 0; int j = 0; t_prob value = 0; t_histogram hist_data; for (i = 0; i < featuresSize; ++i) { table[i] = (t_prob*) malloc(valuesRange[i] * sizeof(t_prob)); hist_data = histogram.getHistogram(i); for (j = 0; j < valuesRange[i]; ++j) { value = (t_prob) hist_data[j] / (t_prob) datasize; table[i][j] = value; } } }