[[PageOutline]] = Credit statistics web sites and services = '''Statistics data''' describes the [http://boinc.berkeley.edu/wiki/Computation_credit credit] granted to hosts, participants and teams by the various BOINC projects. This can be used for various purposes, such as: * Web sites that show statistics and leaderboards for one or more BOINC projects. Examples are available on the [http://boinc.berkeley.edu/links.php#stats list of stats sites]. * Dynamically-generated images (typically used as message-board signatures) that show user and/or team credit, possible across projects. Examples are listed [http://boinc.berkeley.edu/links.php#sigs here]. * Displays of current credit on cell phones and PDAs. Displays that use colors to distinguish BOINC projects should use [http://boinc.netsoft-online.com/e107_plugins/forum/forum_viewtopic.php?3 these colors]. BOINC provides a flexible architecture for distributing statistics data, with the goal of enabling new display applications. ---- [[Image(stats.png, nolink)]][[BR]] '''The BOINC statistics data architecture''' ---- == Getting data from projects == #getting-data Each BOINC project provides data in two forms: * As [XmlStats a set of downloadable files] (in a compressed XML format) that contain the project's complete current statistics. These files are typically updated once every 24 hours. * As [WebRpc a set of Web RPCs] that return an XML-format description of a given participant's credit, based on that participant's database ID. Applications should access these data sources as infrequently as possible, to avoid imposing unnecessary load on project servers. For example, a Web RPCs to get a particular participant's data should made at most once per hour. == Aggregate data == #aggregate A '''data aggregator''' is a service that collects XML files from several projects, and computes the totals for participants and hosts (based on [CrossProjectId cross-project IDs]) across these projects. This aggregate data is then exported in two ways: * As [StatsXml a set of downloadable files] (in a compressed XML format). An example is at http://boinc.netsoft-online.com/stats/. * As [StatsXml#WebRPCs a set of Web RPCs] that return an XML-format description of a given participant or host's credit, based on the cross-project ID. Example: !http://boinc.netsoft-online.com/get_host.php?cpid=???? and !http://boinc.netsoft-online.com/get_host_tot.php?cpid=???? Application developers are encouraged to concentrate on aggregate rather than per-project data. This will encourage participants to join multiple projects. == Code examples == #code-examples Developing a system that collects, analyzes, and stores credit data from all BOINC projects is a large development task. The code for [http://boinc.netsoft-online.com/ BOINC Combined Stats], a web site/service that provides per-project and aggregate data, can be downloaded via git using {{{ git clone git://boinc.berkeley.edu/boinc-combined-stats.git or git clone http://boinc.berkeley.edu/git/boinc-combined-stats.git }}} == Computing the current value of Recent Average Credit == #rac-decay 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: {{{ function decay_average($avg, $avg_time, $now = 0) { $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. PHP code for the decay function can be found in [source:boinc/html/inc/credit.inc html/inc/credit.inc] and [source:boinc/html/inc/host.inc html/inc/host.inc].