pragmastat 3.1.10 → 3.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -118
- package/package.json +2 -6
package/README.md
CHANGED
|
@@ -1,134 +1,91 @@
|
|
|
1
|
-
# Pragmastat
|
|
1
|
+
# Pragmastat
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This is a TypeScript implementation of 'Pragmastat: Pragmatic Statistical Toolkit', which presents a toolkit of statistical procedures that provide reliable results across diverse real-world distributions, with ready-to-use implementations and detailed explanations.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
- PDF manual for this version: https://pragmastat.dev/pragmastat-v3.1.12.pdf
|
|
6
|
+
- Online manual for the latest version: https://pragmastat.dev
|
|
7
|
+
- Manual DOI: [10.5281/zenodo.17236778](https://doi.org/10.5281/zenodo.17236778)
|
|
8
|
+
- Source code: https://github.com/AndreyAkinshin/pragmastat/tree/v3.1.12/ts
|
|
6
9
|
|
|
7
10
|
## Installation
|
|
8
11
|
|
|
9
12
|
```bash
|
|
10
|
-
npm
|
|
13
|
+
npm i pragmastat
|
|
11
14
|
```
|
|
12
15
|
|
|
13
|
-
##
|
|
16
|
+
## Demo
|
|
14
17
|
|
|
15
18
|
```typescript
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
console.log(
|
|
29
|
-
console.log(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
console.log(
|
|
36
|
-
console.log(
|
|
37
|
-
|
|
38
|
-
|
|
19
|
+
import { center, spread, relSpread, shift, ratio, avgSpread, disparity } from '../src';
|
|
20
|
+
|
|
21
|
+
function main() {
|
|
22
|
+
let x = [0, 2, 4, 6, 8];
|
|
23
|
+
console.log(center(x)); // 4
|
|
24
|
+
console.log(center(x.map(v => v + 10))); // 14
|
|
25
|
+
console.log(center(x.map(v => v * 3))); // 12
|
|
26
|
+
|
|
27
|
+
console.log(spread(x)); // 4
|
|
28
|
+
console.log(spread(x.map(v => v + 10))); // 4
|
|
29
|
+
console.log(spread(x.map(v => v * 2))); // 8
|
|
30
|
+
|
|
31
|
+
console.log(relSpread(x)); // 1
|
|
32
|
+
console.log(relSpread(x.map(v => v * 5))); // 1
|
|
33
|
+
|
|
34
|
+
let y = [10, 12, 14, 16, 18];
|
|
35
|
+
console.log(shift(x, y)); // -10
|
|
36
|
+
console.log(shift(x, x)); // 0
|
|
37
|
+
console.log(shift(x.map(v => v + 7), y.map(v => v + 3))); // -6
|
|
38
|
+
console.log(shift(x.map(v => v * 2), y.map(v => v * 2))); // -20
|
|
39
|
+
console.log(shift(y, x)); // 10
|
|
40
|
+
|
|
41
|
+
x = [1, 2, 4, 8, 16];
|
|
42
|
+
y = [2, 4, 8, 16, 32];
|
|
43
|
+
console.log(ratio(x, y)); // 0.5
|
|
44
|
+
console.log(ratio(x, x)); // 1
|
|
45
|
+
console.log(ratio(x.map(v => v * 2), y.map(v => v * 5))); // 0.2
|
|
46
|
+
|
|
47
|
+
x = [0, 3, 6, 9, 12];
|
|
48
|
+
y = [0, 2, 4, 6, 8];
|
|
49
|
+
console.log(spread(x)); // 6
|
|
50
|
+
console.log(spread(y)); // 4
|
|
51
|
+
|
|
52
|
+
console.log(avgSpread(x, y)); // 5
|
|
53
|
+
console.log(avgSpread(x, x)); // 6
|
|
54
|
+
console.log(avgSpread(x.map(v => v * 2), x.map(v => v * 3))); // 15
|
|
55
|
+
console.log(avgSpread(y, x)); // 5
|
|
56
|
+
console.log(avgSpread(x.map(v => v * 2), y.map(v => v * 2))); // 10
|
|
57
|
+
|
|
58
|
+
console.log(shift(x, y)); // 2
|
|
59
|
+
console.log(avgSpread(x, y)); // 5
|
|
60
|
+
|
|
61
|
+
console.log(disparity(x, y)); // 0.4
|
|
62
|
+
console.log(disparity(x.map(v => v + 5), y.map(v => v + 5))); // 0.4
|
|
63
|
+
console.log(disparity(x.map(v => v * 2), y.map(v => v * 2))); // 0.4
|
|
64
|
+
console.log(disparity(y, x)); // -0.4
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
main();
|
|
39
68
|
```
|
|
40
69
|
|
|
41
|
-
##
|
|
70
|
+
## The MIT License
|
|
42
71
|
|
|
43
|
-
|
|
72
|
+
Copyright (c) 2025 Andrey Akinshin
|
|
44
73
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
74
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
75
|
+
a copy of this software and associated documentation files (the
|
|
76
|
+
"Software"), to deal in the Software without restriction, including
|
|
77
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
78
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
79
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
80
|
+
the following conditions:
|
|
48
81
|
|
|
49
|
-
|
|
82
|
+
The above copyright notice and this permission notice shall be
|
|
83
|
+
included in all copies or substantial portions of the Software.
|
|
50
84
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
### Building
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
# Build TypeScript to JavaScript
|
|
62
|
-
npm run build
|
|
63
|
-
|
|
64
|
-
# Or use the build script
|
|
65
|
-
./build.sh build
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### Testing
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
# Run all tests
|
|
72
|
-
npm test
|
|
73
|
-
|
|
74
|
-
# Run tests with coverage
|
|
75
|
-
npm run test:coverage
|
|
76
|
-
|
|
77
|
-
# Run tests in watch mode
|
|
78
|
-
npm run test:watch
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### Code Quality
|
|
82
|
-
|
|
83
|
-
```bash
|
|
84
|
-
# Run ESLint
|
|
85
|
-
npm run lint
|
|
86
|
-
|
|
87
|
-
# Format code with Prettier
|
|
88
|
-
npm run format
|
|
89
|
-
|
|
90
|
-
# Check formatting
|
|
91
|
-
npm run format:check
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### Build Script
|
|
95
|
-
|
|
96
|
-
The `build.sh` script provides convenient commands:
|
|
97
|
-
|
|
98
|
-
```bash
|
|
99
|
-
./build.sh test # Run all tests
|
|
100
|
-
./build.sh build # Build TypeScript to JavaScript
|
|
101
|
-
./build.sh check # Run linting and format checking
|
|
102
|
-
./build.sh clean # Clean build artifacts
|
|
103
|
-
./build.sh format # Format code with Prettier
|
|
104
|
-
./build.sh install # Install npm dependencies
|
|
105
|
-
./build.sh coverage # Run tests with coverage report
|
|
106
|
-
./build.sh watch # Run tests in watch mode
|
|
107
|
-
./build.sh all # Run all tasks
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
## Project Structure
|
|
111
|
-
|
|
112
|
-
```
|
|
113
|
-
ts/
|
|
114
|
-
├── src/ # Source code
|
|
115
|
-
│ ├── index.ts # Main entry point
|
|
116
|
-
│ ├── estimators.ts # Estimator implementations
|
|
117
|
-
│ └── utils.ts # Utility functions
|
|
118
|
-
├── tests/ # Test files
|
|
119
|
-
│ ├── estimators.test.ts # Unit tests
|
|
120
|
-
│ ├── invariance.test.ts # Mathematical invariance tests
|
|
121
|
-
│ └── reference.test.ts # Reference tests against JSON data
|
|
122
|
-
├── dist/ # Compiled JavaScript (generated)
|
|
123
|
-
├── package.json # NPM package configuration
|
|
124
|
-
├── tsconfig.json # TypeScript configuration
|
|
125
|
-
├── jest.config.js # Jest test configuration
|
|
126
|
-
├── .eslintrc.js # ESLint configuration
|
|
127
|
-
├── .prettierrc # Prettier configuration
|
|
128
|
-
├── build.sh # Build script
|
|
129
|
-
└── README.md # This file
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
## License
|
|
133
|
-
|
|
134
|
-
This project is licensed under the MIT License - see the LICENSE file for details.
|
|
85
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
88
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
89
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
90
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
91
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pragmastat",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.12",
|
|
4
4
|
"description": "Pragmastat: Pragmatic Statistical Toolkit",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -16,11 +16,7 @@
|
|
|
16
16
|
"prepublishOnly": "npm run clean && npm run build && npm run test"
|
|
17
17
|
},
|
|
18
18
|
"keywords": [
|
|
19
|
-
"statistics"
|
|
20
|
-
"robust",
|
|
21
|
-
"estimators",
|
|
22
|
-
"median",
|
|
23
|
-
"hodges-lehmann"
|
|
19
|
+
"statistics"
|
|
24
20
|
],
|
|
25
21
|
"author": "Andrey Akinshin",
|
|
26
22
|
"license": "MIT",
|