Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
        /// <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));
            }
        }