lib/bray-curtis.js
/**
 * given an index, calculate the similarity of that vector to the other vectors
 * this should return an array of objects with a similarity score and the vector
 */
given an index, calculate the similarity of that vector to the other vectors
this should return an array of objects with a similarity score and the vector
given an index calculate the similarity of that vector to the other vectors this should return an array of objects with a similarity score and the vector
function calculateSimilarities(vectors, currentVectorIndex) {
  debug('calculateSimilarities for vector: %d', currentVectorIndex);
  var vectorNeighbors = [];
  var diss;
  for (var i = 0; i < vectors.length; i++) {
    vectorNeighbors.push({
      d: calculateSimilarityBetweenVectors.call(this, vectors, currentVectorIndex, i),
      vector: vectors[i]
    });
  }
  debug('sorting results for vector: %d', currentVectorIndex);
  vectorNeighbors = _.sortBy(vectorNeighbors, 'd').reverse();
  debug('sorted results for vector: %d', currentVectorIndex);
  return vectorNeighbors;
}
function calculateSimilarities ( vectors , currentVectorIndex ) { debug ( 'calculateSimilarities for vector: %d' , currentVectorIndex ) ; var vectorNeighbors = [ ] ; var diss ; for ( var i = 0 ; i < vectors . length ; i ++ ) { vectorNeighbors . push ( { d : calculateSimilarityBetweenVectors . call ( this , vectors , currentVectorIndex , i ) , vector : vectors [ i ] } ) ; } debug ( 'sorting results for vector: %d' , currentVectorIndex ) ; vectorNeighbors = _ . sortBy ( vectorNeighbors , 'd' ) . reverse ( ) ; debug ( 'sorted results for vector: %d' , currentVectorIndex ) ; return vectorNeighbors ; }
given an index, calculate the similarity of that vector to the other vectors
 this should return an array of objects with a similarity score and the vector
given an index calculate the similarity of that vector to the other vectors this should return an array of objects with a similarity score and the vector
// calculate the similarity between the two vectors // sort the vectorNeighbors by the d value, in desc order (higher numbers being more similar)