Passed
Push — master ( fb7488...c4e298 )
by Felipe
03:15
created
docs/examples_stats/ex_stats_simple.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,11 +23,11 @@
 block discarded – undo
23 23
  * @package	Math_Stats
24 24
  */
25 25
 
26
-require_once __DIR__ . '/../../vendor/autoload.php';
26
+require_once __DIR__.'/../../vendor/autoload.php';
27 27
 
28 28
 // making some data sets
29
-$data = array (2,2.3,4.5,2,2,3.2,5.3,3,4,5,1,6);
30
-$dnulls = array (1.1650,null, "foo",0.6268, 0.6268, 0.0751, 0.3516, -0.6965);
29
+$data = array(2, 2.3, 4.5, 2, 2, 3.2, 5.3, 3, 4, 5, 1, 6);
30
+$dnulls = array(1.1650, null, "foo", 0.6268, 0.6268, 0.0751, 0.3516, -0.6965);
31 31
 
32 32
 // instantiating a Math_Stats object
33 33
 $s = new \PEAR\Math\Stats();
Please login to merge, or discard this patch.
docs/examples_stats/ex_stats_bigdataset.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
     //require_once 'Math/Stats.php';
3
-   require_once __DIR__ . '/../../vendor/autoload.php';
3
+   require_once __DIR__.'/../../vendor/autoload.php';
4 4
 
5 5
 
6 6
     $data = array();
Please login to merge, or discard this patch.
docs/examples_stats/ex_stats_cummulative_data.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * @package	Math_Stats
24 24
  */
25 25
 
26
-require_once __DIR__ . '/../../vendor/autoload.php';
26
+require_once __DIR__.'/../../vendor/autoload.php';
27 27
 
28 28
 
29 29
 // making some cummulative data sets
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 print_r($dnulls);
47 47
 echo "Generating an error by using data with nulls\n";
48 48
 try {
49
-	print_r($s->setData($dnulls,  \PEAR\Math\Stats::STATS_DATA_CUMMULATIVE));	
49
+	print_r($s->setData($dnulls, \PEAR\Math\Stats::STATS_DATA_CUMMULATIVE));	
50 50
 } catch (\Exception $e) {
51 51
 	echo "\n\t Exception: ".$e->getMessage()."\n\n";
52 52
 }
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
 
55 55
 // let's ignore nulls
56 56
 echo "Ignoring the nulls and trying again\n";
57
-$s->setNullOption( \PEAR\Math\Stats::STATS_IGNORE_NULL);
58
-$s->setData($dnulls,  \PEAR\Math\Stats::STATS_DATA_CUMMULATIVE);
57
+$s->setNullOption(\PEAR\Math\Stats::STATS_IGNORE_NULL);
58
+$s->setData($dnulls, \PEAR\Math\Stats::STATS_DATA_CUMMULATIVE);
59 59
 try {
60 60
 	print_r($s->calcBasic());
61 61
 } catch (\Exception $e) {
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
 
65 65
 // let's assume null == zero
66 66
 echo "Assuming that nulls are zero\n";
67
-$s->setNullOption( \PEAR\Math\Stats::STATS_USE_NULL_AS_ZERO);
68
-$s->setData($dnulls,  \PEAR\Math\Stats::STATS_DATA_CUMMULATIVE);
67
+$s->setNullOption(\PEAR\Math\Stats::STATS_USE_NULL_AS_ZERO);
68
+$s->setData($dnulls, \PEAR\Math\Stats::STATS_DATA_CUMMULATIVE);
69 69
 try {
70 70
 	print_r($s->calcFull());
71 71
 } catch (\Exception $e) {
Please login to merge, or discard this patch.
docs/examples_histogram/ex_histogram_printer.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-require_once __DIR__ . '/../../vendor/autoload.php';;
3
+require_once __DIR__.'/../../vendor/autoload.php'; ;
4 4
 
5 5
 // create a boring array
6 6
 $vals = array(
7
-			1.5,2,3,4,0,3.2,0.1,0,0,5,3,2,3,4,1,2,4,5,1,3,2,4,5,2,3,4,1,2,
8
-			1.5,2,3,4,0,3.2,0.1,0,0,5,3,2,3,4,1,2,4,5,1,3,2,4,5,2,3,4,1,2,
9
-			1.5,2,3,4,0,3.2,0.1,0,0,5,3,2,3,4,1,2,4,5,1,3,2,4,5,2,3,4,1,2
7
+			1.5, 2, 3, 4, 0, 3.2, 0.1, 0, 0, 5, 3, 2, 3, 4, 1, 2, 4, 5, 1, 3, 2, 4, 5, 2, 3, 4, 1, 2,
8
+			1.5, 2, 3, 4, 0, 3.2, 0.1, 0, 0, 5, 3, 2, 3, 4, 1, 2, 4, 5, 1, 3, 2, 4, 5, 2, 3, 4, 1, 2,
9
+			1.5, 2, 3, 4, 0, 3.2, 0.1, 0, 0, 5, 3, 2, 3, 4, 1, 2, 4, 5, 1, 3, 2, 4, 5, 2, 3, 4, 1, 2
10 10
 		);
11 11
 
12 12
 // create an instance 
@@ -27,14 +27,14 @@  discard block
 block discarded – undo
27 27
 
28 28
 // let us read a bigger data set:
29 29
 $data = array();
30
-foreach(file("ex_histogram.data") as $item) {
30
+foreach (file("ex_histogram.data") as $item) {
31 31
 	$data[] = floatval(trim($item));
32 32
 }
33 33
 
34 34
 // let's do a simple histogram
35 35
 $h->setType(\PEAR\Histogram\AbstractHistogram::HISTOGRAM_SIMPLE);
36 36
 // and set new bin options
37
-$h->setBinOptions(20,1.7,2.7);
37
+$h->setBinOptions(20, 1.7, 2.7);
38 38
 // then set a the big data set
39 39
 $h->setData($data);
40 40
 // and calculate using full stats
Please login to merge, or discard this patch.
docs/examples_histogram/ex_histogram3d.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-require_once __DIR__ . '/../../vendor/autoload.php';
3
+require_once __DIR__.'/../../vendor/autoload.php';
4 4
 
5 5
 // let's generate some values;
6
-for ($i=0; $i < 100; $i++) {
7
-	$a['x'][$i] = rand(-1,6);
8
-	$a['y'][$i] = rand(-1,6);
6
+for ($i = 0; $i < 100; $i++) {
7
+	$a['x'][$i] = rand(-1, 6);
8
+	$a['y'][$i] = rand(-1, 6);
9 9
 }
10 10
 
11 11
 $h = new \PEAR\Histogram\Histogram3D();
@@ -19,9 +19,9 @@  discard block
 block discarded – undo
19 19
 // now, let's change the options a wee bit
20 20
 $h->setBinOptions(
21 21
 	array(
22
-		'low' => array( 'x' => 0, 'y' => 0),
23
-		'high' => array( 'x' => 5, 'y' => 5),
24
-		'nbins' => array( 'x' => 5, 'y' => 5)
22
+		'low' => array('x' => 0, 'y' => 0),
23
+		'high' => array('x' => 5, 'y' => 5),
24
+		'nbins' => array('x' => 5, 'y' => 5)
25 25
 		)
26 26
 	);
27 27
 $h->setType(\PEAR\Histogram\AbstractHistogram::HISTOGRAM_CUMMULATIVE);
Please login to merge, or discard this patch.
docs/examples_histogram/ex_histogram4d.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-require_once __DIR__ . '/../../vendor/autoload.php';
3
+require_once __DIR__.'/../../vendor/autoload.php';
4 4
 
5 5
 // let's generate some data
6
-for ($i=0; $i < 100; $i++) {
7
-	$a['x'][$i] = rand(0,4);
8
-	$a['y'][$i] = rand(0,4);
9
-	$a['z'][$i] = rand(0,4);
6
+for ($i = 0; $i < 100; $i++) {
7
+	$a['x'][$i] = rand(0, 4);
8
+	$a['y'][$i] = rand(0, 4);
9
+	$a['z'][$i] = rand(0, 4);
10 10
 }
11 11
 
12 12
 // and create a histogram from the data 
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
 $h = new \PEAR\Histogram\Histogram4D();
15 15
 $h->setBinOptions(
16 16
 	array(
17
-		'low' => array( 'x' => 0, 'y' => 0, 'z'=>0),
18
-		'high' => array( 'x' => 4.0, 'y' => 4.0, 'z'=>4.0),
19
-		'nbins' => array( 'x' => 4, 'y' => 4, 'z'=>4)
17
+		'low' => array('x' => 0, 'y' => 0, 'z'=>0),
18
+		'high' => array('x' => 4.0, 'y' => 4.0, 'z'=>4.0),
19
+		'nbins' => array('x' => 4, 'y' => 4, 'z'=>4)
20 20
 		)
21 21
 	);
22 22
 $h->setData($a);
Please login to merge, or discard this patch.
docs/examples_histogram/ex_histogram.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-require_once __DIR__ . '/../../vendor/autoload.php';
3
+require_once __DIR__.'/../../vendor/autoload.php';
4 4
 
5 5
 // create a boring array
6 6
 $vals = array(
7
-			1.5,2,3,4,0,3.2,0.1,0,0,5,3,2,3,4,1,2,4,5,1,3,2,4,5,2,3,4,1,2,
8
-			1.5,2,3,4,0,3.2,0.1,0,0,5,3,2,3,4,1,2,4,5,1,3,2,4,5,2,3,4,1,2,
9
-			1.5,2,3,4,0,3.2,0.1,0,0,5,3,2,3,4,1,2,4,5,1,3,2,4,5,2,3,4,1,2
7
+			1.5, 2, 3, 4, 0, 3.2, 0.1, 0, 0, 5, 3, 2, 3, 4, 1, 2, 4, 5, 1, 3, 2, 4, 5, 2, 3, 4, 1, 2,
8
+			1.5, 2, 3, 4, 0, 3.2, 0.1, 0, 0, 5, 3, 2, 3, 4, 1, 2, 4, 5, 1, 3, 2, 4, 5, 2, 3, 4, 1, 2,
9
+			1.5, 2, 3, 4, 0, 3.2, 0.1, 0, 0, 5, 3, 2, 3, 4, 1, 2, 4, 5, 1, 3, 2, 4, 5, 2, 3, 4, 1, 2
10 10
 		);
11 11
 
12 12
 // create an instance 
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
23 23
 
24 24
 // let us read a bigger data set:
25 25
 $data = array();
26
-foreach(file(__DIR__."/../../tests/_data/ex_histogram.data") as $item)
26
+foreach (file(__DIR__."/../../tests/_data/ex_histogram.data") as $item)
27 27
 	$data[] = floatval(trim($item));
28 28
 
29 29
 // let's do a simple histogram
30 30
 $h->setType(\PEAR\Histogram\AbstractHistogram::HISTOGRAM_SIMPLE);
31 31
 // and set new bin options
32
-$h->setBinOptions(20,1.7,2.7);
32
+$h->setBinOptions(20, 1.7, 2.7);
33 33
 // then set a the big data set
34 34
 $h->setData($data);
35 35
 // and calculate using full stats
Please login to merge, or discard this patch.
src/Histogram/Histogram.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
         $this->_stats = new \HuasoFoundries\Math\Stats();
117 117
 
118 118
         $this->_statsMode = $statsMode;
119
-        $delta = ($this->_rangeHigh - $this->_rangeLow) / $this->_nbins;
119
+        $delta = ($this->_rangeHigh - $this->_rangeLow)/$this->_nbins;
120 120
         $lastpos = 0;
121 121
         $cumm = 0;
122 122
         $data = $this->_histogramData();
@@ -124,11 +124,11 @@  discard block
 block discarded – undo
124 124
         $ignoreList = array();
125 125
 
126 126
         for ($i = 0; $i < $this->_nbins; $i++) {
127
-            $loBin = $this->_rangeLow + $i * $delta;
127
+            $loBin = $this->_rangeLow + $i*$delta;
128 128
             $hiBin = $loBin + $delta;
129 129
             $this->_bins[$i]["low"] = $loBin;
130 130
             $this->_bins[$i]["high"] = $hiBin;
131
-            $this->_bins[$i]["mid"] = ($hiBin + $loBin) / 2;
131
+            $this->_bins[$i]["mid"] = ($hiBin + $loBin)/2;
132 132
             if ($this->_type == self::HISTOGRAM_CUMMULATIVE) {
133 133
                 $this->_bins[$i]["count"] = $cumm;
134 134
             } else {
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
             $out[] = "{$bin}{$separator}{$freq}";
218 218
         }
219 219
 
220
-        return implode("\n", $out) . "\n";
220
+        return implode("\n", $out)."\n";
221 221
     }
222 222
 
223 223
     /**
@@ -279,11 +279,11 @@  discard block
 block discarded – undo
279 279
             throw new \PEAR_Exception("histogram has not been calculated");
280 280
         }
281 281
         $out = ($this->_type == self::HISTOGRAM_CUMMULATIVE) ? "Cummulative Frequency" : "Histogram";
282
-        $out .= "\n\tNumber of bins: " . $this->_nbins . "\n";
283
-        $out .= "\tPlot range: [" . $this->_rangeLow . ", " . $this->_rangeHigh . "]\n";
282
+        $out .= "\n\tNumber of bins: ".$this->_nbins."\n";
283
+        $out .= "\tPlot range: [".$this->_rangeLow.", ".$this->_rangeHigh."]\n";
284 284
         $hdata = $this->_histogramData();
285
-        $out .= "\tData range: [" . min($hdata) . ", " . max($hdata) . "]\n";
286
-        $out .= "\tOriginal data range: [" . min($this->_data) . ", " . max($this->_data) . "]\n";
285
+        $out .= "\tData range: [".min($hdata).", ".max($hdata)."]\n";
286
+        $out .= "\tOriginal data range: [".min($this->_data).", ".max($this->_data)."]\n";
287 287
         $out .= "BIN (FREQUENCY) ASCII_BAR (%)\n";
288 288
         $fmt = "%-4.3f (%-4d) |%s\n";
289 289
         $bins = $this->_filterBins($mode);
@@ -308,14 +308,14 @@  discard block
 block discarded – undo
308 308
     public function _bar($freq, $maxfreq, $total)
309 309
     {
310 310
 
311
-        $fact = floatval(($maxfreq > 40) ? 40 / $maxfreq : 1);
312
-        $niter = round($freq * $fact);
311
+        $fact = floatval(($maxfreq > 40) ? 40/$maxfreq : 1);
312
+        $niter = round($freq*$fact);
313 313
         $out = "";
314 314
         for ($i = 0; $i < $niter; $i++) {
315 315
             $out .= "*";
316 316
         }
317 317
 
318
-        return $out . sprintf(" (%.1f%%)", $freq / $total * 100);
318
+        return $out.sprintf(" (%.1f%%)", $freq/$total*100);
319 319
 
320 320
     }
321 321
 
Please login to merge, or discard this patch.
src/Histogram/Histogram3D.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
         $this->_bins = array();
113 113
         $this->_stats = array('x' => new \HuasoFoundries\Math\Stats(), 'y' => new \HuasoFoundries\Math\Stats());
114 114
         $this->_statsMode = $statsMode;
115
-        $deltaX = ($this->_rangeHigh['x'] - $this->_rangeLow['x']) / $this->_nbins['x'];
116
-        $deltaY = ($this->_rangeHigh['y'] - $this->_rangeLow['y']) / $this->_nbins['y'];
115
+        $deltaX = ($this->_rangeHigh['x'] - $this->_rangeLow['x'])/$this->_nbins['x'];
116
+        $deltaY = ($this->_rangeHigh['y'] - $this->_rangeLow['y'])/$this->_nbins['y'];
117 117
         $data = $this->_histogramData();
118 118
         //$dataX = $this->_data['x'];
119 119
         //$dataY = $this->_data['y'];
@@ -123,15 +123,15 @@  discard block
 block discarded – undo
123 123
         $cumm = 0;
124 124
         $nData = count($dataX);
125 125
         for ($i = 0; $i < $this->_nbins['x']; $i++) {
126
-            $loXBin = $this->_rangeLow['x'] + $i * $deltaX;
126
+            $loXBin = $this->_rangeLow['x'] + $i*$deltaX;
127 127
             $hiXBin = $loXBin + $deltaX;
128 128
             $xBin = array('low' => $loXBin, 'high' => $hiXBin,
129
-                'mid' => ($hiXBin + $loXBin) / 2);
129
+                'mid' => ($hiXBin + $loXBin)/2);
130 130
             for ($j = 0; $j < $this->_nbins['y']; $j++) {
131
-                $loYBin = $this->_rangeLow['y'] + $j * $deltaY;
131
+                $loYBin = $this->_rangeLow['y'] + $j*$deltaY;
132 132
                 $hiYBin = $loYBin + $deltaY;
133 133
                 $yBin = array('low' => $loYBin, 'high' => $hiYBin,
134
-                    'mid' => ($hiYBin + $loYBin) / 2);
134
+                    'mid' => ($hiYBin + $loYBin)/2);
135 135
                 $bin = array('x' => $xBin, 'y' => $yBin);
136 136
                 $freq = 0;
137 137
                 for ($k = 0; $k < $nData; $k++) {
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
             $out[] = implode($separator, $bins[$i]);
241 241
         }
242 242
 
243
-        return implode("\n", $out) . "\n";
243
+        return implode("\n", $out)."\n";
244 244
     }
245 245
 
246 246
     /**
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
             && is_array($binOptions['low'])
301 301
             && is_array($binOptions['high'])
302 302
             && is_array($binOptions['nbins']));
303
-        if(!$barray) {
303
+        if (!$barray) {
304 304
             return false;
305 305
         }
306 306
         $low = $binOptions['low'];
Please login to merge, or discard this patch.