Calculating average and standard deviation

#1

I have a method called onEddystonesFound that runs approximately every second. As a parameter it has a list of beacons ordered by RSSI values, so the closest beacon can be found in index[0].

Each beacon has a UID which can be called with eg. beacon.get(0).instance and a RSSI value which can be called with eg. beacon.get(0).instance

For the 4 nearest beacons, I want to collect the 10 latest RSSI values for each beacon and calculate an average and a standard deviation of the 10 values to remove outliers and calculate a new average of the remaining values. How can I do this the best way? Have anybody tried to do this before?

@Override
public void onEddystonesFound(List<Eddystone> beacon) {

}