java - standard deviation arraylist error -


i getting error when try retrieve individual values find variance in process of calculating standard deviation. can't figure out whether use .get() or .getvalue , lost. have calculated average.

final arraylist<map.entry<string,numberholder>> entries = new arraylist<map.entry<string,numberholder>>(uacount.entryset());   for(map.entry<string,numberholder> entry : entries)  //iterating on sorted hashmap {      double temp = 0;     double variance = 0;      (int = 0; <= entry.getvalue().occurrences ; ++)         {                            temp += ((entry.getvalue(i).singlevalues) - average)*((entry.getvalue(i).singlevalues) - average);              variance = temp/entry.getvalue().occurrences;         }          double stddev = math.sqrt(variance); 

this numberholder class, populate in main funcion. using equation standard deviation: http://www.mathsisfun.com/data/standard-deviation-formulas.html

based on code, occurrences n , values singlevalues arraylist xi

public static class numberholder {     public int occurrences = 0;     public int sumtime_in_milliseconds = 0;      public arraylist<long> singlevalues = new arraylist<long>(); } 

this error get. :

the method getvalue() in type map.entry<string,series3.numberholder> not applicable arguments (int).  

if need see more code please ask, didn't want put unnecessary might have missed something.

you can't take int argument in map.entry#getvalue(). in code should entry.getvalue() instead of entry.getvalue(i). apart singlevalues arraylist . can't subtract integer average in line (entry.getvalue(i).singlevalues) - average). have first extract out element arraylist , subtract average. loop should this:

for (int = 0; < entry.getvalue().occurrences ; ++)// < entry.getvalue() avoid indexoutofboundsexception {                   temp += ((entry.getvalue().singlevalues.get(i)) - average)*((entry.getvalue().singlevalues.get(i)) - average);    variance = temp/entry.getvalue().occurrences; } 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -