Changeset 1725 for trunk/yat/utility/WeNNI.cc
- Timestamp:
- Jan 15, 2009, 5:57:36 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/utility/WeNNI.cc
r1554 r1725 6 6 Copyright (C) 2006 Jari Häkkinen 7 7 Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson 8 Copyright (C) 2009 Jari Häkkinen 8 9 9 10 This file is part of the yat library, http://dev.thep.lu.se/yat … … 45 46 46 47 47 48 48 // \hat{x_{ij}}=\frac{ \sum_{k=1,N} \frac{w_{kj}*x_{kj}}{d_{ki}} } 49 49 // { \sum_{k=1,N} \frac{w_{kj} }{d_{ki}} } … … 66 66 // Avoid division with zero (perfect match vectors) 67 67 double d=(distance[*k].second ? distance[*k].second : small_number); 68 new_value+=(weight_(distance[*k].first,j) * 69 data_(distance[*k].first,j)/d); 70 norm+=weight_(distance[*k].first,j)/d; 68 double w=weight_(distance[*k].first,j)/d; 69 if (w) { 70 new_value += w*data_(distance[*k].first,j); 71 norm += w; 72 } 71 73 } 72 74 // No impute if no contributions from neighbours. 73 if (norm) {75 if (norm) { 74 76 imputed_data_raw_(i,j) = new_value/norm; 75 imputed_data_(i,j)= 76 weight_(i,j)*data_(i,j) + (1-weight_(i,j))* imputed_data_raw_(i,j); 77 double w=weight_(i,j); 78 if (w) 79 imputed_data_(i,j) = w*data_(i,j) + (1-w)*imputed_data_raw_(i,j); 80 else 81 imputed_data_(i,j) = imputed_data_raw_(i,j); 77 82 } 78 83 else
Note: See TracChangeset
for help on using the changeset viewer.