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.