Moving Averages (?) Question

181 Views Asked by At

I can't figure this out, Im building a basic formula and need some help Lets say I have three photos, each with a score

  1. Photo one: votesCount = 3 [9,8,7]
  2. Photo two: votesCount = 5 [9,8,1,6,7]
  3. Photo three: votesCount = 1 [4]

I want to create a reference to cumulativeScore that is a moving average of sorts where I will be able to simply use the cumulative average, the new score, and the total count (or count of photos ideally) to calculate a rough average score.

Is this possible? The photos dont have references to themselves, so I cannot use individual averages int he equation, nor the individual scores. I could use individual vote counts, but that would be a cumulativeVotes variable, not indivudal votes..

this is for a demo app im building, all help apprecaited with the maths :)