Recalculate an average value
问题 In my Java application I need to recalculate an average value based on the following data: I know current avg value - avgValue I know that avgValue is an average value for list of 12 values - count . Based on this information how to recalculate avgValue when a new value is added to this list of previous 12 values. What is the new avgValue for list of 13 values - count + 1 ? 回答1: Current Sum = avgValue * 12 New sum = current Sum + New value New average = New sum / 13 回答2: If you want to make