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


C# ICollection.Average方法代码示例

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


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

示例1: GetSummary

 private static SummaryViewModel GetSummary(ICollection<TableProjection> tables)
 {
     return new SummaryViewModel
     {
         TablesCount = tables.Count,
         AverageColumnsPerTable = (int) Math.Round(tables.Average(x => x.ColumnsCount)),
         MaxColumnsPerTable = tables.Max(x => x.ColumnsCount)
     };
 }
开发者ID:titarenko,项目名称:OracleFiddler,代码行数:9,代码来源:SchemaExplorerController.cs

示例2: DeviationEstimation

 /// <summary>
 /// 
 /// </summary>
 /// <param name="sequence"></param>
 /// <returns></returns>
 private static Double DeviationEstimation(ICollection<Double> sequence)
 {
     Double result;
     result = Math.Sqrt(sequence.Count / (Double)(sequence.Count - 1) * sequence.Average(x => Math.Pow(x - ExpectedValue, 2)));
     return result;
 }
开发者ID:romannort,项目名称:Modeling.LabTwo,代码行数:11,代码来源:StatisticsResults.cs

示例3: DoStepResult

        private static void DoStepResult(TaskSetting setting, StringBuilder writer, string stepName, ICollection<CaseStep> steps, int depth = 0,StepTimer st=null)
        {
            string preChar = "".PadLeft(depth * 4);
            double minTime = steps.Min(t => t.Timer.MinTime);
            double aveTime = steps.Average(t => t.Timer.AveTime);
            double maxTime = steps.Max(t => t.Timer.MaxTime);
            int successNum = steps.Sum(t => t.Timer.SuccessNum);
            int failNum = steps.Sum(t => t.Timer.FailNum);
            if (failNum > 0)
            {
                string error = string.Join("", steps.Select(t => t.Timer.Error).ToList());
                TraceLog.WriteError("{0}", error);
            }
            writer.AppendFormat("====={0}-{1}({2})", setting.TaskName, stepName, DateTime.Now.ToString());
            writer.AppendLine();
            writer.AppendFormat("====={0}", setting.TaskDes);
            writer.AppendLine();
            writer.AppendFormat("{0}>>Step {1}: success:{2}, fail:{3}", preChar, stepName, successNum, failNum);
            writer.AppendLine();
            writer.AppendFormat("{0}    AVE:\t{1}ms", preChar, aveTime.ToString("F6"));
            writer.AppendLine();
            writer.AppendFormat("{0}    Min:\t{1}ms", preChar, minTime.ToString("F6"));
            writer.AppendLine();
            writer.AppendFormat("{0}    Max:\t{1}ms", preChar, maxTime.ToString("F6"));
            writer.AppendLine();
            writer.AppendFormat("{0}    TotalTime:\t{1}ms",preChar,st!=null ? st.RunTotalTime.ToString("F6"):"");
            writer.AppendLine();
            string info = "";
            foreach(var v in steps)
            {
                if (v.DecodePacketInfo!="")
                    info += v.DecodePacketInfo + "\n";
            }
            if(info != "")
            {
                writer.AppendFormat("req/res:\n{0}",info);
                writer.AppendLine();
            }

            var childs = steps.Where(t => t.ChildStep != null).Select(t => t.ChildStep).ToArray();
            if (childs.Length > 0)
            {
                DoStepResult(setting,writer, childs[0].Action, childs, depth + 1);
            }
            writer.AppendFormat("====={0}-{1}:End", setting.TaskName,stepName);
            writer.AppendLine();
        }
开发者ID:guccang,项目名称:autoTest,代码行数:47,代码来源:ThreadManager.cs

示例4: GetBestGenetically

        private void GetBestGenetically(int freezeGenesUpTo, int numberOfGenesToUse, Func<char> getRandomGene, List<GeneSequence> previousBests, List<GeneSequence> population, List<GeneSequence> spare, Func<string, FitnessResult> calcFitness, ICollection<int> generationsBetweenImprovments, ref int generation)
        {
            _slidingMutationRate = DefaultMutationRate;
            int fastSearchPopulationSize = GaPopsize / 10 + 4 * numberOfGenesToUse / _numberOfGenesInUnitOfMeaning;
            int maxGenerationsWithoutImprovement = (int)(generationsBetweenImprovments.Average() * 1.5);
            Console.WriteLine("> max generations to run without improvement: " + maxGenerationsWithoutImprovement);
            int maxGenerationsWithoutNewSequences = maxGenerationsWithoutImprovement / 10;
            int generationsWithoutNewSequences = 0;
            int i = 0;
            for (; i < maxGenerationsWithoutImprovement && generationsWithoutNewSequences <= maxGenerationsWithoutNewSequences; i++, generation++)
            {
                var previousBestLookup = new HashSet<string>(previousBests.Select(x => x.Fitness.UniqueKey ?? x.GetStringGenes()));
                var populationWithFitness = CalcFitness(population, calcFitness);

                var first = populationWithFitness.First();
                var worstFitness = previousBests[previousBests.Count / 2].Fitness.Value;
                var newSequences = populationWithFitness
                    .Take(UseFastSearch /*&& i < 20*/ ? fastSearchPopulationSize : GaPopsize)
                    .Where(x => x.Fitness.Value <= worstFitness)
                    .Where(x => previousBestLookup.Add(x.Fitness.UniqueKey ?? x.GetStringGenes()))
                    .Take(UseFastSearch ? MaxImprovmentsToKeepFromEachRound : (int)((1 - _slidingMutationRate) * GaPopsize))
                    .ToList();

                if (newSequences.Any())
                {
                    generationsWithoutNewSequences = 0;
                    SortByFitness(newSequences);
                    var previousBestFitness = previousBests.First().Fitness.Value;
                    if (newSequences.First().Fitness.Value < previousBestFitness)
                    {
                        PrintBest(generation, newSequences.First());
            //                        Console.WriteLine("> improved after generation " + i);
                        generationsBetweenImprovments.Add(i);
                        i = -1;
                    }
                    foreach (var copy in newSequences.Select(geneSequence => geneSequence.Clone()))
                    {
                        copy.Generation = generation;
                        previousBests.Add(copy);
                    }
                    int numberToKeep = Math.Max(100, previousBests.Count(x => x.Fitness.Value == first.Fitness.Value));
                    SortByFitness(previousBests);
                    if (numberToKeep < previousBests.Count)
                    {
                        previousBests.RemoveRange(numberToKeep, previousBests.Count - numberToKeep);
                    }
                    UpdateStrategyPercentages(previousBests, generation);

                    _slidingMutationRate = DefaultMutationRate;
                }
                else
                {
                    generationsWithoutNewSequences++;
                    if (generationsWithoutNewSequences > maxGenerationsWithoutNewSequences)
                    {
                        break;
                    }
                    _slidingMutationRate = Math.Max(_slidingMutationRate - SlideRate, 0);
                }

                if (first.Fitness.Value == 0)
                {
                    break;
                }

                CreateNextGeneration(freezeGenesUpTo, numberOfGenesToUse, population, spare, getRandomGene, previousBests);
                var temp = spare;
                spare = population;
                population = temp;
            }

            generationsBetweenImprovments.Add(i);

            //            previousBests.First().GetStringGenes();
        }
开发者ID:BarakUgav61,项目名称:Scratch,代码行数:75,代码来源:GeneticSolver.cs

示例5: DoStepResult

 private static void DoStepResult(StringBuilder writer, string stepName, ICollection<CaseStep> steps, int depth = 0)
 {
     string preChar = "".PadLeft(depth * 4);
     double minTime = steps.Min(t => t.Timer.MinTime);
     double aveTime = steps.Average(t => t.Timer.AveTime);
     double maxTime = steps.Max(t => t.Timer.MaxTime);
     int successNum = steps.Sum(t => t.Timer.SuccessNum);
     int failNum = steps.Sum(t => t.Timer.FailNum);
     if (failNum > 0)
     {
         string error = string.Join("", steps.Select(t => t.Timer.Error).ToList());
         TraceLog.WriteError("{0}", error);
     }
     writer.AppendFormat("{0}>>Step {1}: success:{2}, fail:{3}", preChar, stepName, successNum, failNum);
     writer.AppendLine();
     writer.AppendFormat("{0}    AVE:\t{1}ms", preChar, aveTime.ToString("F6"));
     writer.AppendLine();
     writer.AppendFormat("{0}    Min:\t{1}ms", preChar, minTime.ToString("F6"));
     writer.AppendLine();
     writer.AppendFormat("{0}    Max:\t{1}ms", preChar, maxTime.ToString("F6"));
     writer.AppendLine();
     var childs = steps.Where(t => t.ChildStep != null).Select(t => t.ChildStep).ToArray();
     if (childs.Length > 0)
     {
         DoStepResult(writer, childs[0].Action, childs, depth + 1);
     }
 }
开发者ID:lvshiling,项目名称:Scut,代码行数:27,代码来源:ThreadManager.cs

示例6: FillAggregates

        public static void FillAggregates(this AggregateRow row, ICollection<EmployeeRow> employees)
        {
            row.EmployeeCount = employees.Count;

            row.GrossPayAvg = employees.Average(e => e.GrossPay);
            row.GrossPayMin = employees.Min(e => e.GrossPay);
            row.GrossPayMax = employees.Max(e => e.GrossPay);
            row.GrossPaySum = employees.Sum(e => e.GrossPay);
            row.GrossPayMed = employees.Median(e => e.GrossPay);

            row.SalaryAvg = employees.Average(e => e.Salary);
            row.SalaryMin = employees.Min(e => e.Salary);
            row.SalaryMax = employees.Max(e => e.Salary);
            row.SalarySum = employees.Sum(e => e.Salary);
            row.SalaryMed = employees.Median(e => e.Salary);
        }
开发者ID:Thinking-Beard,项目名称:civilsalary,代码行数:16,代码来源:AggregateRow.cs


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