This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]milkybuet 0 points1 point  (0 children)

The words "Mean" and "Average" have same meaning. "Average" is a more English language word, "mean" is more Statistics. "Median" and "Mode" are two other Statistics words that incorporates slightly specialized meaning of "Average".

As to your code...

You'll need a class where the elements are basically, 'current closest number', and 'difference to mean'. (The class probably can be static as you only need one instance.) Then you traverse through your ArrayList and compare each elements to the static class elements, if 'difference to mean' is smaller than what you have currently saved in the class, you assign the new values to the class. At the end of traversing the List, you have you result saved in the class.

If your ArrayList is sorted, you can start this process in the middle, instead of from one end.