reversing changes.

This commit is contained in:
Ílker Yaz 2012-05-29 23:10:23 +00:00
parent e96059b6f9
commit 1a97c50d10
1 changed files with 9 additions and 9 deletions

View File

@ -42,7 +42,7 @@ public:
} }
void calculate_total_membership(const std::vector<Gaussian_center>& centers) { void calculate_total_membership(const std::vector<Gaussian_center>& centers) {
total_membership = 0.0; total_membership = 0.0;
for(typename std::vector<Gaussian_center>::const_iterator it = centers.begin(); for(std::vector<Gaussian_center>::const_iterator it = centers.begin();
it != centers.end(); ++it) { it != centers.end(); ++it) {
total_membership += it->probability(data) * it->mixing_coefficient; total_membership += it->probability(data) * it->mixing_coefficient;
} }
@ -54,7 +54,7 @@ inline void Gaussian_center::calculate_parameters(const
{ {
/* Calculate new mean */ /* Calculate new mean */
double new_mean = 0.0, total_membership = 0.0; double new_mean = 0.0, total_membership = 0.0;
for(typename std::vector<Gaussian_point>::const_iterator it = points.begin(); for(std::vector<Gaussian_point>::const_iterator it = points.begin();
it != points.end(); ++it) { it != points.end(); ++it) {
double membership = (probability(it->data) * mixing_coefficient) / double membership = (probability(it->data) * mixing_coefficient) /
it->total_membership; it->total_membership;
@ -64,7 +64,7 @@ inline void Gaussian_center::calculate_parameters(const
new_mean /= total_membership; new_mean /= total_membership;
/* Calculate new deviation */ /* Calculate new deviation */
double new_deviation = 0.0; double new_deviation = 0.0;
for(typename std::vector<Gaussian_point>::const_iterator it = points.begin(); for(std::vector<Gaussian_point>::const_iterator it = points.begin();
it != points.end(); ++it) { it != points.end(); ++it) {
double membership = (probability(it->data) * mixing_coefficient) / double membership = (probability(it->data) * mixing_coefficient) /
it->total_membership; it->total_membership;
@ -91,11 +91,11 @@ public:
calculate_fitting(); calculate_fitting();
} }
void fill_with_center_ids(std::vector<int>& data_centers) { void fill_with_center_ids(std::vector<int>& data_centers) {
for(typename std::vector<Gaussian_point>::iterator point_it = points.begin(); for(std::vector<Gaussian_point>::iterator point_it = points.begin();
point_it != points.end(); ++point_it) { point_it != points.end(); ++point_it) {
double max_likelihood = 0.0; double max_likelihood = 0.0;
int max_center = 0, center_counter = 0; int max_center = 0, center_counter = 0;
for(typename std::vector<Gaussian_center>::iterator center_it = centers.begin(); for(std::vector<Gaussian_center>::iterator center_it = centers.begin();
center_it != centers.end(); ++center_it, center_counter++) { center_it != centers.end(); ++center_it, center_counter++) {
double likelihood = center_it->mixing_coefficient * center_it->probability( double likelihood = center_it->mixing_coefficient * center_it->probability(
point_it->data); point_it->data);
@ -120,14 +120,14 @@ protected:
} }
/*Calculates total membership values for a point */ /*Calculates total membership values for a point */
void calculate_membership() { void calculate_membership() {
for(typename std::vector<Gaussian_point>::iterator point_it = points.begin(); for(std::vector<Gaussian_point>::iterator point_it = points.begin();
point_it != points.end(); ++point_it) { point_it != points.end(); ++point_it) {
point_it->calculate_total_membership(centers); point_it->calculate_total_membership(centers);
} }
} }
/*Calculates new parameter values for each cluster */ /*Calculates new parameter values for each cluster */
void calculate_parameters() { void calculate_parameters() {
for(typename std::vector<Gaussian_center>::iterator center_it = centers.begin(); for(std::vector<Gaussian_center>::iterator center_it = centers.begin();
center_it != centers.end(); ++center_it) { center_it != centers.end(); ++center_it) {
center_it->calculate_parameters(points); center_it->calculate_parameters(points);
} }
@ -135,10 +135,10 @@ protected:
/*Calculates how much this adjustment is likely to represent data*/ /*Calculates how much this adjustment is likely to represent data*/
double calculate_likelihood() { double calculate_likelihood() {
double likelihood = 0.0; double likelihood = 0.0;
for(typename std::vector<Gaussian_point>::iterator point_it = points.begin(); for(std::vector<Gaussian_point>::iterator point_it = points.begin();
point_it != points.end(); ++point_it) { point_it != points.end(); ++point_it) {
double point_likelihood = 0.0; double point_likelihood = 0.0;
for(typename std::vector<Gaussian_center>::iterator center_it = centers.begin(); for(std::vector<Gaussian_center>::iterator center_it = centers.begin();
center_it != centers.end(); ++center_it) { center_it != centers.end(); ++center_it) {
point_likelihood += center_it->mixing_coefficient * center_it->probability( point_likelihood += center_it->mixing_coefficient * center_it->probability(
point_it->data); point_it->data);