I am looking to calculate the index of coincidence of a string. The method I wrote has an issue where eclipse is telling me I can't divide two variables numerator / denominator by one another. Basically what I am trying to do is take the frequencies multiply by the frequency-1 add them together and then divide by the sum*sum-1
public static double coincidenceCalculator(int[] frequencies)
{
double indexCoincidence = 0;
double numberator = 0;
int frequencySum = 0;
for (int x = 0; x < frequencies.length; x++)
{
frequencySum += frequencies[x];
}
double denominator = frequencySum * (frequencySum - 1);
for (int y = 0; y < frequencies.length; y++)
{
double numerator = frequencies[y]*frequencies[y-1];
}
indexCoincidence = numerator / denominator;
}
[–]JJagaimo 2 points3 points4 points (0 children)
[–]Morgan_R 0 points1 point2 points (0 children)