I'm trying to calculate the entropy of English using the following Java function
public static void calculateEntropy()
{
for(int i = 0; i < letterFrequencies[i]; i++)
{
entropy += letterFrequencies[i] * (Math.log(letterFrequencies[i])/Math.log(2));
}
entropy *= -1;
}
The formula I'm using requires log base 2 but Java only has natural log and log base 10. I'm trying to use the change of base formula to get the log base 2 of letterFrequencies[i]. I do not know if I am implementing it correctly because I'm expecting an answer close to 4.18 but instead getting roughly .028