/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); } }