| 41 | |
| 42 | == Computing the current value of Recent Average Credit == |
| 43 | BOINC 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: |
| 44 | |
| 45 | {{{ |
| 46 | function decay_average($avg, $avg_time, $now = 0) { |
| 47 | $M_LN2 = 0.693147180559945309417; |
| 48 | $credit_half_life = 86400 * 7; |
| 49 | if ($now == 0) { |
| 50 | $now = time(); |
| 51 | } |
| 52 | $diff = $now - $avg_time; |
| 53 | $weight = exp(-$diff * $M_LN2/$credit_half_life); |
| 54 | $avg *= $weight; |
| 55 | return $avg; |
| 56 | } |
| 57 | }}} |
| 58 | If you don't apply this decay, inactive entities will have incorrectly high RAC. |
| 59 | |
| 60 | PHP code for the decay function can be found in [source:trunk/boinc/html/inc/credit.inc html/inc/credit.inc] and [source:trunk/boinc/html/inc/host.inc html/inc/host.inc]. |