/// <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> /// <param name="tau">Quantile selector, between 0.0 and 1.0 (inclusive).</param> public static double Quantile(this IEnumerable <double?> data, double tau) { if (data == null) { throw new ArgumentNullException("data"); } var array = data.Where(d => d.HasValue).Select(d => d.Value).ToArray(); return(ArrayStatistics.QuantileInplace(array, tau)); }
/// <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> /// <param name="tau">Quantile selector, between 0.0 and 1.0 (inclusive).</param> public static double Quantile(this IEnumerable <double?> data, double tau) { var array = data.Where(d => d.HasValue).Select(d => d.Value).ToArray(); return(ArrayStatistics.QuantileInplace(array, tau)); }
/// <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> /// <param name="tau">Quantile selector, between 0.0 and 1.0 (inclusive).</param> public static double Quantile(this IEnumerable <double> data, double tau) { var array = data.ToArray(); return(ArrayStatistics.QuantileInplace(array, tau)); }