I am getting an error when I try to retrieve the individual values to find the variance in the process of calculating the standard deviation. I can't figure out whether to use .get() or .getValue and I am lost. I have already calculated the average.
final ArrayList<Map.Entry<String,NumberHolder>> entries = new ArrayList<Map.Entry<String,NumberHolder>>(uaCount.entrySet());
for(Map.Entry<String,NumberHolder> entry : entries) //iterating over the sorted hashmap
{
double temp = 0;
double variance = 0;
for (int i = 0; i <= entry.getValue().occurrences ; i ++)
{
temp += ((entry.getValue(i).singleValues) - average)*((entry.getValue(i).singleValues) - average);
variance = temp/entry.getValue().occurrences;
}
double stdDev = Math.sqrt(variance);
This is my NumberHolder class, which I populate in my main funcion. I am using this equation for standard deviation: http://www.mathsisfun.com/data/standard-deviation-formulas.html
based on my code, occurrences is N and the values from the singleValues arraylist are Xi
public static class NumberHolder
{
public int occurrences = 0;
public int sumtime_in_milliseconds = 0;
public ArrayList<Long> singleValues = new ArrayList<Long>();
}
This is the error I get. :
The method getValue() in the type Map.Entry<String,series3.NumberHolder> is not applicable for the arguments (int).
If you need to see more code please just ask, I didn't want to put anything unnecessary but I might have missed something.