コード例 #1
0
        /// <summary>
        /// Estimates the empirical inverse CDF at tau from the provided samples.
        /// </summary>
        /// <param name="data">The data sample sequence.</param>
        public static Func <double, double> EmpiricalInvCDFFunc(this IEnumerable <double> data)
        {
            var array = data.ToArray();

            Array.Sort(array);
            return(tau => SortedArrayStatistics.QuantileCustom(array, tau, QuantileDefinition.EmpiricalInvCDF));
        }
コード例 #2
0
        /// <summary>
        /// Estimates the empirical cummulative distribution function (CDF) at x from the provided samples.
        /// </summary>
        /// <param name="data">The data sample sequence.</param>
        /// <param name="x">The value where to estimate the CDF at.</param>
        public static double EmpiricalCDF(this IEnumerable <double> data, double x)
        {
            var array = data.ToArray();

            Array.Sort(array);
            return(SortedArrayStatistics.EmpiricalCDF(array, x));
        }
コード例 #3
0
        /// <summary>
        /// Estimates the empirical cummulative distribution function (CDF) at x from the provided samples.
        /// </summary>
        /// <param name="data">The data sample sequence.</param>
        public static Func <double, double> EmpiricalCDFFunc(this IEnumerable <double> data)
        {
            var array = data.ToArray();

            Array.Sort(array);
            return(x => SortedArrayStatistics.EmpiricalCDF(array, x));
        }
コード例 #4
0
        /// <summary>
        /// Returns the order statistic (order 1..N) from the provided samples.
        /// </summary>
        /// <param name="data">The data sample sequence.</param>
        public static Func <int, double> OrderStatisticFunc(IEnumerable <double> data)
        {
            var array = data.ToArray();

            Array.Sort(array);
            return(order => SortedArrayStatistics.OrderStatistic(array, order));
        }
コード例 #5
0
        /// <summary>
        /// Estimates the tau-th quantile from the provided samples.
        /// The tau-th quantile is the data value where the cumulative distribution
        /// function crosses tau.
        /// Approximately median-unbiased regardless of the sample distribution (R8).
        /// </summary>
        /// <param name="data">The data sample sequence.</param>
        public static Func <double, double> QuantileFunc(this IEnumerable <double> data)
        {
            var array = data.ToArray();

            Array.Sort(array);
            return(tau => SortedArrayStatistics.Quantile(array, tau));
        }
コード例 #6
0
        /// <summary>
        /// Estimates the p-Percentile value from the provided samples.
        /// If a non-integer Percentile is needed, use Quantile instead.
        /// Approximately median-unbiased regardless of the sample distribution (R8).
        /// </summary>
        /// <param name="data">The data sample sequence.</param>
        public static Func <int, double> PercentileFunc(this IEnumerable <double> data)
        {
            var array = data.ToArray();

            Array.Sort(array);
            return(p => SortedArrayStatistics.Percentile(array, p));
        }
コード例 #7
0
        /// <summary>
        /// Estimates the p-Percentile value from the provided samples.
        /// If a non-integer Percentile is needed, use Quantile instead.
        /// Approximately median-unbiased regardless of the sample distribution (R8).
        /// </summary>
        /// <param name="data">The data sample sequence.</param>
        public static Func <int, double> PercentileFunc(this IEnumerable <double?> data)
        {
            var array = data.Where(d => d.HasValue).Select(d => d.Value).ToArray();

            Array.Sort(array);
            return(p => SortedArrayStatistics.Percentile(array, p));
        }
コード例 #8
0
        /// <summary>
        /// Estimates the tau-th quantile from the provided samples.
        /// The tau-th quantile is the data value where the cumulative distribution
        /// function crosses tau. The quantile definition can be specificed to be compatible
        /// with an existing system.
        /// </summary>
        /// <param name="data">The data sample sequence.</param>
        /// <param name="definition">Quantile definition, to choose what product/definition it should be consistent with</param>
        public static Func <double, double> QuantileCustomFunc(this IEnumerable <double?> data, QuantileDefinition definition)
        {
            var array = data.Where(d => d.HasValue).Select(d => d.Value).ToArray();

            Array.Sort(array);
            return(tau => SortedArrayStatistics.QuantileCustom(array, tau, definition));
        }
コード例 #9
0
        /// <summary>
        /// Estimates the tau-th quantile from the provided samples.
        /// The tau-th quantile is the data value where the cumulative distribution
        /// function crosses tau. The quantile definition can be specificed to be compatible
        /// with an existing system.
        /// </summary>
        /// <param name="data">The data sample sequence.</param>
        /// <param name="definition">Quantile definition, to choose what product/definition it should be consistent with</param>
        public static Func <double, double> QuantileCustomFunc(this IEnumerable <double> data, QuantileDefinition definition)
        {
            var array = data.ToArray();

            Array.Sort(array);
            return(tau => SortedArrayStatistics.QuantileCustom(array, tau, definition));
        }
コード例 #10
0
        /// <summary>
        /// Estimates the tau-th quantile from the provided samples.
        /// The tau-th quantile is the data value where the cumulative distribution
        /// function crosses tau.
        /// Approximately median-unbiased regardless of the sample distribution (R8).
        /// </summary>
        /// <param name="data">The data sample sequence.</param>
        public static Func <double, double> QuantileFunc(this IEnumerable <double?> data)
        {
            var array = data.Where(d => d.HasValue).Select(d => d.Value).ToArray();

            Array.Sort(array);
            return(tau => SortedArrayStatistics.Quantile(array, tau));
        }
コード例 #11
0
        /// <summary>
        /// Estimates the quantile tau from the provided samples.
        /// The tau-th quantile is the data value where the cumulative distribution
        /// function crosses tau. The quantile definition can be specificed to be compatible
        /// with an existing system.
        /// </summary>
        /// <param name="data">The data sample sequence.</param>
        /// <param name="definition">Rank definition, to choose how ties should be handled and what product/definition it should be consistent with</param>
        public static Func <double, double> QuantileRankFunc(this IEnumerable <double> data, RankDefinition definition = RankDefinition.Default)
        {
            var array = data.ToArray();

            Array.Sort(array);
            return(x => SortedArrayStatistics.QuantileRank(array, x, definition));
        }
コード例 #12
0
        /// <summary>
        /// stimates the tau-th quantile from the provided samples.
        /// The tau-th quantile is the data value where the cumulative distribution
        /// function crosses tau. The quantile definition can be specificed to be compatible
        /// with an existing system.
        /// </summary>
        /// <param name="data">The data sample sequence.</param>
        /// <param name="definition">Quantile definition, to choose what product/definition it should be consistent with</param>
        public static Func <double, double> QuantileCustomFunc(this IEnumerable <double?> data, QuantileDefinition definition)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }
            var array = data.Where(d => d.HasValue).Select(d => d.Value).ToArray();

            Array.Sort(array);
            return(tau => SortedArrayStatistics.QuantileCustom(array, tau, definition));
        }
コード例 #13
0
        /// <summary>
        /// Estimates the empirical inverse CDF at tau from the provided samples.
        /// </summary>
        /// <param name="data">The data sample sequence.</param>
        public static Func <double, double> InverseCDFFunc(this IEnumerable <double> data)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }
            var array = data.ToArray();

            Array.Sort(array);
            return(tau => SortedArrayStatistics.QuantileCustom(array, tau, QuantileDefinition.InverseCDF));
        }
コード例 #14
0
        /// <summary>
        /// Estimates the tau-th quantile from the provided samples.
        /// The tau-th quantile is the data value where the cumulative distribution
        /// function crosses tau.
        /// Approximately median-unbiased regardless of the sample distribution (R8).
        /// </summary>
        /// <param name="data">The data sample sequence.</param>
        public static Func <double, double> QuantileFunc(this IEnumerable <double> data)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }
            var array = data.ToArray();

            Array.Sort(array);
            return(tau => SortedArrayStatistics.Quantile(array, tau));
        }
コード例 #15
0
        /// <summary>
        /// Estimates the p-Percentile value from the provided samples.
        /// If a non-integer Percentile is needed, use Quantile instead.
        /// Approximately median-unbiased regardless of the sample distribution (R8).
        /// </summary>
        /// <param name="data">The data sample sequence.</param>
        public static Func <int, double> PercentileFunc(this IEnumerable <double?> data)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }
            var array = data.Where(d => d.HasValue).Select(d => d.Value).ToArray();

            Array.Sort(array);
            return(p => SortedArrayStatistics.Percentile(array, p));
        }
コード例 #16
0
        /// <summary>
        /// Returns the order statistic (order 1..N) from the provided samples.
        /// </summary>
        /// <param name="data">The data sample sequence.</param>
        public static Func <int, double> OrderStatisticFunc(IEnumerable <double> data)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }
            var array = data.ToArray();

            Array.Sort(array);
            return(order => SortedArrayStatistics.OrderStatistic(array, order));
        }
コード例 #17
0
        /// <summary>
        /// Computes the percentile.
        /// </summary>
        /// <param name="percentile">The percentile, must be between 0.0 and 1.0 (inclusive).</param>
        /// <returns>the requested percentile.</returns>
        public double Compute(double percentile)
        {
            switch (Method)
            {
            case PercentileMethod.Nist:
                return(SortedArrayStatistics.QuantileCustom(_data, percentile, QuantileDefinition.Nist));

            case PercentileMethod.Nearest:
                return(SortedArrayStatistics.QuantileCustom(_data, percentile, QuantileDefinition.R3));

            case PercentileMethod.Interpolation:
                return(SortedArrayStatistics.QuantileCustom(_data, percentile, QuantileDefinition.R5));

            case PercentileMethod.Excel:
                return(SortedArrayStatistics.QuantileCustom(_data, percentile, QuantileDefinition.Excel));

            default:
                return(SortedArrayStatistics.Quantile(_data, percentile));
            }
        }