pragmastat 3.1.10 → 3.1.11
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 +72 -119
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,134 +1,87 @@
|
|
|
1
|
-
# Pragmastat
|
|
1
|
+
# Pragmastat
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
This is the TypeScript implementation of Pragmastat, a pragmatic statistical toolkit designed for analyzing real-world data.
|
|
3
|
+
A TypeScript implementation of 'Pragmastat: Pragmatic Statistical Toolkit' - robust summary estimators designed for real-world data analysis.
|
|
4
|
+
Online manual: https://pragmastat.dev
|
|
6
5
|
|
|
7
6
|
## Installation
|
|
8
7
|
|
|
9
8
|
```bash
|
|
10
|
-
npm
|
|
9
|
+
npm i pragmastat
|
|
11
10
|
```
|
|
12
11
|
|
|
13
|
-
##
|
|
12
|
+
## Demo
|
|
14
13
|
|
|
15
14
|
```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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
|
15
|
+
import { center, spread, relSpread, shift, ratio, avgSpread, disparity } from '../src';
|
|
16
|
+
|
|
17
|
+
function main() {
|
|
18
|
+
let x = [0, 2, 4, 6, 8];
|
|
19
|
+
console.log(center(x)); // 4
|
|
20
|
+
console.log(center(x.map(v => v + 10))); // 14
|
|
21
|
+
console.log(center(x.map(v => v * 3))); // 12
|
|
22
|
+
|
|
23
|
+
console.log(spread(x)); // 4
|
|
24
|
+
console.log(spread(x.map(v => v + 10))); // 4
|
|
25
|
+
console.log(spread(x.map(v => v * 2))); // 8
|
|
26
|
+
|
|
27
|
+
console.log(relSpread(x)); // 1
|
|
28
|
+
console.log(relSpread(x.map(v => v * 5))); // 1
|
|
29
|
+
|
|
30
|
+
let y = [10, 12, 14, 16, 18];
|
|
31
|
+
console.log(shift(x, y)); // -10
|
|
32
|
+
console.log(shift(x, x)); // 0
|
|
33
|
+
console.log(shift(x.map(v => v + 7), y.map(v => v + 3))); // -6
|
|
34
|
+
console.log(shift(x.map(v => v * 2), y.map(v => v * 2))); // -20
|
|
35
|
+
console.log(shift(y, x)); // 10
|
|
36
|
+
|
|
37
|
+
x = [1, 2, 4, 8, 16];
|
|
38
|
+
y = [2, 4, 8, 16, 32];
|
|
39
|
+
console.log(ratio(x, y)); // 0.5
|
|
40
|
+
console.log(ratio(x, x)); // 1
|
|
41
|
+
console.log(ratio(x.map(v => v * 2), y.map(v => v * 5))); // 0.2
|
|
42
|
+
|
|
43
|
+
x = [0, 3, 6, 9, 12];
|
|
44
|
+
y = [0, 2, 4, 6, 8];
|
|
45
|
+
console.log(spread(x)); // 6
|
|
46
|
+
console.log(spread(y)); // 4
|
|
47
|
+
|
|
48
|
+
console.log(avgSpread(x, y)); // 5
|
|
49
|
+
console.log(avgSpread(x, x)); // 6
|
|
50
|
+
console.log(avgSpread(x.map(v => v * 2), x.map(v => v * 3))); // 15
|
|
51
|
+
console.log(avgSpread(y, x)); // 5
|
|
52
|
+
console.log(avgSpread(x.map(v => v * 2), y.map(v => v * 2))); // 10
|
|
53
|
+
|
|
54
|
+
console.log(shift(x, y)); // 2
|
|
55
|
+
console.log(avgSpread(x, y)); // 5
|
|
56
|
+
|
|
57
|
+
console.log(disparity(x, y)); // 0.4
|
|
58
|
+
console.log(disparity(x.map(v => v + 5), y.map(v => v + 5))); // 0.4
|
|
59
|
+
console.log(disparity(x.map(v => v * 2), y.map(v => v * 2))); // 0.4
|
|
60
|
+
console.log(disparity(y, x)); // -0.4
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
main();
|
|
79
64
|
```
|
|
80
65
|
|
|
81
|
-
|
|
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
|
-
```
|
|
66
|
+
## The MIT License
|
|
93
67
|
|
|
94
|
-
|
|
68
|
+
Copyright (c) 2025 Andrey Akinshin
|
|
95
69
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
```
|
|
70
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
71
|
+
a copy of this software and associated documentation files (the
|
|
72
|
+
"Software"), to deal in the Software without restriction, including
|
|
73
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
74
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
75
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
76
|
+
the following conditions:
|
|
131
77
|
|
|
132
|
-
|
|
78
|
+
The above copyright notice and this permission notice shall be
|
|
79
|
+
included in all copies or substantial portions of the Software.
|
|
133
80
|
|
|
134
|
-
|
|
81
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
82
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
83
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
84
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
85
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
86
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
87
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|