ilarinieminen / SOM-Toolbox

GNU General Public License v2.0
119 stars 56 forks source link

Floating point problem in som_seqtrain #13

Closed meyerjo closed 8 years ago

meyerjo commented 8 years ago

Hi, today I encountered a floating point problem in the som_seqtrain function. The if condition in line 407 was evaluated to true, but should be false.

I fixed the problem by using the proposed float-comparison method http://www.mathworks.com/matlabcentral/answers/97069-how-can-i-compare-numbers-for-equality-within-a-tolerance-in-matlab-8-0-r2012b

Replaced if length(alpha) ~= trainlen with if ~(abs(length(alpha)-trainlen) < 1e4*eps(min(abs(length(alpha)),abs(trainlen))))

Encountered the problem with Matlab R2014a (Win10) and R2015b. Demo data and a script which causes the problem are attached.

example_error_som_seqtrain.zip

tvatanen commented 8 years ago

Hi Johannes,

If you want to incorporate your code to the toolbox, can you please create a pull request on this bug fix.

thanks a lot!