@iyulab/u-numflow 0.9.0 → 0.11.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 CHANGED
@@ -35,7 +35,7 @@ u-numflow provides foundational mathematical, statistical, and probabilistic bui
35
35
 
36
36
  ```toml
37
37
  [dependencies]
38
- u-numflow = "0.9"
38
+ u-numflow = "0.11"
39
39
  ```
40
40
 
41
41
  ```rust
@@ -218,23 +218,26 @@ const { t_distribution_quantile } = require("@iyulab/u-numflow");
218
218
  try {
219
219
  t_distribution_quantile(1.5, 10);
220
220
  } catch (err) {
221
- console.log(err.code, err.parameter, err.min, err.max, err.got); // parameter_out_of_range p 0 1 1.5
221
+ console.log(err.code, err.parameter, err.exclusive_min, err.exclusive_max, err.got);
222
+ // parameter_out_of_range p 0 1 1.5
222
223
  }
223
224
  ```
224
225
 
225
226
  | `code` | Fields | Meaning |
226
227
  |---|---|---|
227
- | `parameter_out_of_range` | `parameter`, `min`, `max` (or `null`), `got` | `p` not strictly inside (0, 1), or a degrees of freedom that is not a finite number `> 0` (both bounds excluded); a distribution parameter that must be `> 0` (`parameter` is its path, e.g. `distribution.sigma`); `n` or `seed` not a whole number in range |
228
+ | `parameter_out_of_range` | `parameter`, `min`, `max`, `got`; `exclusive_min` / `exclusive_max` on an open end | `p` not strictly inside (0, 1) (`exclusive_min` 0, `exclusive_max` 1), or a degrees of freedom that is not a finite number `> 0` (`exclusive_min` 0); a distribution parameter that must be `> 0` (`exclusive_min` 0; `parameter` is its path, e.g. `distribution.sigma`), or that falls outside the range the others leave it: `distribution.max` not above `min` (`exclusive_min` = `min`), `distribution.mode` outside `[min, max]` (`min`, `max`); `estimate_lambda`'s `lambda_min` not below `lambda_max` (`exclusive_max` = `lambda_max`); a whole `n` or `seed` outside its range, a negative one included (`min` 0, `max`) |
228
229
  | `unknown_option` | `parameter`, `got`, `expected` | A `distribution.kind` the crate does not have |
229
- | `invalid_option` | `parameter` | Distribution parameters out of order: `min < max`, `min ≤ mode ≤ max` |
230
- | `malformed_input` | `parameter`, `index` (or absent) | A `data` argument that is not an array or `Float64Array`, or an element that is not a number; a `distribution` that is not an object with a string `kind`, lacks a parameter or has one its kind does not take; an interval row that is not two numbers (`parameter` is its path, e.g. `a[2]`) |
230
+ | `malformed_input` | `parameter`, `index` (or absent) | A `data` argument that is not an array or `Float64Array`, or an element that is not a number; a `distribution` that is not an object with a string `kind`, lacks a parameter or has one its kind does not take; an interval row that is not two numbers (`parameter` is its path, e.g. `a[2]`); an `n` or `seed` with a fraction ("must be a whole number") |
231
231
  | `reversed_interval` | `parameter`, `index` | An interval row with start > end — refused, not swapped |
232
- | `value_not_finite` | `parameter`, `index` for an array element | A NaN argument, or a NaN or infinity in any `data` array or interval row (`parameter` is the row's path) |
232
+ | `value_not_finite` | `parameter`, `index` for an array element | A NaN argument, an infinite `n`, `seed`, `lambda_min` or `lambda_max`, or a NaN or infinity in any `data` array or interval row (`parameter` is the row's path) |
233
233
  | `empty_input` | `parameter` | `mean` of no values |
234
- | `non_positive_data` | — | Box-Cox data with a value `≤ 0` |
235
- | `insufficient_data` | `parameter`, `min`, `got` for `std_dev`/`variance`; — for Box-Cox | Fewer values than the function needs (`std_dev`/`variance` 2, Box-Cox 2) |
234
+ | `non_positive_data` | `parameter`, `index`, `got` | Box-Cox data with a value `≤ 0` — `index` is the first such value |
235
+ | `insufficient_data` | `parameter`, `min`, `got` | Fewer values than the function needs (`std_dev`/`variance` 2, Box-Cox 2) |
236
236
  | `invalid_transform` | — | A Box-Cox result that is not finite |
237
- | `invalid_lambda_range` | — | `estimate_lambda` bounds that are not finite with `lambda_min < lambda_max` |
237
+
238
+ In `parameter_out_of_range`, `min` and `max` are inclusive bounds and are always
239
+ present — `null` when that end is unbounded or open. An open (exclusive) end is
240
+ `exclusive_min` / `exclusive_max`, present only when the bound is open.
238
241
 
239
242
  ### TypeScript
240
243
 
@@ -68,9 +68,10 @@ exports.chi_squared_quantile = chi_squared_quantile;
68
68
  * As every `distribution` argument: `malformed_input` for a value that is
69
69
  * not such an object, `unknown_option` for an unknown `kind` (with
70
70
  * `expected`), `value_not_finite` for a NaN or infinite parameter,
71
- * `parameter_out_of_range` for a parameter that must be `> 0`, and
72
- * `invalid_option` for parameters out of order (`min < max`,
73
- * `min ≤ mode ≤ max`). `x` NaN throws `value_not_finite`.
71
+ * `parameter_out_of_range` for a parameter that must be `> 0` and for one
72
+ * outside the range the others leave it -- `max` not above `min`
73
+ * (`exclusive_min` = `min`), `mode` outside `[min, max]` (`min`, `max`).
74
+ * `x` NaN throws `value_not_finite`.
74
75
  * @param {DistributionSpec} distribution
75
76
  * @param {number} x
76
77
  * @returns {number}
@@ -127,9 +128,10 @@ exports.distribution_quantile = distribution_quantile;
127
128
  * interval (0, 1), so no variate is infinite.
128
129
  *
129
130
  * # Errors
130
- * As [`distribution_cdf`] for `distribution`; `n` not a whole number in
131
- * `[0, 2³² − 1]` or `seed` not a whole number in `[0, 2⁵³]` throws
132
- * `parameter_out_of_range`.
131
+ * As [`distribution_cdf`] for `distribution`; `n` or `seed` with a fraction
132
+ * throws `malformed_input`, NaN or ±∞ `value_not_finite`, and a whole `n`
133
+ * outside `[0, 2³² − 1]` or `seed` outside `[0, 2⁵³]` (a negative one
134
+ * included) `parameter_out_of_range`.
133
135
  * @param {DistributionSpec} distribution
134
136
  * @param {number} n
135
137
  * @param {number} seed
@@ -156,8 +158,10 @@ exports.distribution_sample = distribution_sample;
156
158
  * interior estimate; widen the range to find the unconstrained optimum.
157
159
  *
158
160
  * # Errors
159
- * Throws as [`box_cox`] does for the data, and `invalid_lambda_range` when the
160
- * range is not finite with `lambda_min < lambda_max`.
161
+ * Throws as [`box_cox`] does for the data; `value_not_finite` (`parameter`
162
+ * `"lambda_min"` or `"lambda_max"`) for a NaN or infinite end, and
163
+ * `parameter_out_of_range` (`parameter: "lambda_min"`, `exclusive_max` =
164
+ * `lambda_max`, `got`) unless `lambda_min < lambda_max`.
161
165
  * @param {number[] | Float64Array} data
162
166
  * @param {number} lambda_min
163
167
  * @param {number} lambda_max
@@ -58,9 +58,10 @@ export function chi_squared_quantile(p: number, k: number): number;
58
58
  * As every `distribution` argument: `malformed_input` for a value that is
59
59
  * not such an object, `unknown_option` for an unknown `kind` (with
60
60
  * `expected`), `value_not_finite` for a NaN or infinite parameter,
61
- * `parameter_out_of_range` for a parameter that must be `> 0`, and
62
- * `invalid_option` for parameters out of order (`min < max`,
63
- * `min ≤ mode ≤ max`). `x` NaN throws `value_not_finite`.
61
+ * `parameter_out_of_range` for a parameter that must be `> 0` and for one
62
+ * outside the range the others leave it -- `max` not above `min`
63
+ * (`exclusive_min` = `min`), `mode` outside `[min, max]` (`min`, `max`).
64
+ * `x` NaN throws `value_not_finite`.
64
65
  */
65
66
  export function distribution_cdf(distribution: DistributionSpec, x: number): number;
66
67
 
@@ -88,9 +89,10 @@ export function distribution_quantile(distribution: DistributionSpec, p: number)
88
89
  * interval (0, 1), so no variate is infinite.
89
90
  *
90
91
  * # Errors
91
- * As [`distribution_cdf`] for `distribution`; `n` not a whole number in
92
- * `[0, 2³² − 1]` or `seed` not a whole number in `[0, 2⁵³]` throws
93
- * `parameter_out_of_range`.
92
+ * As [`distribution_cdf`] for `distribution`; `n` or `seed` with a fraction
93
+ * throws `malformed_input`, NaN or ±∞ `value_not_finite`, and a whole `n`
94
+ * outside `[0, 2³² − 1]` or `seed` outside `[0, 2⁵³]` (a negative one
95
+ * included) `parameter_out_of_range`.
94
96
  */
95
97
  export function distribution_sample(distribution: DistributionSpec, n: number, seed: number): Float64Array;
96
98
 
@@ -104,8 +106,10 @@ export function distribution_sample(distribution: DistributionSpec, n: number, s
104
106
  * interior estimate; widen the range to find the unconstrained optimum.
105
107
  *
106
108
  * # Errors
107
- * Throws as [`box_cox`] does for the data, and `invalid_lambda_range` when the
108
- * range is not finite with `lambda_min < lambda_max`.
109
+ * Throws as [`box_cox`] does for the data; `value_not_finite` (`parameter`
110
+ * `"lambda_min"` or `"lambda_max"`) for a NaN or infinite end, and
111
+ * `parameter_out_of_range` (`parameter: "lambda_min"`, `exclusive_max` =
112
+ * `lambda_max`, `got`) unless `lambda_min < lambda_max`.
109
113
  */
110
114
  export function estimate_lambda(data: number[] | Float64Array, lambda_min: number, lambda_max: number): LambdaEstimateDto;
111
115
 
Binary file
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "iyulab"
6
6
  ],
7
7
  "description": "Foundational mathematical primitives: statistics, probability distributions, random sampling, and collections.",
8
- "version": "0.9.0",
8
+ "version": "0.11.0",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",
package/u_numflow.d.ts CHANGED
@@ -58,9 +58,10 @@ export function chi_squared_quantile(p: number, k: number): number;
58
58
  * As every `distribution` argument: `malformed_input` for a value that is
59
59
  * not such an object, `unknown_option` for an unknown `kind` (with
60
60
  * `expected`), `value_not_finite` for a NaN or infinite parameter,
61
- * `parameter_out_of_range` for a parameter that must be `> 0`, and
62
- * `invalid_option` for parameters out of order (`min < max`,
63
- * `min ≤ mode ≤ max`). `x` NaN throws `value_not_finite`.
61
+ * `parameter_out_of_range` for a parameter that must be `> 0` and for one
62
+ * outside the range the others leave it -- `max` not above `min`
63
+ * (`exclusive_min` = `min`), `mode` outside `[min, max]` (`min`, `max`).
64
+ * `x` NaN throws `value_not_finite`.
64
65
  */
65
66
  export function distribution_cdf(distribution: DistributionSpec, x: number): number;
66
67
 
@@ -88,9 +89,10 @@ export function distribution_quantile(distribution: DistributionSpec, p: number)
88
89
  * interval (0, 1), so no variate is infinite.
89
90
  *
90
91
  * # Errors
91
- * As [`distribution_cdf`] for `distribution`; `n` not a whole number in
92
- * `[0, 2³² − 1]` or `seed` not a whole number in `[0, 2⁵³]` throws
93
- * `parameter_out_of_range`.
92
+ * As [`distribution_cdf`] for `distribution`; `n` or `seed` with a fraction
93
+ * throws `malformed_input`, NaN or ±∞ `value_not_finite`, and a whole `n`
94
+ * outside `[0, 2³² − 1]` or `seed` outside `[0, 2⁵³]` (a negative one
95
+ * included) `parameter_out_of_range`.
94
96
  */
95
97
  export function distribution_sample(distribution: DistributionSpec, n: number, seed: number): Float64Array;
96
98
 
@@ -104,8 +106,10 @@ export function distribution_sample(distribution: DistributionSpec, n: number, s
104
106
  * interior estimate; widen the range to find the unconstrained optimum.
105
107
  *
106
108
  * # Errors
107
- * Throws as [`box_cox`] does for the data, and `invalid_lambda_range` when the
108
- * range is not finite with `lambda_min < lambda_max`.
109
+ * Throws as [`box_cox`] does for the data; `value_not_finite` (`parameter`
110
+ * `"lambda_min"` or `"lambda_max"`) for a NaN or infinite end, and
111
+ * `parameter_out_of_range` (`parameter: "lambda_min"`, `exclusive_max` =
112
+ * `lambda_max`, `got`) unless `lambda_min < lambda_max`.
109
113
  */
110
114
  export function estimate_lambda(data: number[] | Float64Array, lambda_min: number, lambda_max: number): LambdaEstimateDto;
111
115
 
package/u_numflow_bg.js CHANGED
@@ -63,9 +63,10 @@ export function chi_squared_quantile(p, k) {
63
63
  * As every `distribution` argument: `malformed_input` for a value that is
64
64
  * not such an object, `unknown_option` for an unknown `kind` (with
65
65
  * `expected`), `value_not_finite` for a NaN or infinite parameter,
66
- * `parameter_out_of_range` for a parameter that must be `> 0`, and
67
- * `invalid_option` for parameters out of order (`min < max`,
68
- * `min ≤ mode ≤ max`). `x` NaN throws `value_not_finite`.
66
+ * `parameter_out_of_range` for a parameter that must be `> 0` and for one
67
+ * outside the range the others leave it -- `max` not above `min`
68
+ * (`exclusive_min` = `min`), `mode` outside `[min, max]` (`min`, `max`).
69
+ * `x` NaN throws `value_not_finite`.
69
70
  * @param {DistributionSpec} distribution
70
71
  * @param {number} x
71
72
  * @returns {number}
@@ -119,9 +120,10 @@ export function distribution_quantile(distribution, p) {
119
120
  * interval (0, 1), so no variate is infinite.
120
121
  *
121
122
  * # Errors
122
- * As [`distribution_cdf`] for `distribution`; `n` not a whole number in
123
- * `[0, 2³² − 1]` or `seed` not a whole number in `[0, 2⁵³]` throws
124
- * `parameter_out_of_range`.
123
+ * As [`distribution_cdf`] for `distribution`; `n` or `seed` with a fraction
124
+ * throws `malformed_input`, NaN or ±∞ `value_not_finite`, and a whole `n`
125
+ * outside `[0, 2³² − 1]` or `seed` outside `[0, 2⁵³]` (a negative one
126
+ * included) `parameter_out_of_range`.
125
127
  * @param {DistributionSpec} distribution
126
128
  * @param {number} n
127
129
  * @param {number} seed
@@ -147,8 +149,10 @@ export function distribution_sample(distribution, n, seed) {
147
149
  * interior estimate; widen the range to find the unconstrained optimum.
148
150
  *
149
151
  * # Errors
150
- * Throws as [`box_cox`] does for the data, and `invalid_lambda_range` when the
151
- * range is not finite with `lambda_min < lambda_max`.
152
+ * Throws as [`box_cox`] does for the data; `value_not_finite` (`parameter`
153
+ * `"lambda_min"` or `"lambda_max"`) for a NaN or infinite end, and
154
+ * `parameter_out_of_range` (`parameter: "lambda_min"`, `exclusive_max` =
155
+ * `lambda_max`, `got`) unless `lambda_min < lambda_max`.
152
156
  * @param {number[] | Float64Array} data
153
157
  * @param {number} lambda_min
154
158
  * @param {number} lambda_max
package/u_numflow_bg.wasm CHANGED
Binary file