Mercurial > hg > audiodb
changeset 53:944f05e65a58
Fix what is I think an off-by-one in query and sequence searching.
When taking the mean of the N minimum distances, only consider those
distances which are closer than the infinite/uninitialized distance.
(This renders us potentially vulnerable to an internal consistency
horror where we end up trying to divide by zero. This is unlikely to be
picked up by unit tests, but might well be by random tests if this is in
fact a problem.)
author | mas01cr |
---|---|
date | Thu, 20 Sep 2007 08:50:35 +0000 |
parents | b46c50dfd3ee |
children | f258a0258755 |
files | audioDB.cpp |
diffstat | 1 files changed, 6 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/audioDB.cpp Wed Sep 19 15:10:51 2007 +0000 +++ b/audioDB.cpp Thu Sep 20 08:50:35 2007 +0000 @@ -1770,8 +1770,8 @@ } // Search for minimum distance by shingles (concatenated vectors) - for(j=0;j<numVectors-wL;j+=HOP_SIZE) - for(k=0;k<trackTable[track]-wL;k+=HOP_SIZE){ + for(j=0;j<=numVectors-wL;j+=HOP_SIZE) + for(k=0;k<=trackTable[track]-wL;k+=HOP_SIZE){ thisDist=2-(2/(qNorm[j]*sNorm[trackIndexOffset+k]))*DD[j][k]; if(verbosity>10) cerr << thisDist << " " << qNorm[j] << " " << sNorm[trackIndexOffset+k] << endl; @@ -1820,9 +1820,11 @@ } // Calculate the mean of the N-Best matches thisDist=0.0; - for(m=0; m<pointNN; m++) + for(m=0; m<pointNN; m++) { + if (distances[m] == 1000000.0) break; thisDist+=distances[m]; - thisDist/=pointNN; + } + thisDist/=m; // Let's see the distances then... if(verbosity>3)