Warning: Parameter 1 to Language::getMagic() expected to be a reference, value given in /home/boincnew/public_html/boinc-wiki.info/w/includes/StubObject.php on line 58
Recent Average Credit - Unofficial BOINC Wiki

# Recent Average Credit

(Redirected from RAC)

The current running average of credit earned by each Computer, Participant, or Team over time.

Think of it as a speedometer …

It tracks the rate at which you are earning credit with Credit earned today having more weight in the average than the Credit granted in the past; each day farther back the less impact on the "running" average

This is done so that the value does not jump up and down as Granted Credit events occur.

The Recent Average Credit is updated when Credit is added (from verified results). Recent Average Credit is computed by taking the Total Credit (not the Claimed Credit) and reducing it by half every week before adding the current Granted Credit. Since the credit is added as it is granted, the formula takes into account the time difference between now and the last time that Credit was granted. If no Credit is granted for a week, the Recent Average Credit is reduced by half anyway.

The Recent Average Credit calculation is run independently for each computer, participant, or team. So having an old computer that is no longer producing credits does not reduce the Recent Average Credit, but rather will increase it from what it would have been without the old computer. This increment will shrink until it is indistinguishable from 0.

The Recent Average Credit credit is therefore the number of Cobblestones per day performed recently in the production of Work Units by each Computer, Participant, or Team. This average decreases by 50% in the "half-life", according to algorithm.

##  Computation of the Recent Average Credit

###  Updating the RAC

So how is the Recent Average Credit computed? Each time new Credit granted, the following function is used to update the Recent Average Credit of the Computer, Participant, or Team:
RAC(new) = RAC(old)*d(t) + (1-d(t))*credit(new)

Where d(t) is the decay function, and t is the time (in seconds) since the last Recent Average Credit recalculation.

d(t) = e^(-ln(2)*t / 604800)

The Recent Average Credit for any Computer, Participant, or Team is calculated every time that Credit is added to that object. Please see also the example on the right.

Note:
Also, the Recent Average Credit number is updated when Credit is granted after the Result has passed Validation, not when a Result is returned. This is true for all current Projects with the exception of Climateprediction.net (CPDN) which has different Quorum Rules.

####  Prediction of RAC Development for a Machine

Actually, PC #2 and #3 are the same whereas the two simulations depict how the RAC develops from 0 when running 24 hours a day (pink) and from maximum to a level when running the machine only 12 hours a day (yellow).
Download this Excel Sheet in order to visualize the development of the RAC if running your machine continuously. The sheet determines the correct curve based on the formulas denoted above and the average computation duration (CPU Time), average credit granted and the number of CPUs/cores. Additionally, you can specify how long a machine is crunching per day.

Simply get these values from the Results For Computer Page and roughly estimate the particular average.

###  Decreasing the RAC

If an entire week passed since the last credit was granted, the Recent Average Credit for the object will be divided by 2. The actual calculation is exponential. If an object starts with a Recent Average Credit of 128, and no Credit is added, after a week, the RAC will be 64, after another week, the RAC will be 32. Continuing week by week 16, 8, 4, 2, 1, 1/2, 1/4, 1/8, 1/16 ... Eventually, it will be close enough to zero so as not to matter.

Note:
The original intent was to actually calculate the Recent Average Credit at least once a week. This provision was dropped because of the impact on the BOINC Database by the query that would be used to update the numbers. Most of the Third Party Statistics Sites still calculate the Recent Average Credit this way.

###  Important to Notice

On one point, there is an oddity, and it doesn't make perfect sense. Removing a component will have no bearing on the calculation of the parent's Recent Average Credit.

Since the calculation of the Recent Average Credit is sensitive to time that the Recent Average Credit was last calculated, the Recent Average Credit of the children may not add to the Recent Average Credit of the parent. For example it is possible to have 2 computers that have Recent Average Credits of 15 and 30, and still have the Participant's Recent Average Credit of 35, or 25, etc.

Right after joining a BOINC Powered Project and getting the first credits granted are working against a very short time, and slightly odd things can happen to the numbers. The odd numbers for Recent Average Credit at the beginning of a Participants tenure at a Project are strictly an artifact of the equation used to generate them and are the result of the extremely short time span and the lack of previous data.

Note:
The Back-End Systems have to be up and running for the values to be updated. The process to update the Recent Average Credit should be run on a weekly basis, but it is possible that this process may be halted and the RAC will not reflect abrupt terminations of the Participant's computers contributions to a project.

So, if one or more of your machines stops processing work for a BOINC Powered Project, it is possible that its Recent Average Credit will remain at a constant value for some period of time and you will not see an expected decay curve. The same effect holds true for when the Project stops accepting returned Results, such as when the Project is suspended.

Most of the Third Party Statistics Sites that gather the Project data do an external calculation of the Recent Average Credit making the numbers that they output accurate.

Note:
You cannot sum Recent Average Credit values, such as adding all of your individual computer's Recent Average Credit numbers and get a meaningful answer.
Whenever the credit for any particular item (host, user, or team) changes, the RAC for that item is re-calculated. The calculation is very sensitive to when the calculation is done, so it is true that the RAC for all of the hosts that belong to a user will not add to the RAC for the user, and the RAC for all users in a team will also not add to the RAC for the team.

The simplest way to picture it is that Total Credit is like your odometer, and Recent Average Credit is like your speedometer.

##  Implementation of the Recent Average Credit Algorithm

BOINC Powered Projects maintain two counts of Granted Credit:

• Total Credit: The total number of Cobblestones performed and granted.
• Recent Average Credit: The average number of Cobblestones per day granted recently. This average decreases by a factor of two every week, according to the algorithm given below.

Both quantities (Total Credit and Recent Average Credit) are maintained for each Participant, Host, and Team.

Each time new Credit is granted, the following function is used to update the recent average credit of the Participant, Host, and Team:

```void update_average(
double work_start_time,         // when new work was started
// (or zero if no new work)
double work,                    // amount of new work
double half_life,
double& avg,                    // average work per day (in and out)
double& avg_time                // when average was last computed
) {
double now = dtime();

if (avg_time) {
// If an average R already exists, imagine that the new work was done
// entirely between avg_time and now.
// That gives a rate R'.
// Replace R with a weighted average of R and R',
// weighted so that we get the right half-life if R' == 0.
//
// But this blows up if avg_time == now; you get 0*(1/0)
// So consider the limit as diff->0,
// using the first-order Taylor expansion of
// exp(x)=1+x+O(x^2).
// So to the lowest order in diff:
// weight = 1 - diff ln(2) / half_life
// so one has
// avg += (1-weight)*(work/diff_days)
// avg += [diff*ln(2)/half_life] * (work*SECONDS_PER_DAY/diff)
// notice that diff cancels out, leaving
// avg += [ln(2)/half_life] * work*SECONDS_PER_DAY

double diff, diff_days, weight;

diff = now - avg_time;
if (diff<0) diff=0;

diff_days = diff/SECONDS_PER_DAY;
weight = exp(-diff*M_LN2/half_life);

avg *= weight;

if ((1.0-weight) > 1.e-6) {
avg += (1-weight)*(work/diff_days);
} else {
avg += M_LN2*work*SECONDS_PER_DAY/half_life;
}
} else if (work) {
// If first time, average is just work/duration
//
double dd = (now - work_start_time)/SECONDS_PER_DAY;
avg = work/dd;
}
avg_time = now;
}
```

###  Computing the Current Value of Recent Average Credit

The BOINC Server Software updates "Recent Average Credit" (RAC) only when new Credit is granted. Interfaces that export RAC also export that time at which it was last updated. To obtain the current value of RAC, you must 'decay' it based on the time that has elapsed since it was updated:

```   \$M_LN2 = 0.693147180559945309417;
\$credit_half_life = 86400 * 7;
if (\$now == 0) {
\$now = time();
}
\$diff = \$now - \$avg_time;
\$weight = exp(-\$diff * \$M_LN2/\$credit_half_life);
\$avg *= \$weight;
return \$avg;
}
```

If you don't apply this decay, inactive entities will have incorrectly high RAC.

Note:
PHP code for the decay function can be found in html/inc/credit.inc and html/inc/host.inc.