示例#1
0
        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));
        }
示例#2
0
 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));
 }
示例#3
0
 private static IEnumerable <T> BoundBySigmasIter <T>(this IEnumerable <T> ld, Func <T, double> transform, SigmaBoundingContext context)
 {
     return(ld.Where(item => context.IsValueInBounds(transform(item))));
 }
示例#4
0
 private static IEnumerable <double> BoundBySigmasIter(this IEnumerable <double> ld, SigmaBoundingContext context)
 {
     return(ld.Where(context.IsValueInBounds));
 }