当前位置: 首页>>代码示例>>C#>>正文


C# IEnumerable.Average方法代码示例

本文整理汇总了C#中IEnumerable.Average方法的典型用法代码示例。如果您正苦于以下问题:C# IEnumerable.Average方法的具体用法?C# IEnumerable.Average怎么用?C# IEnumerable.Average使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IEnumerable的用法示例。


在下文中一共展示了IEnumerable.Average方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AverangeCorrection

        private ProjectedAfrCorrection AverangeCorrection(IEnumerable<LogLine> lines, float targetAfr)
        {
            return new ProjectedAfrCorrection()
            {
                AfrDiffPercent = (float)lines.WeightedAverage(
                    l => (l.AfrWideband.Value / targetAfr) * 100 - 100,
                    l => l.ProximityIndex),
                //widebandDiffPercent.Average(),

                AfrDiffAbsolute = (float) lines.WeightedAverage(
                    l => targetAfr - l.AfrWideband.Value, 
                    l => l.ProximityIndex), //widebandDiffAbsolute.Average(),

                NboCorrection = (float) lines.WeightedAverage(
                    l => l.AfrCorrection.Value,
                    l => l.ProximityIndex
                ),

                Count = lines.Count(),

                AvgAfr = (float)lines.WeightedAverage(
                    l => l.AfrWideband.Value,
                    l => l.ProximityIndex
                ),
                AvgKpa = lines.Average(l => l.Map.Value),
                AvgRpm = (int)lines.Average(l => l.Rpm.Value)
            };
        }
开发者ID:strndy,项目名称:DET3-FIT-analyzer,代码行数:28,代码来源:AfrAnalyser.cs

示例2: AggregateMeasurements

 protected override Measurement AggregateMeasurements(IEnumerable<Measurement> measurements)
 {           
     return new Measurement
                {
                    X = (int)measurements.Average(m => m.X), 
                    Y = (int)measurements.Average(m => m.Y)
                };
 }
开发者ID:cwsquared,项目名称:Katas,代码行数:8,代码来源:AveragingAggregator.cs

示例3: Aggregate

 public Measurement Aggregate(IEnumerable<Measurement> measurements)
 {
     return new Measurement
                {
                    X = (int)measurements.Average(m => m.X),
                    Y = (int)measurements.Average(m => m.Y)
                };
 }
开发者ID:cwsquared,项目名称:Katas,代码行数:8,代码来源:AveragingStrategy.cs

示例4: SlopeOfPoints

        /// <summary>
        /// Gets the slope for a set of points using the formula:
        /// m = SUM(x-AVG(x)(y-AVG(y)) / SUM(x-AVG(x))^2
        /// </summary>
        /// <param name="points">Points to calculate the Slope from</param>
        /// <returns>SlopeOfPoints</returns>
        private static float SlopeOfPoints(IEnumerable<PointF> points)
        {
            float avgX = points.Average(p => p.X);
            float avgY = points.Average(p => p.Y);

            float dividend = points.Sum(p => (p.X - avgX) * (p.Y - avgY));
            float divisor = (float)points.Sum(p => Math.Pow(p.X - avgX, 2));

            return dividend / divisor;
        }
开发者ID:worstward,项目名称:rlviewer,代码行数:16,代码来源:LinearLeastSquares.cs

示例5: Aggregate

        public Measurement Aggregate(IEnumerable<Measurement> measurements)
        {
            if (measurements.Contains(null))
                throw new ArgumentNullException();

            return new Measurement()
            {
                HighValue = measurements.Average(m => m.HighValue),
                LowValue = measurements.Average(m => m.LowValue)
            };
        }
开发者ID:Malacola,项目名称:TestProjects,代码行数:11,代码来源:AveragingCalculator.cs

示例6: Covariance

 private static double Covariance(IEnumerable<double> xs, IEnumerable<double> ys)
 {
     var xAvg = xs.Average();
     var yAvg = ys.Average();
     var cov = xs.Zip(ys, (x, y) => (x - xAvg) * (y - yAvg)).Average();
     return cov;
 }
开发者ID:adamgoral,项目名称:infernethol,代码行数:7,代码来源:Program.cs

示例7: CalculateStatistics

        /// <summary>
        /// Calculates the statistics.
        /// </summary>
        /// <param name="benchmarks">The composite query benchmarks.</param>
        private static void CalculateStatistics(IEnumerable<BenchmarkBase> benchmarks)
        {
            if (null != benchmarks) {
                var avgSelect = benchmarks.Average(b => ((CompositeQueries)b).SimpleQuery.Time.ElapsedMilliseconds);
                Console.WriteLine("{0:0.0000} : Average simple select", avgSelect / 1000.0);

                var avgFilter = benchmarks.Average(b => ((CompositeQueries)b).FilterQuery.Time.ElapsedMilliseconds);
                Console.WriteLine("{0:0.0000} : Average simple filter", avgFilter / 1000.0);

                var avgMapReduceTags = benchmarks.Average(b => ((CompositeQueries)b).TagCountMapReduce.Time.ElapsedMilliseconds);
                Console.WriteLine("{0:0.0000} : Average Map-Reduce tags", avgMapReduceTags / 1000.0);

                var avgMapReduceComments = benchmarks.Average(b => ((CompositeQueries)b).CommentAuthorMapReduce.Time.ElapsedMilliseconds);
                Console.WriteLine("{0:0.0000} : Average Map-Reduce comments", avgMapReduceComments / 1000.0);
            }
        }
开发者ID:gaurangsinha,项目名称:MongoBench,代码行数:20,代码来源:Program.cs

示例8: FillInSusiInfo

        public void FillInSusiInfo(Student student, StudentInfo studentInfo, IEnumerable<CourseInfo> courseInfo)
        {
            student.FirstName = studentInfo.FirstName;
            student.LastName = studentInfo.LastName;

            Tuple<int, int> startEndYears = studentInfo.GetStartEndYear();
            Bachelor bachelor = new Bachelor
            {
                StartYear = startEndYears.Item1,
                EndYear = startEndYears.Item2,
                CurrentCourse = studentInfo.Year,
                Specialty = StudentManager.programmeMapping[studentInfo.Programme],
                Subjects = courseInfo.Select(x => x.ToSubject()).ToList(),
                CurrentAverageGrade = courseInfo.Average(x => x.Grade)
            };

            FMIEdu fmiEdu = new FMIEdu
            {
                Bachelor = bachelor,
            };

            student.FMIInfo = fmiEdu;

            db.SaveChanges();
        }
开发者ID:nikup,项目名称:occupie,代码行数:25,代码来源:StudentManager.cs

示例9: AverageBool

        private bool AverageBool(IEnumerable<bool> itemBools)
        {
            var avgBool = itemBools.Average(i => Convert.ToDouble(i));

            var isBool = Convert.ToBoolean(Round(avgBool));

            return isBool;
        }
开发者ID:ripa-alexandr,项目名称:weather,代码行数:8,代码来源:Calculator.cs

示例10: GetStandardDeviation

		private int GetStandardDeviation(IEnumerable<int> values)
		{
			var setAverage = values.Average();
			var diffSqTotal = values.Sum((val) => (val - setAverage) * (val - setAverage));
			var diffSqAvg = (diffSqTotal / (values.Count() - 1));

			return (int)Math.Sqrt(diffSqAvg);
		}
开发者ID:KroneckerX,项目名称:WCell,代码行数:8,代码来源:RealmStatsExtended.cs

示例11: Average

 public static FlowView Average(IEnumerable<FlowView> views)
 {
     if (views == null || !views.Any()) return null;
     var first = views.FirstOrDefault();
     return new FlowView
     {
         StatTime = first.StatTime,
         ENodebId = first.ENodebId,
         SectorId = first.SectorId,
         PdcpUplinkFlow = views.Average(x => x.PdcpUplinkFlow),
         PdcpDownlinkFlow = views.Average(x => x.PdcpDownlinkFlow),
         AverageUsers = views.Average(x => x.AverageUsers),
         MaxUsers = views.Max(x => x.MaxUsers),
         AverageActiveUsers = views.Average(x => x.AverageActiveUsers),
         MaxActiveUsers = views.Max(x => x.MaxActiveUsers)
     };
 }
开发者ID:ouyh18,项目名称:LtePlatform,代码行数:17,代码来源:FlowView.cs

示例12: calcStdDev

 static double calcStdDev(IEnumerable<double> values)
 {
     double ret = 0;
     double avg = values.Average();
     double sum = values.Sum(d => Math.Pow(d - avg, 2));
     ret = Math.Sqrt((sum) / (values.Count() - 1));
     return ret;
 }
开发者ID:RaiaN,项目名称:kohonen_som,代码行数:8,代码来源:Program.cs

示例13: GetRating

        /// <summary>
        /// Gets the average rating for the given players.
        /// These players are typically all players in a specific line.
        /// </summary>
        /// <param name="players"></param>
        /// <returns></returns>
        public static decimal GetRating(IEnumerable<Player> players)
        {
            //TODO per linie de rating uitrekenen door de primary en wellicht ook secondary skills te pakken ofzoiets...

             // Nu eerst gewoon de gemiddelde rating van elke speler pakken...
             var average = players.Average(player => player.Rating);
             return average;
        }
开发者ID:bouwe77,项目名称:fmg,代码行数:14,代码来源:TeamRater.cs

示例14: PerfIteratorResult

 public PerfIteratorResult(IEnumerable<PerfRoundResult> resultsList)
 {
     this.ResultsList = resultsList;
     this.RepeatCount = resultsList.Count();
     this.OverallAverageTicks = resultsList.Average(r => r.AverageTicks);
     this.OverallMaxTicks = resultsList.Max(r => r.MaxTicks);
     this.OverallMinTicks = resultsList.Min(r => r.MinTicks);
 }
开发者ID:LuanNunes,项目名称:MOO,代码行数:8,代码来源:PerfIteratorResult.cs

示例15: CalculatePricePerServing2

        public static decimal CalculatePricePerServing2(IEnumerable<Meal> meals)
        {
            if (meals == null || !meals.Any(p => p != null && p.Price != 0 && p.Servings != 0))
              {
            return -1;
              }

              return meals.Average(p => p.Servings / p.Price);
        }
开发者ID:GROSSWEBER,项目名称:pex-demo,代码行数:9,代码来源:Demo.cs


注:本文中的IEnumerable.Average方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。