I'm working on a project where I'm trying to decipher an input text using frequency analysis. So far I've added first letter frequencies, common bigrams, double letter frequencies, as well as single letter frequencies.
An issue I'm running into is finding a way to calculate a sort of threshold for single letter frequencies. For example, my frequency for the letter 'e' is 12.02. Now when i enter the phrase "hello world" as a cipher "zkppo worpd", the letter frequency for what should be 'e' is roughly 9. Using just the letter frequencies from the array, it would therefore convert the 'k' to a 't'. I was wondering if there was any sort of algorithm I could use to give the letter frequencies a threshold based off of the length of input string.
If you guys would want to look at the code, the link is here.