@cloudglides/nox 1.1.5 → 2.0.0
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 +9 -9
- package/example/src/App.css +89 -84
- package/example/src/App.jsx +375 -151
- package/package.json +7 -6
- package/src/core.browser.js +10 -2
- package/src/core.js +32 -4
- package/src/generators/logistic.js +30 -25
- package/src/generators/mixer.js +7 -7
- package/src/generators/mt19937.js +10 -7
- package/src/generators/pcg64.js +23 -12
- package/src/generators/splitmix64.js +12 -6
- package/src/generators/tent.js +12 -7
- package/src/generators/xorshift64.js +6 -3
- package/src/index.d.ts +68 -4
- package/src/index.js +154 -2
- package/src/rng.browser.js +21 -10
- package/src/rng.js +95 -82
- package/src/utils/arrays.js +149 -0
- package/src/utils/bits.js +146 -21
- package/src/utils/categorical.js +68 -31
- package/src/utils/combinatorics.js +113 -69
- package/src/utils/confidence.js +145 -0
- package/src/utils/decomposition.js +204 -0
- package/src/utils/distributions-advanced.js +122 -0
- package/src/utils/distributions-extra.js +102 -11
- package/src/utils/distributions-special.js +77 -20
- package/src/utils/distributions.js +99 -35
- package/src/utils/effects.js +172 -0
- package/src/utils/entropy.browser.js +29 -26
- package/src/utils/entropy.js +18 -8
- package/src/utils/helpers.js +64 -0
- package/src/utils/hypothesis.js +167 -0
- package/src/utils/integration.js +137 -0
- package/src/utils/interpolation.js +221 -0
- package/src/utils/matrix.js +242 -0
- package/src/utils/noise.js +36 -22
- package/src/utils/odesolvers.js +176 -0
- package/src/utils/optimization.js +215 -0
- package/src/utils/precomputed.js +166 -0
- package/src/utils/probability.js +199 -0
- package/src/utils/regression.js +170 -0
- package/src/utils/resampling.js +112 -0
- package/src/utils/rootfinding.js +158 -0
- package/src/utils/sampling.js +86 -77
- package/src/utils/seed.js +10 -4
- package/src/utils/seeding.js +24 -12
- package/src/utils/sequence.js +116 -32
- package/src/utils/state.js +48 -36
- package/src/utils/statistics.js +64 -2
- package/src/utils/stochastic.js +91 -31
- package/src/utils/stratified.js +108 -0
- package/src/utils/timeseries.js +166 -0
- package/src/utils/transforms.js +146 -0
- package/test/comprehensive-new.js +126 -0
- package/test/comprehensive.js +4 -3
- package/test/error-handling.js +49 -0
- package/test/new-features.js +52 -0
- package/IMPROVEMENTS.md +0 -58
package/README.md
CHANGED
|
@@ -5,13 +5,13 @@ Simple, unpredictable random number generator.
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install nox
|
|
8
|
+
npm install @cloudglides/nox
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Quick Start
|
|
12
12
|
|
|
13
13
|
```javascript
|
|
14
|
-
import { rng, deterministic } from 'nox';
|
|
14
|
+
import { rng, deterministic } from '@cloudglides/nox';
|
|
15
15
|
|
|
16
16
|
const r = rng();
|
|
17
17
|
|
|
@@ -31,7 +31,7 @@ r.bools(5); // [true, false, true, ...]
|
|
|
31
31
|
## Reproducible
|
|
32
32
|
|
|
33
33
|
```javascript
|
|
34
|
-
import { deterministic } from 'nox';
|
|
34
|
+
import { deterministic } from '@cloudglides/nox';
|
|
35
35
|
|
|
36
36
|
const r = deterministic(42);
|
|
37
37
|
// Always same sequence
|
|
@@ -40,7 +40,7 @@ const r = deterministic(42);
|
|
|
40
40
|
## Distributions
|
|
41
41
|
|
|
42
42
|
```javascript
|
|
43
|
-
import { rng, normal, exponential, uniform, poisson } from 'nox';
|
|
43
|
+
import { rng, normal, exponential, uniform, poisson } from '@cloudglides/nox';
|
|
44
44
|
|
|
45
45
|
const r = rng();
|
|
46
46
|
|
|
@@ -53,7 +53,7 @@ poisson(r, lambda=5);
|
|
|
53
53
|
## Sampling
|
|
54
54
|
|
|
55
55
|
```javascript
|
|
56
|
-
import { rng, shuffle, pick, sample } from 'nox';
|
|
56
|
+
import { rng, shuffle, pick, sample } from '@cloudglides/nox';
|
|
57
57
|
|
|
58
58
|
const r = rng();
|
|
59
59
|
|
|
@@ -65,7 +65,7 @@ sample([1, 2, 3, 4, 5], 3, r);
|
|
|
65
65
|
## State
|
|
66
66
|
|
|
67
67
|
```javascript
|
|
68
|
-
import { rng, saveState, restoreState } from 'nox';
|
|
68
|
+
import { rng, saveState, restoreState } from '@cloudglides/nox';
|
|
69
69
|
|
|
70
70
|
const r = rng();
|
|
71
71
|
const snapshot = saveState(r);
|
|
@@ -78,7 +78,7 @@ r.nextFloat(); // Same value
|
|
|
78
78
|
## Weighted Sampling
|
|
79
79
|
|
|
80
80
|
```javascript
|
|
81
|
-
import { rng, weightedPick, reservoirSample } from 'nox';
|
|
81
|
+
import { rng, weightedPick, reservoirSample } from '@cloudglides/nox';
|
|
82
82
|
|
|
83
83
|
const r = rng();
|
|
84
84
|
const items = ['A', 'B', 'C'];
|
|
@@ -91,7 +91,7 @@ reservoirSample(stream, k, r); // Sample k from large stream
|
|
|
91
91
|
## Statistical Tests
|
|
92
92
|
|
|
93
93
|
```javascript
|
|
94
|
-
import { rng, meanTest, varianceTest, kolmogorovSmirnovTest } from 'nox';
|
|
94
|
+
import { rng, meanTest, varianceTest, kolmogorovSmirnovTest } from '@cloudglides/nox';
|
|
95
95
|
|
|
96
96
|
const r = rng();
|
|
97
97
|
const data = r.floats(1000);
|
|
@@ -106,7 +106,7 @@ const ks = kolmogorovSmirnovTest(data); // Test uniform distribution
|
|
|
106
106
|
For reproducible results or specific generator properties:
|
|
107
107
|
|
|
108
108
|
```javascript
|
|
109
|
-
import { RNG, PCG64, MT19937, Xorshift64, Splitmix64 } from 'nox';
|
|
109
|
+
import { RNG, PCG64, MT19937, Xorshift64, Splitmix64 } from '@cloudglides/nox';
|
|
110
110
|
|
|
111
111
|
const r = new RNG(PCG64, seed); // PCG64 (default, fast, high quality)
|
|
112
112
|
const r = new RNG(MT19937, seed); // MT19937 (Mersenne Twister)
|
package/example/src/App.css
CHANGED
|
@@ -3,58 +3,77 @@
|
|
|
3
3
|
min-height: 100vh;
|
|
4
4
|
display: flex;
|
|
5
5
|
flex-direction: column;
|
|
6
|
-
background: #
|
|
7
|
-
|
|
6
|
+
background: #fff;
|
|
7
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
header {
|
|
11
|
-
padding: 2rem
|
|
11
|
+
padding: 2rem;
|
|
12
12
|
text-align: center;
|
|
13
|
-
border-bottom: 1px solid #
|
|
13
|
+
border-bottom: 1px solid #ddd;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
header h1 {
|
|
17
|
-
font-size:
|
|
18
|
-
margin
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
letter-spacing: -0.5px;
|
|
17
|
+
font-size: 2.5rem;
|
|
18
|
+
margin: 0 0 0.3rem 0;
|
|
19
|
+
font-weight: 700;
|
|
20
|
+
letter-spacing: -1px;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
header p {
|
|
25
|
-
font-size: 0.95rem;
|
|
26
|
-
color: #333333;
|
|
27
24
|
margin: 0;
|
|
25
|
+
color: #666;
|
|
26
|
+
font-size: 0.95rem;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.tabs-container {
|
|
30
|
+
padding: 1.5rem 2rem;
|
|
31
|
+
border-bottom: 1px solid #eee;
|
|
32
|
+
max-width: 1200px;
|
|
33
|
+
margin: 0 auto;
|
|
34
|
+
width: 100%;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.category {
|
|
38
|
+
margin-bottom: 1.5rem;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.category:last-child {
|
|
42
|
+
margin-bottom: 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.category h3 {
|
|
46
|
+
font-size: 0.9rem;
|
|
47
|
+
font-weight: 600;
|
|
48
|
+
color: #666;
|
|
49
|
+
margin: 0 0 0.6rem 0;
|
|
50
|
+
text-transform: uppercase;
|
|
51
|
+
letter-spacing: 0.5px;
|
|
28
52
|
}
|
|
29
53
|
|
|
30
54
|
.tabs {
|
|
31
55
|
display: flex;
|
|
32
|
-
gap:
|
|
33
|
-
padding: 1.5rem 2rem;
|
|
34
|
-
justify-content: center;
|
|
56
|
+
gap: 0.5rem;
|
|
35
57
|
flex-wrap: wrap;
|
|
36
|
-
border-bottom: 1px solid #e0e0e0;
|
|
37
58
|
}
|
|
38
59
|
|
|
39
60
|
.tabs button {
|
|
40
|
-
padding: 0.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
border-radius: 0;
|
|
61
|
+
padding: 0.5rem 1rem;
|
|
62
|
+
border: 1px solid #000;
|
|
63
|
+
background: #fff;
|
|
44
64
|
cursor: pointer;
|
|
45
|
-
|
|
46
|
-
color: #000000;
|
|
47
|
-
background: #ffffff;
|
|
65
|
+
font-size: 0.85rem;
|
|
48
66
|
font-weight: 500;
|
|
67
|
+
transition: 0.15s;
|
|
49
68
|
}
|
|
50
69
|
|
|
51
70
|
.tabs button:hover {
|
|
52
71
|
background: #f5f5f5;
|
|
53
72
|
}
|
|
54
73
|
|
|
55
|
-
.tabs button
|
|
56
|
-
|
|
57
|
-
|
|
74
|
+
.tabs button:active {
|
|
75
|
+
background: #000;
|
|
76
|
+
color: #fff;
|
|
58
77
|
}
|
|
59
78
|
|
|
60
79
|
.content {
|
|
@@ -65,105 +84,91 @@ header p {
|
|
|
65
84
|
width: 100%;
|
|
66
85
|
}
|
|
67
86
|
|
|
68
|
-
.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
border: 1px solid #e0e0e0;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.section h2 {
|
|
75
|
-
margin-bottom: 1.5rem;
|
|
76
|
-
color: #000000;
|
|
77
|
-
font-size: 1.3rem;
|
|
87
|
+
.content h2 {
|
|
88
|
+
font-size: 1.2rem;
|
|
89
|
+
margin: 0 0 1.5rem 0;
|
|
78
90
|
font-weight: 600;
|
|
79
91
|
}
|
|
80
92
|
|
|
81
|
-
.action-btn {
|
|
82
|
-
background: #000000;
|
|
83
|
-
color: #ffffff;
|
|
84
|
-
padding: 0.7rem 1.8rem;
|
|
85
|
-
font-size: 0.9rem;
|
|
86
|
-
border: none;
|
|
87
|
-
border-radius: 0;
|
|
88
|
-
cursor: pointer;
|
|
89
|
-
font-weight: 500;
|
|
90
|
-
transition: all 0.2s;
|
|
91
|
-
margin-bottom: 1.5rem;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
.action-btn:hover {
|
|
95
|
-
background: #333333;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
.action-btn:active {
|
|
99
|
-
background: #000000;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
93
|
.results {
|
|
103
94
|
background: #f8f8f8;
|
|
104
95
|
padding: 1.5rem;
|
|
105
|
-
border: 1px solid #
|
|
106
|
-
border-left: 3px solid #000000;
|
|
107
|
-
margin-top: 1rem;
|
|
96
|
+
border: 1px solid #ddd;
|
|
108
97
|
font-family: 'Courier New', monospace;
|
|
109
98
|
font-size: 0.9rem;
|
|
110
|
-
word-break: break-all;
|
|
111
99
|
}
|
|
112
100
|
|
|
113
|
-
.
|
|
101
|
+
.result-row {
|
|
102
|
+
display: flex;
|
|
103
|
+
align-items: baseline;
|
|
104
|
+
gap: 0.8rem;
|
|
114
105
|
margin: 0.6rem 0;
|
|
115
|
-
line-height: 1.5;
|
|
116
|
-
color: #000000;
|
|
117
106
|
}
|
|
118
107
|
|
|
119
|
-
.
|
|
120
|
-
color: #000000;
|
|
108
|
+
.result-row .label {
|
|
121
109
|
font-weight: 600;
|
|
110
|
+
min-width: 140px;
|
|
111
|
+
color: #333;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.result-row .value {
|
|
115
|
+
color: #666;
|
|
116
|
+
word-break: break-all;
|
|
117
|
+
flex: 1;
|
|
122
118
|
}
|
|
123
119
|
|
|
124
120
|
footer {
|
|
125
121
|
text-align: center;
|
|
126
|
-
padding: 1.5rem
|
|
127
|
-
border-top: 1px solid #
|
|
128
|
-
color: #666666;
|
|
122
|
+
padding: 1.5rem;
|
|
123
|
+
border-top: 1px solid #eee;
|
|
129
124
|
font-size: 0.9rem;
|
|
125
|
+
color: #666;
|
|
130
126
|
}
|
|
131
127
|
|
|
132
128
|
footer a {
|
|
133
|
-
color: #
|
|
129
|
+
color: #000;
|
|
134
130
|
text-decoration: none;
|
|
135
|
-
margin: 0 0.3rem;
|
|
136
131
|
font-weight: 500;
|
|
132
|
+
margin: 0 0.3rem;
|
|
137
133
|
}
|
|
138
134
|
|
|
139
135
|
footer a:hover {
|
|
140
136
|
text-decoration: underline;
|
|
141
137
|
}
|
|
142
138
|
|
|
143
|
-
@media (max-width:
|
|
139
|
+
@media (max-width: 600px) {
|
|
144
140
|
header h1 {
|
|
145
|
-
font-size: 1.
|
|
141
|
+
font-size: 1.8rem;
|
|
146
142
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
padding:
|
|
143
|
+
|
|
144
|
+
.tabs-container {
|
|
145
|
+
padding: 1rem;
|
|
150
146
|
}
|
|
151
147
|
|
|
148
|
+
.category h3 {
|
|
149
|
+
font-size: 0.8rem;
|
|
150
|
+
margin-bottom: 0.4rem;
|
|
151
|
+
}
|
|
152
|
+
|
|
152
153
|
.tabs {
|
|
153
|
-
gap: 0.
|
|
154
|
-
padding: 1rem;
|
|
154
|
+
gap: 0.3rem;
|
|
155
155
|
}
|
|
156
|
-
|
|
156
|
+
|
|
157
157
|
.tabs button {
|
|
158
|
-
padding: 0.
|
|
159
|
-
font-size: 0.
|
|
158
|
+
padding: 0.4rem 0.8rem;
|
|
159
|
+
font-size: 0.75rem;
|
|
160
160
|
}
|
|
161
|
-
|
|
161
|
+
|
|
162
162
|
.content {
|
|
163
163
|
padding: 1rem;
|
|
164
164
|
}
|
|
165
|
-
|
|
166
|
-
.
|
|
167
|
-
|
|
165
|
+
|
|
166
|
+
.result-row {
|
|
167
|
+
flex-direction: column;
|
|
168
|
+
gap: 0.3rem;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.result-row .label {
|
|
172
|
+
min-width: auto;
|
|
168
173
|
}
|
|
169
174
|
}
|