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.
Files changed (2) hide show
  1. package/README.md +72 -119
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,134 +1,87 @@
1
- # Pragmastat TypeScript Implementation
1
+ # Pragmastat
2
2
 
3
- [![DOI](https://zenodo.org/badge/doi/10.5281/zenodo.17236778.svg)](https://doi.org/10.5281/zenodo.17236778)
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 install pragmastat
9
+ npm i pragmastat
11
10
  ```
12
11
 
13
- ## Usage
12
+ ## Demo
14
13
 
15
14
  ```typescript
16
- import {
17
- center,
18
- spread,
19
- relSpread,
20
- shift,
21
- ratio,
22
- avgSpread,
23
- disparity
24
- } from 'pragmastat';
25
-
26
- // One-sample estimators
27
- const data = [1, 2, 3, 4, 5];
28
- console.log('Center:', center(data));
29
- console.log('Spread:', spread(data));
30
- console.log('RelSpread:', relSpread(data));
31
-
32
- // Two-sample estimators
33
- const x = [1, 2, 3];
34
- const y = [4, 5, 6];
35
- console.log('Shift:', shift(x, y));
36
- console.log('Ratio:', ratio(x, y));
37
- console.log('AvgSpread:', avgSpread(x, y));
38
- console.log('Disparity:', disparity(x, y));
39
- ```
40
-
41
- ## Estimators
42
-
43
- ### One-Sample Estimators
44
-
45
- - **center**: Hodges-Lehmann location estimator - robust measure of average
46
- - **spread**: Shamos scale estimator - robust measure of dispersion
47
- - **relSpread**: Relative dispersion measure - spread normalized by center
48
-
49
- ### Two-Sample Estimators
50
-
51
- - **shift**: Hodges-Lehmann shift estimator - robust measure of location difference
52
- - **ratio**: Robust ratio estimator - median of all pairwise ratios
53
- - **avgSpread**: Pooled spread estimator - combined measure of dispersion
54
- - **disparity**: Effect size measure - normalized difference between samples
55
-
56
- ## Development
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
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
- ### 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
- ```
66
+ ## The MIT License
93
67
 
94
- ### Build Script
68
+ Copyright (c) 2025 Andrey Akinshin
95
69
 
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
- ```
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
- ## License
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
- This project is licensed under the MIT License - see the LICENSE file for details.
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pragmastat",
3
- "version": "3.1.10",
3
+ "version": "3.1.11",
4
4
  "description": "Pragmastat: Pragmatic Statistical Toolkit",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",