SHARE
TWEET

Ugly Stats

a guest Sep 30th, 2015 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var rawData = "gYxseNjwafVPfgsoHnzLblmmAxZUiOnGcchqEAEwjyxwjUIfpXfJQcdLapTmFaqHGCFsdvpLarmPJLOZYMEILGNIPwNOgEazuBVJcyVjBRL";
  2. var letterFrequencies = rawData.ToLower().ToCharArray().GroupBy(c => c).Select(g => new KeyValuePair<char, int>(g.Key, g.Count())).OrderByDescending(p => p.Value);
  3. var homeRow = "asdfghjkl".ToCharArray();
  4.  
  5. var totalChars = letterFrequencies.Sum(kvp => kvp.Value);
  6. var homeRowChars = letterFrequencies.Where(kvp => homeRow.Contains(kvp.Key)).Sum(kvp => kvp.Value);
  7.  
  8. //Console.WriteLine("total: " + totalChars);
  9. //Console.WriteLine("home row: " + homeRowChars);
  10. Console.WriteLine("Home row % expected: " + (9.0/26).ToString("0.0%"));
  11. Console.WriteLine("Home row % actual: " + ((double)homeRowChars/totalChars).ToString("0.0%"));
  12.  
  13. var upperCount = rawData.ToCharArray().Count(c => char.IsUpper(c));
  14. Console.WriteLine("Expected upper: 50%");
  15. Console.WriteLine("Actual upper: " + ((double)upperCount/rawData.Length).ToString("0.0%"));
  16.  
  17. var sequentialCaseCount = 0;
  18. var lastUpper = char.IsUpper(rawData[0]);
  19. foreach (char c in rawData.ToCharArray().Skip(1))
  20. {
  21.     var currUpper = char.IsUpper(c);
  22.     if (lastUpper == currUpper)
  23.         {
  24.             sequentialCaseCount++;
  25.         }
  26.        
  27.         lastUpper = currUpper;
  28. }
  29.  
  30. Console.WriteLine("Expected sequential case match: 50%");
  31. Console.WriteLine("Actual sequential case match: " + ((double)sequentialCaseCount / (rawData.Length - 1)).ToString("0.0%"));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top