Changeset 174
Legend:
 Unmodified
 Added
 Removed

trunk/src/WeNNI.cc
r172 r174 37 37 double norm=0.0; 38 38 for (vector<u_int>::const_iterator k=knn.begin(); k!=knn.end(); k++) { 39 new_value+=1.0*data_(distance[*k].first,j)/(distance[*k].second); 40 norm+=1.0/(distance[*k].second); 39 // Jari, a small number needed here, use something standardized. 40 // Avoid division with zero (perfect match vectors) 41 double d=(distance[*k].second ? distance[*k].second : 1e10); 42 new_value+=1.0*data_(distance[*k].first,j)/d; 43 norm+=1.0/d; 41 44 } 42 45 // No impute if no contributions from neighbours. 
trunk/src/kNNI.cc
r172 r174 44 44 double norm=0.0; 45 45 for (vector<u_int>::const_iterator k=knn.begin(); k!=knn.end(); k++) { 46 new_value+=data_(distance[*k].first,j)/(distance[*k].second); 47 norm+=1.0/(distance[*k].second); 46 // Jari, a small number needed here, use something standardized. 47 // Avoid division with zero (perfect match vectors) 48 double d=(distance[*k].second ? distance[*k].second : 1e10); 49 new_value+=data_(distance[*k].first,j)/d; 50 norm+=1.0/d; 48 51 } 49 52 // No impute if no contributions from neighbours.
Note: See TracChangeset
for help on using the changeset viewer.