I have the code to calculate the fashion of a population sample but I do not know what to do if it is a sample of two or more fashions.
public static void getModa(double muestra[]) {
int maximoNumRepeticiones= 0;
double moda= 0;
for(int i=0; i<muestra.length; i++)
{
int numRepeticiones= 0;
for(int j=0; j<muestra.length; j++)
{
if(muestra[i]==muestra[j])
{
numRepeticiones++;
} //fin if
if(numRepeticiones>maximoNumRepeticiones)
{
moda= muestra[i];
maximoNumRepeticiones= numRepeticiones;
} //fin if
}
} //fin for
System.out.print(moda);
} //fin getModa
This is what I hope you do:
Entry: double muestra= new double {3, 4, 3, 3, 5, 4, 4}
Output: moda= 3
4
This is what it does:
Entry: double muestra= new double {3, 4, 3, 3, 5, 4, 4}
Output: moda= 3
I'm supposed to have two fashions: 3 and 4. I could even have more but only show me the first one.