Skip to content

Commit 4338a7f

Browse files
committed
Code quality enhancements
- Refactored PHP code quality tools in package.json - Updated file documentation - Improved docbloc formatting - Fix whitespacing in Math stuff
1 parent 7a7efae commit 4338a7f

File tree

5 files changed

+242
-152
lines changed

5 files changed

+242
-152
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ The result array contains additional information like the data range 𝑹, the i
123123
Simple rule using the square root of the sample size.
124124

125125
$$
126-
k = \left \lceil \sqrt{n} \; \right \rceil
126+
k = \left \lceil \sqrt{n} \ \right \rceil
127127
$$
128128

129129
```php
@@ -141,7 +141,7 @@ $k = BinSelection::squareRoot($data);
141141
Based on the logarithm of the sample size. Good for normal distributions.
142142

143143
$$
144-
k = 1 + \left \lceil \; \log_2(n) \; \right \rceil
144+
k = 1 + \left \lceil \ \log_2(n) \ \right \rceil
145145
$$
146146

147147
```php
@@ -159,7 +159,7 @@ $k = BinSelection::sturges($data);
159159
Improvement of *Sturges*’ rule that accounts for data skewness.
160160

161161
$$
162-
k = 1 + \left\lceil \; \log_2(n) + \log_2\left(1 + \frac{|g_1|}{\sigma_{g_1}}\right) \; \right \rceil
162+
k = 1 + \left\lceil \ \log_2(n) + \log_2\left(1 + \frac{|g_1|}{\sigma_{g_1}}\right) \ \right \rceil
163163
$$
164164

165165
```php
@@ -189,7 +189,7 @@ R = \max_i x_i - \min_i x_i
189189
$$
190190

191191
$$
192-
k = \left \lceil \frac{R}{h} \right \rceil
192+
k = \left \lceil \ \frac{R}{h} \ \right \rceil
193193
$$
194194

195195
The result is an array with keys `width`, `bins`, `range`, and `stddev`. Map them to variables like so:
@@ -241,7 +241,7 @@ list($h, $k, $R, $IQR) = BinSelection::freedmanDiaconis($data);
241241
Uses the cube root of the sample size, generally provides more bins than *Sturges*. This is the original *Rice Rule*:
242242

243243
$$
244-
k = \left \lceil \; \sqrt[3]{2n} \enspace \right \rceil = \left \lceil \; (2n)^{1/3} \; \right \rceil
244+
k = \left \lceil \ \sqrt[3]{2n} \enspace \right \rceil = \left \lceil \ (2n)^{1/3} \ \right \rceil
245245
$$
246246

247247
```php
@@ -259,7 +259,7 @@ $k = BinSelection::terrellScott($data);
259259
Uses the cube root of the sample size, generally provides more bins than *Sturges*. Formula as taught by David M. Lane at Rice University. — **N.B.** This *Rice Rule* seems to be not the original. In fact, *Terrell-Scott’s* (1985) seems to be. Also note that both variants can yield different results under certain circumstances. This Lane’s variant from the early 2000s is however more commonly cited:
260260

261261
$$
262-
k = 2 \times \left \lceil \; \sqrt[3]{n} \enspace \right \rceil = 2 \times \left \lceil \; n^{1/3} \; \right \rceil
262+
k = 2 \times \left \lceil \ \sqrt[3]{n} \enspace \right \rceil = 2 \times \left \lceil \ n^{1/3} \ \right \rceil
263263
$$
264264

265265
```php

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@
88
"watch": "npm-run-all -p watch:*",
99
"watch:src": "chokidar \"src/**/*.php\" -c \"./vendor/bin/frt {path} && npm run phpstan {path} && npm run rector {path}\"",
1010
"watch:tests": "chokidar \"tests/**/*.php\" -c \"npm run phpunit:short {path}\"",
11+
1112
"phpstan": "./vendor/bin/phpstan --no-progress analyse",
12-
"phpcs": "./vendor/bin/php-cs-fixer fix --verbose --diff --dry-run",
13+
14+
"phpcs": "npm run phpcs:apply -- --dry-run",
1315
"phpcs:apply": "./vendor/bin/php-cs-fixer fix --verbose --diff",
14-
"rector": "./vendor/bin/rector process --dry-run",
16+
17+
"rector": "npm run rector:apply -- --dry-run",
1518
"rector:apply": "./vendor/bin/rector process",
19+
1620
"phpunit": "./vendor/bin/phpunit --testdox",
1721
"phpunit:short": "npm run phpunit -- --no-coverage"
1822
},

phpstan.neon.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ parameters:
66
level: 9
77
paths:
88
- src
9+
- tests
910

0 commit comments

Comments
 (0)