public RosterAssignmentAnalyzer(IDictionary<PositionAbbreviation, RosterPosition> rosterPositions, ICollection<Player> availablePlayers)
        {
            if (availablePlayers.Count > rosterPositions.Sum(rp => rp.Value.Count))
            {
                throw new ArgumentException("There are more players than roster positions available.");
            }

            _rosterPositions = rosterPositions;
            _availablePlayers = availablePlayers;
        }
        public double Value(IDictionary<string, double> p1, IDictionary<string, double> p2)
        {
            double dot = 0;

            string[] keys = p2.Keys.ToArray();

            foreach (string key in keys)
                if (p1.ContainsKey(key))
                    dot += Math.Sqrt(p1[key] * p2[key]);

            return -dot / Math.Sqrt(p1.Sum(c => c.Value)) * Math.Sqrt(p2.Sum(c => c.Value));
        }
Example #3
0
        static void GenerateReport(IDictionary<Uri, long> dump, IDictionary<string, long> errors)
        {
            var totalCount = dump.Sum(pair => pair.Value);
            var distinctCount = dump.Count;
            var errorCount = errors.Sum(pair => pair.Value);
            var top10 = dump.OrderByDescending(pair => pair.Value).Take(10).ToList();
            var top10Errors = errors.OrderByDescending(pair => pair.Value).Take(10).ToList();

            Console.Clear();

            Console.WriteLine($"Total Count:\t\t{totalCount}");
            Console.WriteLine($"Distinct Count:\t\t{distinctCount}");
            Console.WriteLine($"Error Count:\t\t{errorCount}");
            Console.WriteLine();
            Console.WriteLine("Top 10:");
            top10.ForEach(pair => Console.WriteLine($" ({pair.Value}) {pair.Key}"));Console.WriteLine();
            Console.WriteLine("Top 10 Errors:");
            top10Errors.ForEach(pair => Console.WriteLine($" ({pair.Value}) {pair.Key}"));
        }
Example #4
0
 // ReSharper restore UnusedMember.Local
 public Genie(IDictionary<string, AnswerStatistic> answerStatistics, int answeringChoicesCount)
 {
     this.answerStatistics = answerStatistics;
     this.answeringChoicesCount = answeringChoicesCount;
     answersGuessedCount = answerStatistics.Sum(s => s.Value.AnswerCount);
     questionStatistics = answerStatistics.SelectMany(s => s.Value.AnsweredQuestionsById)
                             .GroupBy(p => p.Key)
                             .ToDictionary(g => g.Key, g => new QuestionStatistic
                                 {
                                     ChoicesFrequencies = g.Aggregate(new int[answeringChoicesCount], (curr, p) =>
                                         {
                                             for (int i = 0; i < answeringChoicesCount; i++)
                                             {
                                                 curr[i] += p.Value.ChoicesFrequencies[i];
                                             }
                                             return curr;
                                         })
                                 });
 }
Example #5
0
        private Dictionary<Allele, double> getAlleleFreqs(IDictionary<Genotype, int> genotypeCounts)
        {
            // Get the total count of Alleles
            long totalPop = genotypeCounts.Sum(pair => (long)pair.Value);
            long totalAlleles = 2 * totalPop;

            // Get the count of each Allele (twice in homozygotes, once in heterozygotes)
            Dictionary<Allele, long> alleleCounts = new Dictionary<Allele, long>();
            Genotype[] genotypes = genotypeCounts.Keys.ToArray();
            foreach (Genotype g in genotypes) {
                int count = genotypeCounts[g];

                // Increment the first Allele's count
                if (alleleCounts.ContainsKey(g.Allele1))
                    alleleCounts[g.Allele1] += count;
                else
                    alleleCounts.Add(g.Allele1, count);

                // Increment the second Allele's count
                if (alleleCounts.ContainsKey(g.Allele2))
                    alleleCounts[g.Allele2] += count;
                else
                    alleleCounts.Add(g.Allele2, count);
            }

            // Divide by total to get Allele frequencies
            Dictionary<Allele, double> alleleFreqs = alleleCounts.ToDictionary(
                pair => pair.Key,
                pair => (double)pair.Value / (double)totalAlleles
            );
            return alleleFreqs;
        }
        private void WriteHeader(StreamWriter sw, IDictionary<File, string> files, TypeDefinition[] types)
        {
            var total = files.Sum(x => x.Key.Annotations.Length);

            sw.WriteLine("<html>");
            sw.WriteLine("<head>");
            sw.WriteLine("<meta charset='utf-8' />");
            sw.WriteLine("<title>Warning Report</title>");
            sw.WriteLine("<link rel='stylesheet' type='text/css' href='report.css' />");
            sw.WriteLine("</head><body><div class='container'>");
            sw.WriteLine("<h1>Summary</h1>");
            sw.WriteLine("<table class='overview'>");
            sw.WriteLine("<colgroup>");
            sw.WriteLine("<col width='160' />");
            sw.WriteLine("<col />");
            sw.WriteLine("</colgroup>");
            sw.WriteLine("<tbody>");
            sw.WriteLine("<tr><th>Generated on:</th><td>" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "</td></tr>");

            WriteStats(sw, files, types, total);

            sw.WriteLine("</tbody>");
            sw.WriteLine("</table>");
            sw.WriteLine("<h1>Files</h1>");
        }
 private int GetWordCount(IDictionary<string, int> words)
 {
   return words.Sum(pair => pair.Value);
 }
Example #8
0
 /// <summary>
 /// Writes total captured rowcounts to log and graphite
 /// </summary>
 private void RecordRowCounts(IDictionary<string, long> changesCaptured)
 {
     long total = changesCaptured.Sum(x => x.Value);
     logger.Log("Total rowcount across all tables: " + total, LogLevel.Info);
     string key = string.Format("db.mssql_changetracking_counters.RowCountsMaster.{0}.{1}", Config.Master.Replace('.', '_'), Config.MasterDB);
     logger.Increment(key, total);
 }