public static IEnumerable <T> BoundBySigmas <T>(this IEnumerable <T> ld, Func <T, double> transform, double minBound, double maxBound) { double mean = ld.Average(transform); double stdev = ld.StandardDeviation(transform); SigmaBoundingContext context = new SigmaBoundingContext { Mean = mean, StdDev = stdev, MinBound = minBound, MaxBound = maxBound }; return(BoundBySigmasIter(ld, transform, context)); }
public static IEnumerable <double> BoundBySigmas(this IEnumerable <double> ld, double minBound, double maxBound, ref object context) { if (!ld.Any()) { return(ld); } if (context == null) { double mean = ld.Average(); double stdev = ld.StandardDeviation(); context = new SigmaBoundingContext { Mean = mean, StdDev = stdev, MinBound = minBound, MaxBound = maxBound }; } return(BoundBySigmasIter(ld, (SigmaBoundingContext)context)); }
private static IEnumerable <T> BoundBySigmasIter <T>(this IEnumerable <T> ld, Func <T, double> transform, SigmaBoundingContext context) { return(ld.Where(item => context.IsValueInBounds(transform(item)))); }
private static IEnumerable <double> BoundBySigmasIter(this IEnumerable <double> ld, SigmaBoundingContext context) { return(ld.Where(context.IsValueInBounds)); }