# Merging/averaging percentages

This may be a very simple question, but I'm not even sure what the correct terminology is for the procedure I am trying to do so I wasn't able to find anything else here...

The scenario is that I'm writing a program that tracks completion. The program has 2 classes: storage and the active record.

Storage contains:
variable: CompletionRate (a percentage)
function: MergeNewRate(newRate) (merges newRate with the old rate from previous session.)

ActiveRecord contains:
variable: Attempts (number of attempts)
variable: Completions (number of completions)
function: CompletionRate() (returns completions/attempts)

During a session, the ActiveRecord is updated as the user attempts and (potentially) completes their task. When the session ends, the value returned from CompletionRate() is stored in Storage's CompletionRate variable. In any subsequent sessions, I would like the users subsequent CompletionRates to average/merge/{insert correct terminology} the new rate with the old rate.

Example:
First Session
ActiveRecord.Attempts = 5;
ActiveRecord.Completions = 3;
var newRate = ActiveRecord.CompletionRate(); // = 3/5 = 0.6 Storage.MergeNewRate(newRate); //Storage.CompletionRate becomes 0.6

The user now participates in another session:
Second Session
ActiveRecord.Attempts = 3;
ActiveRecord.Completions = 1;
var newRate = ActiveRecord.CompletionRate(); // = 1/3 = 0.333 Storage.MergeNewRate(newRate); //Storage.CompletionRate SHOULD become 0.5

It should become 0.5 because ultimately the user has made 8 attempts and completed 4 across both sessions - and that's a 50% completion rate. Is there a way to do this given only 2 percentages?

Yes. I could just store and update Attempts and Completions on both Storage and ActiveRecord - but I am curious as to the solution to this (if there is one...).

-

There is no way.

Alicia has attempted $98$, completed $98$, then attempts $2$, fails at both. The cumulative average should hardly budge. In this case, $100\%$ "combined with" $0\%$ should be $98\%$.

Bob has attempted $2$, completed both, then attempts $2$, fails at both. In this case, $100\%$ "combined with" $0\%$ should be $50\%$.

But as you pointed out, there is an easy fix.

-
Thanks André, I was hoping for there to be some crazy voodoo that I've never heard of but I guess there isn't. Thanks for your answer! I'd upvote if I had the rep! – Jace Feb 27 '13 at 5:14

Like Andre said, give JUST the percentages, there is no way to do this because when you compute and save ONLY the percentages, you lose too much information. At the very least you need at least two pieces of information. Save either

total attempts and total completions

or

total attempts and the percentage. With the second case it'll be like a running weighted average. You probably thinking of something like taking the average of the percentages or something but that won't work. You would need a WEIGHTED average of the percentages but for that you need the weights which means again you need more information.

-
Thanks for your answer Fixed Point. I'd love to upvote, but I don't have the rep yet. – Jace Feb 27 '13 at 5:14