예제 #1
0
        /// <summary>
        /// Calculates the variance of a set of complex values.
        /// </summary>
        /// <param name="Values">Values</param>
        /// <param name="Node">Node performing the evaluation.</param>
        /// <returns>Variance.</returns>
        public static Complex CalcVariance(Complex[] Values, ScriptNode Node)
        {
            Complex Avg    = Average.CalcAverage(Values, Node);
            Complex Result = 0;
            Complex d;
            int     i, c = Values.Length;

            for (i = 0; i < c; i++)
            {
                d       = (Values[i] - Avg);
                Result += d * d;
            }

            Result /= c;

            return(Result);
        }
예제 #2
0
        /// <summary>
        /// Calculates the variance of a set of double values.
        /// </summary>
        /// <param name="Values">Values</param>
        /// <param name="Node">Node performing the evaluation.</param>
        /// <returns>Variance.</returns>
        public static double CalcVariance(double[] Values, ScriptNode Node)
        {
            double Avg    = Average.CalcAverage(Values, Node);
            double Result = 0;
            double d;
            int    i, c = Values.Length;

            for (i = 0; i < c; i++)
            {
                d       = (Values[i] - Avg);
                Result += d * d;
            }

            Result /= c;

            return(Result);
        }
예제 #3
0
        /// <summary>
        /// Calculates the standard deviation of a set of double values.
        /// </summary>
        /// <param name="Values">Values</param>
        /// <param name="Node">Node performing the evaluation.</param>
        /// <returns>Standard deviation.</returns>
        public static double CalcStandardDeviation(double[] Values, ScriptNode Node)
        {
            double Avg    = Average.CalcAverage(Values, Node);
            double Result = 0;
            double d;
            int    i, c = Values.Length;

            if (c == 1)
            {
                return(0);
            }

            for (i = 0; i < c; i++)
            {
                d       = (Values[i] - Avg);
                Result += d * d;
            }

            Result /= (c - 1);

            return(Math.Sqrt(Result));
        }
예제 #4
0
        /// <summary>
        /// Calculates the standard deviation of a set of complex values.
        /// </summary>
        /// <param name="Values">Values</param>
        /// <param name="Node">Node performing the evaluation.</param>
        /// <returns>Standard deviation.</returns>
        public static Complex CalcStandardDeviation(Complex[] Values, ScriptNode Node)
        {
            Complex Avg    = Average.CalcAverage(Values, Node);
            Complex Result = 0;
            Complex d;
            int     i, c = Values.Length;

            if (c == 1)
            {
                return(Complex.Zero);
            }

            for (i = 0; i < c; i++)
            {
                d       = (Values[i] - Avg);
                Result += d * d;
            }

            Result /= (c - 1);

            return(Complex.Sqrt(Result));
        }