MediaWiki  1.23.8
RunningStatTest.php
Go to the documentation of this file.
1 <?php
7 
8  public $points = array(
9  49.7168, 74.3804, 7.0115, 96.5769, 34.9458,
10  36.9947, 33.8926, 89.0774, 23.7745, 73.5154,
11  86.1322, 53.2124, 16.2046, 73.5130, 10.4209,
12  42.7299, 49.3330, 47.0215, 34.9950, 18.2914,
13  );
14 
24  public function testRunningStatAccuracy() {
25  $rstat = new RunningStat();
26  foreach( $this->points as $point ) {
27  $rstat->push( $point );
28  }
29 
30  $mean = array_sum( $this->points ) / count( $this->points );
31  $variance = array_sum( array_map( function ( $x ) use ( $mean ) {
32  return pow( $mean - $x, 2 );
33  }, $this->points ) ) / ( count( $rstat ) - 1 );
34  $stddev = sqrt( $variance );
35 
36  $this->assertEquals( count( $rstat ), count( $this->points ) );
37  $this->assertEquals( $rstat->min, min( $this->points ) );
38  $this->assertEquals( $rstat->max, max( $this->points ) );
39  $this->assertEquals( $rstat->getMean(), $mean );
40  $this->assertEquals( $rstat->getVariance(), $variance );
41  $this->assertEquals( $rstat->getStdDev(), $stddev );
42  }
43 
51  public function testRunningStatMerge() {
52  $expected = new RunningStat();
53 
54  foreach( $this->points as $point ) {
55  $expected->push( $point );
56  }
57 
58  // Split the data into two sets
59  $sets = array_chunk( $this->points, floor( count( $this->points ) / 2 ) );
60 
61  // Accumulate the first half into one RunningStat object
62  $first = new RunningStat();
63  foreach( $sets[0] as $point ) {
64  $first->push( $point );
65  }
66 
67  // Accumulate the second half into another RunningStat object
68  $second = new RunningStat();
69  foreach( $sets[1] as $point ) {
70  $second->push( $point );
71  }
72 
73  // Merge the second RunningStat object into the first
74  $first->merge( $second );
75 
76  $this->assertEquals( count( $first ), count( $this->points ) );
77  $this->assertEquals( $first, $expected );
78  }
79 }
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
RunningStat
Represents a running summary of a stream of numbers.
Definition: RunningStat.php:52
RunningStatTest\$points
$points
Definition: RunningStatTest.php:8
MediaWikiTestCase
Definition: MediaWikiTestCase.php:6
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
RunningStatTest\testRunningStatMerge
testRunningStatMerge()
When one RunningStat instance is merged into another, the state of the target RunningInstance should ...
Definition: RunningStatTest.php:51
RunningStatTest\testRunningStatAccuracy
testRunningStatAccuracy()
Verify that the statistical moments and extrema computed by RunningStat match expected values.
Definition: RunningStatTest.php:24
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
RunningStatTest
PHP Unit tests for RunningStat class.
Definition: RunningStatTest.php:6