# Changeset 1725 for trunk/yat/utility/WeNNI.cc

Ignore:
Timestamp:
Jan 15, 2009, 5:57:36 PM (12 years ago)
Message:

Addresses #464. Weight zero will kill NaNs? and Infs.

File:
1 edited

Unmodified
Removed
• ## trunk/yat/utility/WeNNI.cc

 r1554 Copyright (C) 2006 Jari Häkkinen Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson Copyright (C) 2009 Jari Häkkinen This file is part of the yat library, http://dev.thep.lu.se/yat // \hat{x_{ij}}=\frac{ \sum_{k=1,N} \frac{w_{kj}*x_{kj}}{d_{ki}} } //                   { \sum_{k=1,N} \frac{w_{kj}       }{d_{ki}} } // Avoid division with zero (perfect match vectors) double d=(distance[*k].second ? distance[*k].second : small_number); new_value+=(weight_(distance[*k].first,j) * data_(distance[*k].first,j)/d); norm+=weight_(distance[*k].first,j)/d; double w=weight_(distance[*k].first,j)/d; if (w) { new_value += w*data_(distance[*k].first,j); norm      += w; } } // No impute if no contributions from neighbours. if (norm){ if (norm) { imputed_data_raw_(i,j) = new_value/norm; imputed_data_(i,j)= weight_(i,j)*data_(i,j) + (1-weight_(i,j))* imputed_data_raw_(i,j); double w=weight_(i,j); if (w) imputed_data_(i,j) = w*data_(i,j) + (1-w)*imputed_data_raw_(i,j); else imputed_data_(i,j) = imputed_data_raw_(i,j); } else
Note: See TracChangeset for help on using the changeset viewer.