Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This seems like something I should be able to do but I can not for the life of me figure it out. I'm writing a program to calculate an average score; let's say that my data looks like this.

x = number of votes

y = current rating

z = new rating

Is there a way for me to calculate in the new rating, without needing the scores of each individual vote?

So say that an item has a total of two scores, the data would look like this:

x = 2

y = 90

and then a new rating is introduced (let's say someone scored a 50%):

z = 50

I need to calculate how the z would influence the 90%, without having a record of each individual rating.

Help is greatly appreciated!

share|cite|improve this question
up vote 2 down vote accepted

Suppose that $x$ votes lead to rating of $y$. Then $xy$ is the current total score (the sum of the scores of the $x$ people). Add the new score $z$, and divide by the new number of people. So the new average is $$\frac{xy+z}{x+1}.$$

In your numerical example, we have $x=2$ and the average score is $90$. So the scores of the $2$ people add up to $(2)(90)=180$. Add the new score $50$. We get $230$. Finally, divide by $3$.

Remark: The letters $x$, $y$, and $z$ are perhaps not ideal for your problem. I would call the current number of people something like $n$ instead of $x$.

share|cite|improve this answer
Thank you so much! This answered it perfectly. Waiting until I can accept it as an answer. I was just using those variables as placeholders (in the code, they're described by their variable names). – Andrew Klatzke Dec 2 '12 at 18:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.