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


C# IList.Average方法代码示例

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


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

示例1: Calculate

      public async Task<IssuesCollectionStatistics> Calculate(IList<JiraIssue> issues)
      {
         if(issues == null || issues.Any() == false)
            return null;

         return await Task.Factory.StartNew(() =>
         {
            return new IssuesCollectionStatistics
            {
               IssuesCount = issues.Count(),
               ResolvedIssuesCount = issues.Where(i => i.Resolved.HasValue).Count(),
               UnresolvedIssuesCount = issues.Where(i => i.Resolved.HasValue == false).Count(),

               AverageResolutionTimeHours = issues
                                               .Where(i => i.Resolved.HasValue)
                                               .Select(i => (i.Resolved.Value - i.Created).TotalHours).Average(),
               MaxResolutionTimeHours = issues
                                               .Where(i => i.Resolved.HasValue)
                                               .Select(i => (i.Resolved.Value - i.Created).TotalHours).Max(),

               TotalStorypoints = issues.Sum(i => i.StoryPoints),
               AverageStorypointsPerTask = issues.Average(i => i.StoryPoints),

               AverageSubtasksCount = issues.Average(i => i.Subtasks),

               EpicsInvolved = issues.Select(i => i.EpicLink).Distinct().Count(),

               DistinctReporters = issues.Select(i => i.Reporter).Distinct().Count()
            };
         });
      }
开发者ID:sceeter89,项目名称:jira-client,代码行数:31,代码来源:IssuesStatisticsCalculator.cs

示例2: Calculate

        public RiskProfile Calculate(Bet bet, IList<Bet> settledBets)
        {
            if (settledBets.Count == 0)
            {
                return Constants.SAFE_PROFILE;
            }

            var avergaStake = settledBets.Average(bets => bets.Stake);

            if (bet.Stake > (avergaStake * Constants.EXCEPTIONALLY_RISKY_STAKE_FACTOR))
            {
                return new RiskProfile
                {
                    Risk = Risk.HighlyRisky,
                    Reason = "Stake is exceptionally large based on betting history."
                };
            }

            if (bet.Stake > (avergaStake *  Constants.UNUSUAL_STAKE_FACTOR))
            {
                return new RiskProfile
                {
                    Risk = Risk.Unusual,
                    Reason = "Stake is unusually large based on betting history."
                };
            }

            return Constants.SAFE_PROFILE;
        }
开发者ID:wenden-risk-analyser,项目名称:risky-ui,代码行数:29,代码来源:HighStakeRisk.cs

示例3: DisplayStats

        static void DisplayStats(IList<Response> responses)
        {
            if (!responses.Any())
            {
                return;
            }

            var average = responses.Average(x => (x.EndUtc - x.StartUtc).TotalMilliseconds);
            ClearLine();
            Console.WriteLine("Average time: {0} ms", Convert.ToInt32(average));

            var min = responses.Min(x => x.StartUtc);
            var max = responses.Max(x => x.EndUtc);
            var count = responses.Count;
            var timespan = Convert.ToInt32((max - min).TotalMilliseconds);
            timespan = timespan == 0 ? 0 : timespan / 1000;
            var rps = timespan == 0 ? 0 : count / timespan;

            ClearLine();
            Console.WriteLine("Performance: {0} rps ({1} reqs in {2})", Convert.ToInt32(rps), responses.Count, timespan);

            ClearLine();
            Console.WriteLine("Threads: {0}", responses.Select(x => x.TaskId).Distinct().Count());

            ClearLine();
            Console.WriteLine("Errors: {0}", responses.Count(x => !x.Success));
        }
开发者ID:sebastienros,项目名称:LoadTest,代码行数:27,代码来源:Program.cs

示例4: Compute

        public RatingResult Compute(IList<RestaurantReview> reviews)
        {
            var result = new RatingResult();

            result.Rating = (int)reviews.Average(r => r.Rating);

            return result;
        }
开发者ID:atbelarmino,项目名称:MVC4,代码行数:8,代码来源:IRatingAlgorithm.cs

示例5: Do

 public AggregationOperationResult Do(IList<UniversalValue> input)
 {
     if (input == null)
         throw new ArgumentNullException("input");
     AggregationOperationResult result = new AggregationOperationResult();
     result.Add("avg", input.Average());
     return result;
 }
开发者ID:demonix,项目名称:iPoint.ServiceStatistics,代码行数:8,代码来源:AvgAggregationOperation.cs

示例6: CalculateAverages

        private static AggregatedWeatherResponse CalculateAverages(IList<WeatherServiceResponse> weatherServiceResponses)
        {
            AggregatedWeatherResponse aggregatedResponse = null;

            if (weatherServiceResponses.Count > 0)
            {
                aggregatedResponse = new AggregatedWeatherResponse
                {
                    AverageTemperatureCelsius = Math.Round(weatherServiceResponses.Average(a => a.TemperatureCelsius), 1),
                    AverageTemperatureFahrenheit = Math.Round(weatherServiceResponses.Average(a => a.TemperatureFahrenheit), 1),
                    AverageWindSpeedKph = Math.Round(weatherServiceResponses.Average(a => a.WindSpeedKph), 1),
                    AverageWindSpeedMph = Math.Round(weatherServiceResponses.Average(a => a.WindSpeedMph), 1)
                };
            }

            return aggregatedResponse;
        }
开发者ID:robbakeruk,项目名称:Weather,代码行数:17,代码来源:WeatherAggregatorService.cs

示例7: Do

 public AggregationOperationResult Do(IList<double> input)
 {
     if (input == null)
         throw new ArgumentNullException("input");
     if (!input.Any())
         throw new InvalidOperationException("No elements to aggregate");
     return new AggregationOperationResult(AggregationType.Avg,input.Average());
 }
开发者ID:demonix,项目名称:iPoint.ServiceStatistics,代码行数:8,代码来源:AvgAggregationOperation.cs

示例8: FindSumAndAverage

        private static void FindSumAndAverage(IList<int> numbers)
        {
            long numbersSum = 0;
            double numbersAverage = 0;

            numbersSum = numbers.Sum();
            numbersAverage = numbers.Average();
            Console.WriteLine("The sum of your sequence is: {0} and the avgerage is: {1}.", numbersSum, numbersAverage);
        }
开发者ID:ekostadinov,项目名称:CoursesProjects,代码行数:9,代码来源:PositiveIntegersSequence.cs

示例9: GetAverage

        public static ArrayVector GetAverage(IList<ArrayVector> vectors)
        {
            if (vectors == null) throw new ArgumentNullException("vectors");
            if (vectors.Count == 0) throw new ArgumentException("The source must not be empty.", "vectors");

            return Enumerable.Range(0, vectors[0].Dimension)
                .Select(i => vectors.Average(v => v.Value[i]))
                .ToArray();
        }
开发者ID:sakapon,项目名称:Bellona.Analysis,代码行数:9,代码来源:ArrayVector.cs

示例10: Calculate

        public double Calculate(IList<Coder> participants)
        {
            var n = participants.Count;
            var ratAvg = participants.Average(x => x.R);

            var sqrRatStdev = participants.Sum(x => Math.Pow(x.R - ratAvg, 2)) / (n - 1);
            var sqrVolAvg = participants.Sum(x => x.V * x.V) / n;

            return Math.Sqrt(sqrVolAvg + sqrRatStdev);
        }
开发者ID:IvanMacek,项目名称:TopCoder-Rating-Analysis,代码行数:10,代码来源:CompetitionFactorFunction.cs

示例11: Analyze

        public static Movement Analyze(IList<Movement> movements)
        {
            Movement movement;

            if (movements.Any(x => x > Movement.Higher))
                movement = Movement.Highest;
            else if (movements.Any(x => x > Movement.High))
                movement = Movement.High;
            else if (movements.Any(x => x > Movement.Med))
                movement = Movement.Med;
            else if (movements.Average(x => (double)x) > (double)Movement.Lowest)
                movement = Movement.Low;
            else
                movement = Movement.Lowest;
            return movement;
        }
开发者ID:pkwd,项目名称:SleepHack,代码行数:16,代码来源:AccelerometerToMovementParser.cs

示例12: RelatorioJogosDisponiveisModel

        public RelatorioJogosDisponiveisModel(IList<Jogo> jogosDisponiveis)
        {
            this.Jogos = new List<JogoDisponivelModel>();

            if(jogosDisponiveis != null && jogosDisponiveis.Count > 0)
            {
                foreach (Jogo jogo in jogosDisponiveis)
                {
                    var jogoModel = new JogoDisponivelModel(jogo);
                    this.Jogos.Add(jogoModel);
                }

                this.QuantidadeTotalDeJogos = jogosDisponiveis.Count;
                this.ValorMedio = jogosDisponiveis.Average(j => j.Preco);
                decimal maiorPreco = jogosDisponiveis.Max(j => j.Preco);
                decimal menorPreco = jogosDisponiveis.Min(j => j.Preco);

                this.JogoMaisCaro = this.Jogos.First(j => j.Preco == maiorPreco);
                this.JogoMaisBarato = this.Jogos.First(j => j.Preco == menorPreco);
            }
        }
开发者ID:TiagoPintoAlves,项目名称:crescer-2015-2,代码行数:21,代码来源:RelatorioJogosDisponiveisModel.cs

示例13: CalculateSummaries

        public static StatSummary CalculateSummaries(IList<decimal> vals)
        {
            var res = new StatSummary();

            res.Count = vals.Count;
            res.Average = vals.Average();

            var sorted = new List<decimal>(vals);
            sorted.Sort();

            res.Median = CalculateQuantile(sorted, 0.5M);
            res.LowerQuartile = CalculateQuantile(sorted, 0.25M);
            res.UpperQuartile = CalculateQuantile(sorted, 0.75M);

            res.Min = sorted.First();
            res.Max = sorted.Last();

            res.Percentile2 = CalculateQuantile(sorted, 0.02M);
            res.Percentile98 = CalculateQuantile(sorted, 0.98M);

            Validate(sorted, res);
            return res;
        }
开发者ID:sopel,项目名称:AppMetrics,代码行数:23,代码来源:Stats.cs

示例14: StandardDeviation

 public static double StandardDeviation(IList<double> doubleList, out double average, out double max, out double min)
 {
     average = doubleList.Average();
     double sumOfDerivation = 0;
     max = -1e9;
     min = 1e9;
     foreach (double value in doubleList)
     {
         max = Math.Max(max, value);
         min = Math.Min(min, value);
         sumOfDerivation += (value) * (value);
     }
     double sumOfDerivationAverage = sumOfDerivation / doubleList.Count;
     return Math.Sqrt(sumOfDerivationAverage - (average * average));
 }
开发者ID:GabeTesta,项目名称:Warps,代码行数:15,代码来源:BLAS.cs

示例15: AverageIList

 public static double AverageIList(IList<double> numbers)
 {
     return numbers.Average();
 }
开发者ID:algobasket,项目名称:Dynamo,代码行数:4,代码来源:RegressionTargets.cs


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