コード例 #1
0
ファイル: Statistics.cs プロジェクト: redyjq/mathnet-numerics
        /// <summary>
        /// Evaluates the root mean square (RMS) also known as quadratic mean.
        /// Returns NaN if data is empty or if any entry is NaN.
        /// </summary>
        /// <param name="data">The data to calculate the RMS of.</param>
        public static double RootMeanSquare(this IEnumerable <double> data)
        {
            var array = data as double[];

            return(array != null
                ? ArrayStatistics.RootMeanSquare(array)
                : StreamingStatistics.RootMeanSquare(data));
        }
コード例 #2
0
ファイル: Statistics.cs プロジェクト: redyjq/mathnet-numerics
        /// <summary>
        /// Evaluates the harmonic mean.
        /// Returns NaN if data is empty or if any entry is NaN.
        /// </summary>
        /// <param name="data">The data to calculate the harmonic mean of.</param>
        /// <returns>The harmonic mean of the sample.</returns>
        public static double HarmonicMean(this IEnumerable <double> data)
        {
            var array = data as double[];

            return(array != null
                ? ArrayStatistics.HarmonicMean(array)
                : StreamingStatistics.HarmonicMean(data));
        }
コード例 #3
0
        /// <summary>
        /// Evaluates the population variance from the provided full population.
        /// 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="population">The full population data.</param>
        public static double PopulationVariance(this IEnumerable <double> population)
        {
            var array = population as double[];

            return(array != null
                ? ArrayStatistics.PopulationVariance(array)
                : StreamingStatistics.PopulationVariance(population));
        }
コード例 #4
0
 /// <summary>
 /// Returns the maximum value in the sample data.
 /// Returns NaN if data is empty or if any entry is NaN.
 /// Null-entries are ignored.
 /// </summary>
 /// <param name="data">The sample data.</param>
 /// <returns>The maximum value in the sample data.</returns>
 public static double Maximum(this IEnumerable <double?> data)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data");
     }
     return(StreamingStatistics.Maximum(data.Where(d => d.HasValue).Select(d => d.Value)));
 }
コード例 #5
0
 /// <summary>
 /// Estimates the unbiased population standard deviation from the provided samples.
 /// On a dataset of size N will use an N-1 normalizer (Bessel's correction).
 /// Returns NaN if data has less than two entries or if any entry is NaN.
 /// Null-entries are ignored.
 /// </summary>
 /// <param name="samples">A subset of samples, sampled from the full population.</param>
 public static double StandardDeviation(this IEnumerable <double?> samples)
 {
     if (samples == null)
     {
         throw new ArgumentNullException("samples");
     }
     return(StreamingStatistics.StandardDeviation(samples.Where(d => d.HasValue).Select(d => d.Value)));
 }
コード例 #6
0
        /// <summary>
        /// Estimates the sample mean and the unbiased population variance from the provided samples.
        /// On a dataset of size N will use an N-1 normalizer (Bessel's correction).
        /// Returns NaN for mean if data is empty or if any entry is NaN and NaN for variance if data has less than two entries or if any entry is NaN.
        /// </summary>
        /// <param name="data">The data to calculate the mean of.</param>
        /// <returns>The mean of the sample.</returns>
        public static Tuple <double, double> MeanVariance(this IEnumerable <double> data)
        {
            var array = data as double[];

            return(array != null
                ? ArrayStatistics.MeanVariance(array)
                : StreamingStatistics.MeanVariance(data));
        }
コード例 #7
0
        /// <summary>
        /// Estimates the sample mean and the unbiased population variance from the provided samples.
        /// On a dataset of size N will use an N-1 normalizer (Bessel's correction).
        /// Returns NaN for mean if data is empty or if any entry is NaN and NaN for variance if data has less than two entries or if any entry is NaN.
        /// </summary>
        /// <param name="samples">The data to calculate the mean of.</param>
        /// <returns>The mean of the sample.</returns>
        public static Tuple <double, double> MeanVariance(this IEnumerable <double> samples)
        {
            var array = samples as double[];

            return(array != null
                ? ArrayStatistics.MeanVariance(array)
                : StreamingStatistics.MeanVariance(samples));
        }
コード例 #8
0
        /// <summary>
        /// Estimates the unbiased population standard deviation from the provided samples.
        /// On a dataset of size N will use an N-1 normalizer (Bessel's correction).
        /// Returns NaN if data has less than two entries or if any entry is NaN.
        /// </summary>
        /// <param name="samples">A subset of samples, sampled from the full population.</param>
        public static double StandardDeviation(this IEnumerable <double> samples)
        {
            var array = samples as double[];

            return(array != null
                ? ArrayStatistics.StandardDeviation(array)
                : StreamingStatistics.StandardDeviation(samples));
        }
コード例 #9
0
 /// <summary>
 /// Evaluates the population standard deviation from the provided full population.
 /// 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.
 /// Null-entries are ignored.
 /// </summary>
 /// <param name="population">The full population data.</param>
 public static double PopulationStandardDeviation(this IEnumerable <double?> population)
 {
     if (population == null)
     {
         throw new ArgumentNullException("population");
     }
     return(StreamingStatistics.PopulationStandardDeviation(population.Where(d => d.HasValue).Select(d => d.Value)));
 }
コード例 #10
0
        /// <summary>
        /// Returns the maximum value in the sample data.
        /// Returns NaN if data is empty or if any entry is NaN.
        /// </summary>
        /// <param name="data">The sample data.</param>
        /// <returns>The maximum value in the sample data.</returns>
        public static double Maximum(this IEnumerable <double> data)
        {
            var array = data as double[];

            return(array != null
                ? ArrayStatistics.Maximum(array)
                : StreamingStatistics.Maximum(data));
        }
コード例 #11
0
        /// <summary>
        /// Evaluates the population standard deviation from the provided full population.
        /// 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="population">The full population data.</param>
        public static double PopulationStandardDeviation(this IEnumerable <double> population)
        {
            var array = population as double[];

            return(array != null
                ? ArrayStatistics.PopulationStandardDeviation(array)
                : StreamingStatistics.PopulationStandardDeviation(population));
        }
コード例 #12
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));
        }
コード例 #13
0
        /// <summary>
        /// Estimates the unbiased population covariance from the provided samples.
        /// On a dataset of size N will use an N-1 normalizer (Bessel's correction).
        /// Returns NaN if data has less than two entries or if any entry is NaN.
        /// </summary>
        /// <param name="samples1">A subset of samples, sampled from the full population.</param>
        /// <param name="samples2">A subset of samples, sampled from the full population.</param>
        public static double Covariance(this IEnumerable <double> samples1, IEnumerable <double> samples2)
        {
            var array1 = samples1 as double[];
            var array2 = samples2 as double[];

            return(array1 != null && array2 != null
                ? ArrayStatistics.Covariance(array1, array2)
                : StreamingStatistics.Covariance(samples1, samples2));
        }
コード例 #14
0
 /// <summary>
 /// Evaluates the population covariance from the provided full populations.
 /// On a dataset of size N will use an N normalize and would thus be biased if applied to a subsetr.
 /// Returns NaN if data is empty or if any entry is NaN.
 /// Null-entries are ignored.
 /// </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)
 {
     if (population1 == null)
     {
         throw new ArgumentNullException("population1");
     }
     if (population2 == null)
     {
         throw new ArgumentNullException("population2");
     }
     return(StreamingStatistics.PopulationCovariance(population1.Where(d => d.HasValue).Select(d => d.Value), population2.Where(d => d.HasValue).Select(d => d.Value)));
 }
コード例 #15
0
 /// <summary>
 /// Estimates the unbiased population covariance from the provided samples.
 /// On a dataset of size N will use an N-1 normalizer (Bessel's correction).
 /// Returns NaN if data has less than two entries or if any entry is NaN.
 /// Null-entries are ignored.
 /// </summary>
 /// <param name="samples1">A subset of samples, sampled from the full population.</param>
 /// <param name="samples2">A subset of samples, sampled from the full population.</param>
 public static double Covariance(this IEnumerable <double?> samples1, IEnumerable <double?> samples2)
 {
     if (samples1 == null)
     {
         throw new ArgumentNullException("samples1");
     }
     if (samples2 == null)
     {
         throw new ArgumentNullException("samples2");
     }
     return(StreamingStatistics.Covariance(samples1.Where(d => d.HasValue).Select(d => d.Value), samples2.Where(d => d.HasValue).Select(d => d.Value)));
 }
コード例 #16
0
 /// <summary>
 /// Estimates the unbiased population standard deviation from the provided samples.
 /// On a dataset of size N will use an N-1 normalizer (Bessel's correction).
 /// Returns NaN if data has less than two entries or if any entry is NaN.
 /// Null-entries are ignored.
 /// </summary>
 /// <param name="samples">A subset of samples, sampled from the full population.</param>
 public static double StandardDeviation(this IEnumerable <double?> samples)
 {
     return(StreamingStatistics.StandardDeviation(samples.Where(d => d.HasValue).Select(d => d.Value)));
 }
コード例 #17
0
ファイル: Statistics.cs プロジェクト: redyjq/mathnet-numerics
 /// <summary>
 /// Calculates the entropy of a stream of double values in bits.
 /// Returns NaN if any of the values in the stream are NaN.
 /// </summary>
 /// <param name="data">The data sample sequence.</param>
 public static double Entropy(IEnumerable <double> data)
 {
     return(StreamingStatistics.Entropy(data));
 }
コード例 #18
0
ファイル: Statistics.cs プロジェクト: redyjq/mathnet-numerics
 /// <summary>
 /// Calculates the entropy of a stream of double values in bits.
 /// Returns NaN if any of the values in the stream are NaN.
 /// Null-entries are ignored.
 /// </summary>
 /// <param name="data">The data sample sequence.</param>
 public static double Entropy(IEnumerable <double?> data)
 {
     return(StreamingStatistics.Entropy(data.Where(d => d.HasValue).Select(d => d.Value)));
 }
コード例 #19
0
 /// <summary>
 /// Returns the maximum value in the sample data.
 /// Returns NaN if data is empty or if any entry is NaN.
 /// Null-entries are ignored.
 /// </summary>
 /// <param name="data">The sample data.</param>
 /// <returns>The maximum value in the sample data.</returns>
 public static double Maximum(this IEnumerable <double?> data)
 {
     return(StreamingStatistics.Maximum(data.Where(d => d.HasValue).Select(d => d.Value)));
 }
コード例 #20
0
 /// <summary>
 /// Evaluates the population covariance from the provided full populations.
 /// On a dataset of size N will use an N normalize and would thus be biased if applied to a subsetr.
 /// Returns NaN if data is empty or if any entry is NaN.
 /// Null-entries are ignored.
 /// </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)
 {
     return(StreamingStatistics.PopulationCovariance(population1.Where(d => d.HasValue).Select(d => d.Value), population2.Where(d => d.HasValue).Select(d => d.Value)));
 }
コード例 #21
0
 /// <summary>
 /// Estimates the unbiased population covariance from the provided samples.
 /// On a dataset of size N will use an N-1 normalizer (Bessel's correction).
 /// Returns NaN if data has less than two entries or if any entry is NaN.
 /// Null-entries are ignored.
 /// </summary>
 /// <param name="samples1">A subset of samples, sampled from the full population.</param>
 /// <param name="samples2">A subset of samples, sampled from the full population.</param>
 public static double Covariance(this IEnumerable <double?> samples1, IEnumerable <double?> samples2)
 {
     return(StreamingStatistics.Covariance(samples1.Where(d => d.HasValue).Select(d => d.Value), samples2.Where(d => d.HasValue).Select(d => d.Value)));
 }
コード例 #22
0
 /// <summary>
 /// Evaluates the population standard deviation from the provided full population.
 /// 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.
 /// Null-entries are ignored.
 /// </summary>
 /// <param name="population">The full population data.</param>
 public static double PopulationStandardDeviation(this IEnumerable <double?> population)
 {
     return(StreamingStatistics.PopulationStandardDeviation(population.Where(d => d.HasValue).Select(d => d.Value)));
 }
コード例 #23
0
ファイル: Statistics.cs プロジェクト: redyjq/mathnet-numerics
 /// <summary>
 /// Evaluates the root mean square (RMS) also known as quadratic mean.
 /// Returns NaN if data is empty or if any entry is NaN.
 /// Null-entries are ignored.
 /// </summary>
 /// <param name="data">The data to calculate the mean of.</param>
 public static double RootMeanSquare(this IEnumerable <double?> data)
 {
     return(StreamingStatistics.RootMeanSquare(data.Where(d => d.HasValue).Select(d => d.Value)));
 }
コード例 #24
0
 /// <summary>
 /// Estimates the unbiased population variance from the provided samples.
 /// On a dataset of size N will use an N-1 normalizer (Bessel's correction).
 /// Returns NaN if data has less than two entries or if any entry is NaN.
 /// Null-entries are ignored.
 /// </summary>
 /// <param name="samples">A subset of samples, sampled from the full population.</param>
 public static double Variance(this IEnumerable <double?> samples)
 {
     return(StreamingStatistics.Variance(samples.Where(d => d.HasValue).Select(d => d.Value)));
 }