mirror of https://github.com/CGAL/cgal
reversing changes.
This commit is contained in:
parent
e96059b6f9
commit
1a97c50d10
|
|
@ -42,7 +42,7 @@ public:
|
|||
}
|
||||
void calculate_total_membership(const std::vector<Gaussian_center>& centers) {
|
||||
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) {
|
||||
total_membership += it->probability(data) * it->mixing_coefficient;
|
||||
}
|
||||
|
|
@ -54,7 +54,7 @@ inline void Gaussian_center::calculate_parameters(const
|
|||
{
|
||||
/* Calculate new mean */
|
||||
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) {
|
||||
double membership = (probability(it->data) * mixing_coefficient) /
|
||||
it->total_membership;
|
||||
|
|
@ -64,7 +64,7 @@ inline void Gaussian_center::calculate_parameters(const
|
|||
new_mean /= total_membership;
|
||||
/* Calculate new deviation */
|
||||
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) {
|
||||
double membership = (probability(it->data) * mixing_coefficient) /
|
||||
it->total_membership;
|
||||
|
|
@ -91,11 +91,11 @@ public:
|
|||
calculate_fitting();
|
||||
}
|
||||
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) {
|
||||
double max_likelihood = 0.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++) {
|
||||
double likelihood = center_it->mixing_coefficient * center_it->probability(
|
||||
point_it->data);
|
||||
|
|
@ -120,14 +120,14 @@ protected:
|
|||
}
|
||||
/*Calculates total membership values for a point */
|
||||
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->calculate_total_membership(centers);
|
||||
}
|
||||
}
|
||||
/*Calculates new parameter values for each cluster */
|
||||
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->calculate_parameters(points);
|
||||
}
|
||||
|
|
@ -135,10 +135,10 @@ protected:
|
|||
/*Calculates how much this adjustment is likely to represent data*/
|
||||
double calculate_likelihood() {
|
||||
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) {
|
||||
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) {
|
||||
point_likelihood += center_it->mixing_coefficient * center_it->probability(
|
||||
point_it->data);
|
||||
|
|
|
|||
Loading…
Reference in New Issue