Accord.Statistics.Circular.Distance C# (CSharp) Method

Distance() public static method

Computes the angular distance between two angles.
public static Distance ( double x, double y ) : double
x double The first angle.
y double The second angle.
return double
        public static double Distance(double x, double y)
        {
            return Distance(Math.Cos(x), Math.Sin(x), Math.Cos(y), Math.Sin(y));
        }

Same methods

Circular::Distance ( double x, double y, double length ) : double
Circular::Distance ( double cosx, double sinx, double cosy, double siny ) : double

Usage Example

Exemplo n.º 1
0
        /// <summary>
        ///   Computes the circular kurtosis of the given circular angles.
        /// </summary>
        ///
        /// <param name="angles">A double array containing the angles in radians.</param>
        ///
        /// <returns>The circular kurtosis for the given <paramref name="angles"/>.</returns>
        ///
        public static double Kurtosis(double[] angles)
        {
            // Compute mean direction
            double theta = Circular.Mean(angles);

            // Compute central moments
            double rho2 = CentralMoments(angles, 2).Magnitude;
            double mu2  = NoncentralMoments(angles, 2).Phase;

            // compute skewness
            double k = 0;

            for (int i = 0; i < angles.Length; i++) // Pewsey, Metrika, 2004
            {
                k += Math.Cos(2 * Circular.Distance(angles[i], theta));
            }
            k /= angles.Length;

            /*
             * double k0 = 0;
             * double R4 = (R * R * R * R);
             * double omR2 = (1 - R) * (1 - R);
             * for (int i = 0; i < angles.Length; i++) // Fisher, Circular Statistics, p. 34
             *  k0 += (rho2 * Math.Cos(Circular.Distance(mu2, 2 * theta)) - R4) / omR2; // (formula 2.30)
             */

            return(k);
        }