Ejemplo n.º 1
0
        /// <summary>
        /// Returns distance between two N-dimensional double vectors.
        /// </summary>
        /// 
        /// <param name="p">1st point vector.</param>
        /// <param name="q">2nd point vector.</param>
        /// 
        /// <returns>Returns Cosine distance between two supplied vectors.</returns>
        /// 
        /// <exception cref="ArgumentException">Thrown if the two vectors are of different dimensions (if specified
        /// array have different length).</exception>
        /// 
        public double GetDistance( double[] p, double[] q )
        {
            double distance;

            CosineSimilarity dist = new CosineSimilarity( );
            distance = (double) 1 - dist.GetSimilarityScore( p, q );

            return distance;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns distance between two N-dimensional double vectors.
        /// </summary>
        ///
        /// <param name="p">1st point vector.</param>
        /// <param name="q">2nd point vector.</param>
        ///
        /// <returns>Returns Cosine distance between two supplied vectors.</returns>
        ///
        /// <exception cref="ArgumentException">Thrown if the two vectors are of different dimensions (if specified
        /// array have different length).</exception>
        ///
        public double GetDistance(double[] p, double[] q)
        {
            double distance;

            CosineSimilarity dist = new CosineSimilarity( );

            distance = (double)1 - dist.GetSimilarityScore(p, q);

            return(distance);
        }