Answer the question
In order to leave comments, you need to log in
How to transfer a mathematical formula to a program?
Hello, there is a formula
. Am I implementing it correctly in the code or am I mistaken?
for(int i = 0; i < foundLettersFrequency.size(); i++)
{
double letterFrequency = foundLettersFrequency[i];
double stringLength = 10; // Длина строки находится иначе. это для упрощения
// Сама формула, на каждой итерации цикла - Верно ли?
double IC = letterFrequency * (letterFrequency - 1) / stringLength * (stringLength - 1);
}
Answer the question
In order to leave comments, you need to log in
You are wrong. Division and multiplication are equal left associative operations.
And there is no summation in your loop.
1. declaring variables inside the loop hurts the eye, fu.
2. IC is not initialized to zero before the loop, as a result the variable may have a random value.
3. IC += ... you need the sum, but where do you have the summation?
4.
double stringLength = 10; // The length of the string is found differently. this is to simplifyreal string length??
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question