@cloudglides/nox 1.1.6 → 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 +38 -7
- package/example/src/App.jsx +328 -25
- 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 -1
- package/src/rng.browser.js +5 -6
- package/src/rng.js +95 -94
- 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.js +4 -3
- package/test/new-features.js +52 -0
- package/IMPROVEMENTS.md +0 -58
- package/PERFORMANCE.md +0 -69
package/IMPROVEMENTS.md
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
# Improvements Made (Hour 2)
|
|
2
|
-
|
|
3
|
-
## Batch Operations
|
|
4
|
-
- Added `batch(count, fn)` - Execute custom function n times
|
|
5
|
-
- Added `floats(count)` - Generate array of floats
|
|
6
|
-
- Added `ints(count, max)` - Generate array of integers
|
|
7
|
-
- Added `bools(count, probability)` - Generate array of booleans
|
|
8
|
-
|
|
9
|
-
## RNG API Enhancements
|
|
10
|
-
- Added `range(min, max, step)` - Pick random value from stepped range
|
|
11
|
-
- Added `choice(arr)` - Pick random element from array
|
|
12
|
-
- Better error messages with TypeError vs RangeError distinctions
|
|
13
|
-
|
|
14
|
-
## Statistical Improvements
|
|
15
|
-
- Added `kolmogorovSmirnovTest(data)` - KS goodness-of-fit test
|
|
16
|
-
- Added `meanTest(data, expected)` - Test mean of distribution
|
|
17
|
-
- Added `varianceTest(data, expected)` - Test variance of distribution
|
|
18
|
-
- All tests return detailed result objects with pass/fail indicators
|
|
19
|
-
|
|
20
|
-
## Sampling Enhancements
|
|
21
|
-
- Improved `weightedPick()` with comprehensive validation
|
|
22
|
-
- Improved `weightedSample()` with type checking
|
|
23
|
-
- Improved `reservoirSample()` with better error handling
|
|
24
|
-
|
|
25
|
-
## Generator Optimizations
|
|
26
|
-
- Removed modulo bias in `nextInt()` - uses rejection sampling instead
|
|
27
|
-
- Applied to: PCG64, Xorshift64, Splitmix64, MT19937
|
|
28
|
-
- Ensures uniform distribution across all ranges
|
|
29
|
-
|
|
30
|
-
## Performance & Caching
|
|
31
|
-
- Added crypto cache in entropy source for performance
|
|
32
|
-
- Added `clearCryptoCache()` export for testing
|
|
33
|
-
- Better entropy mixing with proper BigInt operations
|
|
34
|
-
|
|
35
|
-
## Type Safety
|
|
36
|
-
- Added `IGenerator` interface for type consistency
|
|
37
|
-
- Added `GeneratorConstructor` type definition
|
|
38
|
-
- Added generic types to shuffle, pick, sample functions
|
|
39
|
-
- Added test result interfaces: `TestResult`, `KSTestResult`
|
|
40
|
-
- Complete TypeScript definitions for all new APIs
|
|
41
|
-
|
|
42
|
-
## Documentation
|
|
43
|
-
- Updated README with batch operations examples
|
|
44
|
-
- Added weighted sampling section
|
|
45
|
-
- Added statistical tests section
|
|
46
|
-
- Enhanced generator selection documentation
|
|
47
|
-
|
|
48
|
-
## Testing
|
|
49
|
-
- Added comprehensive test suite (test/comprehensive.js)
|
|
50
|
-
- Added advanced features test (test/advanced.js)
|
|
51
|
-
- All tests pass successfully
|
|
52
|
-
|
|
53
|
-
## Code Quality
|
|
54
|
-
- Total lines: 1107 → 1318 (+211)
|
|
55
|
-
- Files modified: 10
|
|
56
|
-
- Lines added/changed: 286
|
|
57
|
-
- Consistent error handling patterns
|
|
58
|
-
- Full backward compatibility maintained
|
package/PERFORMANCE.md
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
# Performance Benchmarks
|
|
2
|
-
|
|
3
|
-
Benchmarks run on Node.js v20.19.6 on modern hardware.
|
|
4
|
-
|
|
5
|
-
## RNG Operations (per second)
|
|
6
|
-
|
|
7
|
-
| Operation | Rate |
|
|
8
|
-
|-----------|------|
|
|
9
|
-
| `nextFloat()` | 2.5M |
|
|
10
|
-
| `nextInt(100)` | 2.8M |
|
|
11
|
-
| `int(1, 100)` | 1.8M |
|
|
12
|
-
| `bool()` | 3.5M |
|
|
13
|
-
| `choice()` | 1.5M |
|
|
14
|
-
|
|
15
|
-
## Batch Operations
|
|
16
|
-
|
|
17
|
-
| Operation | Rate |
|
|
18
|
-
|-----------|------|
|
|
19
|
-
| `floats(1000)` | 2.5k/sec |
|
|
20
|
-
| `ints(1000, 100)` | 2.2k/sec |
|
|
21
|
-
| `bools(1000)` | 2.8k/sec |
|
|
22
|
-
|
|
23
|
-
## Distributions
|
|
24
|
-
|
|
25
|
-
| Distribution | Rate |
|
|
26
|
-
|--------------|------|
|
|
27
|
-
| `normal()` | 1.0M |
|
|
28
|
-
| `exponential()` | 1.5M |
|
|
29
|
-
| `uniform()` | 3.5M |
|
|
30
|
-
| `poisson()` | 0.8M |
|
|
31
|
-
|
|
32
|
-
## Sequence Operations
|
|
33
|
-
|
|
34
|
-
| Operation | Rate |
|
|
35
|
-
|-----------|------|
|
|
36
|
-
| `shuffle(100)` | 14k/sec |
|
|
37
|
-
| `sample(100, 50)` | 25k/sec |
|
|
38
|
-
| `pick()` | 1.5M |
|
|
39
|
-
|
|
40
|
-
## Generators
|
|
41
|
-
|
|
42
|
-
All generators show similar performance characteristics:
|
|
43
|
-
- **PCG64**: Fast, cryptographic quality
|
|
44
|
-
- **Xorshift64**: Fastest, good distribution
|
|
45
|
-
- **Splitmix64**: Very fast, good avalanche
|
|
46
|
-
- **MT19937**: Good period, slower output
|
|
47
|
-
|
|
48
|
-
## Optimization History
|
|
49
|
-
|
|
50
|
-
### v1.1.5
|
|
51
|
-
- 17% faster `nextFloat()` (division → multiplication)
|
|
52
|
-
- 53% faster `nextInt()` (fast path for small max)
|
|
53
|
-
- Pre-allocated arrays in batch operations
|
|
54
|
-
- Removed unnecessary array copies in sampling
|
|
55
|
-
|
|
56
|
-
### v1.1.4
|
|
57
|
-
- Fixed unbiased distribution in `nextInt()`
|
|
58
|
-
- Improved variance calculations
|
|
59
|
-
|
|
60
|
-
### v1.1.3
|
|
61
|
-
- Browser compatibility fixes
|
|
62
|
-
|
|
63
|
-
## Tips for Best Performance
|
|
64
|
-
|
|
65
|
-
1. **Reuse RNG instance**: Creating new RNG is cheaper than recreating distributions
|
|
66
|
-
2. **Batch operations**: Use `.floats(n)` instead of loop with `.nextFloat()`
|
|
67
|
-
3. **Small ranges**: `nextInt()` fast-paths for `max < 65536`
|
|
68
|
-
4. **Avoid shuffling large arrays**: Use reservoir sampling or weighted sampling instead
|
|
69
|
-
5. **Cache distribution parameters**: Pre-compute lambda, mean, stddev if used repeatedly
|