Last active
August 16, 2024 09:49
-
-
Save pozhidaevak/0dca594d6f0de367f232909fe21cdb2f to your computer and use it in GitHub Desktop.
Python dict with English letter frequency
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
letterFrequency = {'E' : 12.0, | |
'T' : 9.10, | |
'A' : 8.12, | |
'O' : 7.68, | |
'I' : 7.31, | |
'N' : 6.95, | |
'S' : 6.28, | |
'R' : 6.02, | |
'H' : 5.92, | |
'D' : 4.32, | |
'L' : 3.98, | |
'U' : 2.88, | |
'C' : 2.71, | |
'M' : 2.61, | |
'F' : 2.30, | |
'Y' : 2.11, | |
'W' : 2.09, | |
'G' : 2.03, | |
'P' : 1.82, | |
'B' : 1.49, | |
'V' : 1.11, | |
'K' : 0.69, | |
'X' : 0.17, | |
'Q' : 0.11, | |
'J' : 0.10, | |
'Z' : 0.07 } |
Not all heroes wear capes
Just a thumbs up 👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!
I found that the probabilities sum to about 99.97, not 100.
Try
If you e.g. want to choose random letters from the alphabet using
numpy.random.choice
, then you have to pass a normalized version of these values. Sowhere I assumed recent enough python for the keys and values to be ordered the same.
You may compute a renormalized dict as follows (with the
100
at the start or not).To 100:
To 1: