The code at the link is mediocre – it has dozens of unnecessary casts or declarations, dozens of superfluous statements, and numerous unused or unnecessary variables. Also, the code shown there has nothing about any averages, so evidently does not show whatever code you actually are running. You could revise your question and include the actual sketch within it.
Nevertheless, the code at the link looks like it will take a reading ok. Possibly your modifications, whatever they are, incorrectly initialize variables for the running average calculation, or incorrectly initialize some other variable not shown. Or there may be some hardware glitch that spoils the first reading.
Several fixes are possible. You could discard the first reading. You could discard the first reading of each set of readings. You could take readings in sets of three or five and only keep the median reading. You could take sets of readings and discard the highest and lowest readings. You could apply exponential smoothing or some other form of smoothing to the readings.
Note, the formula you show for averaging –
((count-1)/count)*volt_mV + (1/count)*volt_V – has a number of problems. First, if
count is an integer, both of
(1/count) will compute to zero values. Secondly, as
count becomes large, you will be adding a tiny value to a much larger value, which is ill-conditioned arithmetic. Third, although the formula computes a running average, it does not compute a moving average. That is, your formula computes the average of all readings taken so far, with all readings equally weighted. A moving average, on the other hand, typically will weight recent readings more heavily than old readings, for example via a window technique or via an exponential smoothing formula like
movingAverage = (15*movingAverage + newReading)/16.