Esempio n. 1
0
        /// <summary>
        /// Evaluates the population covariance from the provided full populations.
        /// On a dataset of size N will use an N normalizer and would thus be biased if applied to a subset.
        /// Returns NaN if data is empty or if any entry is NaN.
        /// </summary>
        /// <param name="population1">The full population data.</param>
        /// <param name="population2">The full population data.</param>
        public static double PopulationCovariance(this IEnumerable <double> population1, IEnumerable <double> population2)
        {
            var array1 = population1 as double[];
            var array2 = population2 as double[];

            return(array1 != null && array2 != null
                ? ArrayStatistics.PopulationCovariance(array1, array2)
                : StreamingStatistics.PopulationCovariance(population1, population2));
        }