smath 1.16.0 → 2.1.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/types/index.d.ts CHANGED
@@ -5,308 +5,5 @@
5
5
  * ![NPM Downloads](https://img.shields.io/npm/d18m/smath)
6
6
  * ![NPM Last Update](https://img.shields.io/npm/last-update/smath)
7
7
  */
8
- /**
9
- * Check if two numbers are approximately equal with a maximum abolute error.
10
- * @param a Any number
11
- * @param b Any number
12
- * @param epsilon Maximum absolute error
13
- * @returns True if `a` is approximately `b`
14
- * @example
15
- * const b1 = SMath.approx(1 / 3, 0.33, 1e-6), // false
16
- * b2 = SMath.approx(1 / 3, 0.33, 1e-2); // true
17
- */
18
- export declare function approx(a: number, b: number, epsilon?: number): boolean;
19
- /**
20
- * Clamp a number within a range.
21
- * @param n The number to clamp
22
- * @param min The minimum value of the range
23
- * @param max The maximum value of the range
24
- * @returns A clamped number
25
- * @example
26
- * const n1 = SMath.clamp(5, 0, 10), // 5
27
- * n2 = SMath.clamp(-2, 0, 10); // 0
28
- */
29
- export declare function clamp(n: number, min: number, max: number): number;
30
- /**
31
- * Normalize the number `n` from the range `min, max` to the range `0, 1`
32
- * @param n The number to normalize
33
- * @param min The minimum value in the range
34
- * @param max The maximum value in the range
35
- * @returns A normalized value
36
- * @example
37
- * const y = SMath.normalize(18, 9, 99); // 0.1
38
- */
39
- export declare function normalize(n: number, min: number, max: number): number;
40
- /**
41
- * Expand a normalized number `n` to the range `min, max`
42
- * @param n A normalized number
43
- * @param min The minimum value in the range
44
- * @param max The maximum value in the range
45
- * @returns A value within the number range
46
- * @example
47
- * const y = SMath.expand(0.25, 4, 6); // 4.5
48
- */
49
- export declare function expand(n: number, min: number, max: number): number;
50
- /**
51
- * Translate a number `n` from the range `min1, max1` to the range `min2, max2`
52
- * @param n The number to translate
53
- * @param min1 The minimum value from the initial range
54
- * @param max1 The maximum value from the initial range
55
- * @param min2 The minimum value for the final range
56
- * @param max2 The maximum value for the final range
57
- * @returns A translated number in the final range
58
- * @example
59
- * const C = 20,
60
- * F = SMath.translate(C, 0, 100, 32, 212); // 68
61
- */
62
- export declare function translate(n: number, min1: number, max1: number, min2: number, max2: number): number;
63
- /**
64
- * Generate an array of linearly spaced numbers.
65
- * @param min The initial value of the linear space
66
- * @param max The final value of the linear space
67
- * @param count The number of values in the space
68
- * @returns The linear space as an array of numbers
69
- * @example
70
- * const space = SMath.linspace(1, 5, 6);
71
- * // [ 1, 1.8, 2.6, 3.4, 4.2, 5 ]
72
- */
73
- export declare function linspace(min: number, max: number, count: number): number[];
74
- /**
75
- * Generate an array of logarithmically spaced numbers.
76
- * @param min The initial magnitude of the space
77
- * @param max The final magnitude of the space
78
- * @param count The number of values in the space
79
- * @returns The logarithmic space as an array of numbers
80
- * @example
81
- * const space = SMath.logspace(0, 2, 5);
82
- * // [ 1, 3.2, 10, 31.6, 100 ]
83
- */
84
- export declare function logspace(min: number, max: number, count: number): number[];
85
- /**
86
- * Compute the factorial of `n`.
87
- * @param n Any positive integer
88
- * @returns `n!`
89
- * @example
90
- * const y = SMath.factorial(5); // 120
91
- */
92
- export declare function factorial(n: number): number;
93
- /**
94
- * Factorize `n` into its prime factors.
95
- * @param n Any positive integer
96
- * @returns The array of prime factors
97
- * @example
98
- * const y = SMath.factors(12); // [ 2, 2, 3 ]
99
- */
100
- export declare function factors(n: number): number[];
101
- /**
102
- * Round a number to the nearest multiple of an arbitrary
103
- * base. Does not round when the base is set to zero.
104
- * @param n Any number to round
105
- * @param base Any base to round to
106
- * @returns `n` rounded to the nearest multiple of `base`
107
- * @example
108
- * const y = SMath.round2(Math.PI, 0.2); // 3.2
109
- */
110
- export declare function round2(n: number, base: number): number;
111
- /**
112
- * Calculate the relative normalized error or deviation from any
113
- * value to an accepted value. An error of 0 indicates that the
114
- * two values are identical. An error of -0.1 indicates that the
115
- * experimental value is 10% smaller than (90% of) the accepted
116
- * value. An error of 1.0 indicates that the experimental value
117
- * is 100% greater (or twice the size) of the accepted value.
118
- * @param experimental The value observed or produced by a test
119
- * @param actual The accepted or theoretical value
120
- * @returns The relative (normalized) error
121
- * @example
122
- * const e = SMath.error(22.5, 25); // -0.1
123
- */
124
- export declare function error(experimental: number, actual: number): number;
125
- /**
126
- * Add up all the inputs.
127
- * If none are present, returns 0.
128
- * @param data An array of numeric inputs
129
- * @returns The sum total
130
- * @example
131
- * const y = SMath.sum([1, 2, 3]); // 6
132
- */
133
- export declare function sum(data: number[]): number;
134
- /**
135
- * Multiply all the inputs.
136
- * If none are present, returns 1.
137
- * @param data An array of numeric inputs
138
- * @returns The product
139
- * @example
140
- * const y = SMath.prod([2, 2, 3, 5]); // 60
141
- */
142
- export declare function prod(data: number[]): number;
143
- /**
144
- * Compute the average, or mean, of a set of numbers.
145
- * @param data An array of numeric inputs
146
- * @returns The average, or mean
147
- * @example
148
- * const y = SMath.avg([1, 2, 4, 4]); // 2.75
149
- */
150
- export declare function avg(data: number[]): number;
151
- /**
152
- * Compute the median of a set of numbers.
153
- * @param data An array of numeric inputs
154
- * @returns The median of the dataset
155
- * @example
156
- * const y = SMath.median([2, 5, 3, 1]); // 2.5
157
- */
158
- export declare function median(data: number[]): number;
159
- /**
160
- * Compute the variance of a **complete population**.
161
- * @param data An array of numeric inputs
162
- * @returns The population variance
163
- * @example
164
- * const y = SMath.varp([1, 2, 4, 4]); // 1.6875
165
- */
166
- export declare function varp(data: number[]): number;
167
- /**
168
- * Compute the variance of a **sample**.
169
- * @param data An array of numeric inputs
170
- * @returns The sample variance
171
- * @example
172
- * const y = SMath.vars([1, 2, 4, 4]); // 2.25
173
- */
174
- export declare function vars(data: number[]): number;
175
- /**
176
- * Compute the standard deviation of a **complete population**.
177
- * @param data An array of numeric inputs
178
- * @returns The population standard deviation
179
- * @example
180
- * const y = SMath.stdevp([1, 2, 3, 4]); // 1.118...
181
- */
182
- export declare function stdevp(data: number[]): number;
183
- /**
184
- * Compute the standard deviation of a **sample**.
185
- * @param data An array of numeric inputs
186
- * @returns The sample standard deviation
187
- * @example
188
- * const y = SMath.stdevs([1, 2, 3, 4]); // 1.29...
189
- */
190
- export declare function stdevs(data: number[]): number;
191
- /**
192
- * Generate a uniformly-distributed floating-point number within the range.
193
- * @param min The minimum bound
194
- * @param max The maximum bound
195
- * @returns A random float within the range
196
- * @example
197
- * const y = SMath.runif(-2, 2); // 0.376...
198
- */
199
- export declare function runif(min: number, max: number): number;
200
- /**
201
- * Generate a uniformly-distributed integer within the range.
202
- * @param min The minimum bound (inclusive)
203
- * @param max The maximum bound (inclusive)
204
- * @returns A random integer within the range
205
- * @example
206
- * const y = SMath.rint(-4, 3); // -4
207
- */
208
- export declare function rint(min: number, max: number): number;
209
- /**
210
- * Generate a normally-distributed floating-point number.
211
- * @param mean The mean of the population distribution
212
- * @param stdev The standard deviation of the population
213
- * @returns A random float
214
- * @example
215
- * const y = SMath.rnorm(2, 3); // 1.627...
216
- */
217
- export declare function rnorm(mean?: number, stdev?: number): number;
218
- /**
219
- * Generate a population of normally-distributed floating-point numbers.
220
- * @param count The number of values to generate
221
- * @param mean The mean of the population distribution
222
- * @param stdev The standard deviation of the population
223
- * @returns A population of random floats
224
- * @example
225
- * const dataset = SMath.rdist(3); // [ 1.051..., -0.779..., -2.254... ]
226
- */
227
- export declare function rdist(count: number, mean?: number, stdev?: number): number[];
228
- /**
229
- * Randomize an array of arbitrary elements.
230
- * @param stack An array of arbitrary elements
231
- * @returns The `stack` array in a random order
232
- * @example
233
- * const shuffled = SMath.shuffle(['a', 'b', 'c']); // [ 'c', 'a', 'b' ]
234
- */
235
- export declare function shuffle<T>(stack: T[]): T[];
236
- /**
237
- * Select a single item from an array at random with uniform weights.
238
- * @param stack An array of arbirary item
239
- * @returns A single randomly selected item
240
- * @example
241
- * const selected = SMath.selectRandom([10, 20, 30, 40]); // 30
242
- */
243
- export declare function selectRandom<T>(stack: T[]): T;
244
- /**
245
- * Select a single index in an array at random with different weights.
246
- * @param weights The weights for each item
247
- * @returns The 0-based index of the randomly selected item
248
- * @example
249
- * const index = SMath.selectRandomWeighted([3.5, 4, 1]); // 1
250
- */
251
- export declare function selectRandomWeighted(weights: number[]): number;
252
- /**
253
- * Take the limit of a function. A return value of `NaN` indicates
254
- * that no limit exists either due to a discontinuity or imaginary value.
255
- * @param f Function `f(x)`
256
- * @param x The x-value where to take the limit
257
- * @param h The approach distance
258
- * @param discontinuity_cutoff The discontinuity cutoff
259
- * @returns `lim(f(x->x))`
260
- * @example
261
- * const y = SMath.lim(Math.log, 0); // -Infinity
262
- */
263
- export declare function lim(f: (x: number) => number, x: number, h?: number, discontinuity_cutoff?: number): number;
264
- /**
265
- * Take the derivative of a function.
266
- * @param f Function `f(x)`
267
- * @param x The x-value where to evaluate the derivative
268
- * @param epsilon Small step value
269
- * @returns `f'(x)`
270
- * @example
271
- * const y = SMath.differentiate(x => 3 * x ** 2, 2); // 12
272
- */
273
- export declare function differentiate(f: (x: number) => number, x: number, epsilon?: number): number;
274
- /**
275
- * Compute the definite integral of a function.
276
- * @param f Function `f(x)`
277
- * @param a The miminum integral bound
278
- * @param b The maximum integral bound
279
- * @param Ndx The number of rectangles to compute
280
- * @returns `F(b)-F(a)`
281
- * @example
282
- * const y = SMath.integrate(x => 3 * x ** 2, 1, 2); // 7
283
- */
284
- export declare function integrate(f: (x: number) => number, a: number, b: number, Ndx?: number): number;
285
- /**
286
- * Convert an arbitrary decimal number into a simplified fraction (or ratio).
287
- * See `mixed()` for instructions on how to break out the whole number part.
288
- * @param n The decimal number to convert
289
- * @param epsilon Maximum absolute error
290
- * @returns An object containing the fraction's numerator and denominator
291
- * @example
292
- * const frac = SMath.rat(0.625); // { num: 5, den: 8 }
293
- */
294
- export declare function rat(n: number, epsilon?: number): {
295
- num: number;
296
- den: number;
297
- };
298
- /**
299
- * Convert an arbitrary decimal number into a simplified fraction, after
300
- * breaking out the whole number part first. See `rat()` for keeping the
301
- * number as a ratio without separating the whole number part.
302
- * @param n A decimal number to convert
303
- * @param epsilon Maximum absolute error
304
- * @returns An object containing the whole part and fraction numerator and denominator
305
- * @example
306
- * const frac = SMath.mixed(-8 / 6); // { whole: -1, num: 1, den: 3 }
307
- */
308
- export declare function mixed(n: number, epsilon?: number): {
309
- whole: number;
310
- num: number;
311
- den: number;
312
- };
8
+ export * as SMath from './smath.js';
9
+ export * as DataFit from './datafit/index.js';
@@ -0,0 +1,311 @@
1
+ /**
2
+ * Check if two numbers are approximately equal with a maximum abolute error.
3
+ * @param a Any number
4
+ * @param b Any number
5
+ * @param epsilon Maximum absolute error
6
+ * @returns True if `a` is approximately `b`
7
+ * @example
8
+ * const b1 = SMath.approx(1 / 3, 0.33, 1e-6), // false
9
+ * b2 = SMath.approx(1 / 3, 0.33, 1e-2); // true
10
+ */
11
+ export declare function approx(a: number, b: number, epsilon?: number): boolean;
12
+ /**
13
+ * Clamp a number within a range.
14
+ * @param n The number to clamp
15
+ * @param min The minimum value of the range
16
+ * @param max The maximum value of the range
17
+ * @returns A clamped number
18
+ * @example
19
+ * const n1 = SMath.clamp(5, 0, 10), // 5
20
+ * n2 = SMath.clamp(-2, 0, 10); // 0
21
+ */
22
+ export declare function clamp(n: number, min: number, max: number): number;
23
+ /**
24
+ * Normalize the number `n` from the range `min, max` to the range `0, 1`
25
+ * @param n The number to normalize
26
+ * @param min The minimum value in the range
27
+ * @param max The maximum value in the range
28
+ * @returns A normalized value
29
+ * @example
30
+ * const y = SMath.normalize(18, 9, 99); // 0.1
31
+ */
32
+ export declare function normalize(n: number, min: number, max: number): number;
33
+ /**
34
+ * Expand a normalized number `n` to the range `min, max`
35
+ * @param n A normalized number
36
+ * @param min The minimum value in the range
37
+ * @param max The maximum value in the range
38
+ * @returns A value within the number range
39
+ * @example
40
+ * const y = SMath.expand(0.25, 4, 6); // 4.5
41
+ */
42
+ export declare function expand(n: number, min: number, max: number): number;
43
+ /**
44
+ * Translate a number `n` from the range `min1, max1` to the range `min2, max2`
45
+ * @param n The number to translate
46
+ * @param min1 The minimum value from the initial range
47
+ * @param max1 The maximum value from the initial range
48
+ * @param min2 The minimum value for the final range
49
+ * @param max2 The maximum value for the final range
50
+ * @returns A translated number in the final range
51
+ * @example
52
+ * const C = 20,
53
+ * F = SMath.translate(C, 0, 100, 32, 212); // 68
54
+ */
55
+ export declare function translate(n: number, min1: number, max1: number, min2: number, max2: number): number;
56
+ /**
57
+ * Generate an array of linearly spaced numbers.
58
+ * @param min The initial value of the linear space
59
+ * @param max The final value of the linear space
60
+ * @param count The number of values in the space
61
+ * @returns The linear space as an array of numbers
62
+ * @example
63
+ * const space = SMath.linspace(1, 5, 6);
64
+ * // [ 1, 1.8, 2.6, 3.4, 4.2, 5 ]
65
+ */
66
+ export declare function linspace(min: number, max: number, count: number): number[];
67
+ /**
68
+ * Generate an array of logarithmically spaced numbers.
69
+ * @param min The initial magnitude of the space
70
+ * @param max The final magnitude of the space
71
+ * @param count The number of values in the space
72
+ * @returns The logarithmic space as an array of numbers
73
+ * @example
74
+ * const space = SMath.logspace(0, 2, 5);
75
+ * // [ 1, 3.2, 10, 31.6, 100 ]
76
+ */
77
+ export declare function logspace(min: number, max: number, count: number): number[];
78
+ /**
79
+ * Compute the factorial of `n`.
80
+ * @param n Any positive integer
81
+ * @returns `n!`
82
+ * @example
83
+ * const y = SMath.factorial(5); // 120
84
+ */
85
+ export declare function factorial(n: number): number;
86
+ /**
87
+ * Factorize `n` into its prime factors.
88
+ * @param n Any positive integer
89
+ * @returns The array of prime factors
90
+ * @example
91
+ * const y = SMath.factors(12); // [ 2, 2, 3 ]
92
+ */
93
+ export declare function factors(n: number): number[];
94
+ /**
95
+ * An optimized algorithm to determine if any number is prime.
96
+ * @param n Any positive integer
97
+ * @returns `true` if `n` is prime
98
+ */
99
+ export declare function isPrime(n: number): boolean;
100
+ /**
101
+ * Round a number to the nearest multiple of an arbitrary
102
+ * base. Does not round when the base is set to zero.
103
+ * @param n Any number to round
104
+ * @param base Any base to round to
105
+ * @returns `n` rounded to the nearest multiple of `base`
106
+ * @example
107
+ * const y = SMath.round2(Math.PI, 0.2); // 3.2
108
+ */
109
+ export declare function round2(n: number, base: number): number;
110
+ /**
111
+ * Calculate the relative normalized error or deviation from any
112
+ * value to an accepted value. An error of 0 indicates that the
113
+ * two values are identical. An error of -0.1 indicates that the
114
+ * experimental value is 10% smaller than (90% of) the accepted
115
+ * value. An error of 1.0 indicates that the experimental value
116
+ * is 100% greater (or twice the size) of the accepted value.
117
+ * @param experimental The value observed or produced by a test
118
+ * @param actual The accepted or theoretical value
119
+ * @returns The relative (normalized) error
120
+ * @example
121
+ * const e = SMath.error(22.5, 25); // -0.1
122
+ */
123
+ export declare function error(experimental: number, actual: number): number;
124
+ /**
125
+ * Add up all the inputs.
126
+ * If none are present, returns 0.
127
+ * @param data An array of numeric inputs
128
+ * @returns The sum total
129
+ * @example
130
+ * const y = SMath.sum([1, 2, 3]); // 6
131
+ */
132
+ export declare function sum(data: number[]): number;
133
+ /**
134
+ * Multiply all the inputs.
135
+ * If none are present, returns 1.
136
+ * @param data An array of numeric inputs
137
+ * @returns The product
138
+ * @example
139
+ * const y = SMath.prod([2, 2, 3, 5]); // 60
140
+ */
141
+ export declare function prod(data: number[]): number;
142
+ /**
143
+ * Compute the average, or mean, of a set of numbers.
144
+ * @param data An array of numeric inputs
145
+ * @returns The average, or mean
146
+ * @example
147
+ * const y = SMath.avg([1, 2, 4, 4]); // 2.75
148
+ */
149
+ export declare function avg(data: number[]): number;
150
+ /**
151
+ * Compute the median of a set of numbers.
152
+ * @param data An array of numeric inputs
153
+ * @returns The median of the dataset
154
+ * @example
155
+ * const y = SMath.median([2, 5, 3, 1]); // 2.5
156
+ */
157
+ export declare function median(data: number[]): number;
158
+ /**
159
+ * Compute the variance of a **complete population**.
160
+ * @param data An array of numeric inputs
161
+ * @returns The population variance
162
+ * @example
163
+ * const y = SMath.varp([1, 2, 4, 4]); // 1.6875
164
+ */
165
+ export declare function varp(data: number[]): number;
166
+ /**
167
+ * Compute the variance of a **sample**.
168
+ * @param data An array of numeric inputs
169
+ * @returns The sample variance
170
+ * @example
171
+ * const y = SMath.vars([1, 2, 4, 4]); // 2.25
172
+ */
173
+ export declare function vars(data: number[]): number;
174
+ /**
175
+ * Compute the standard deviation of a **complete population**.
176
+ * @param data An array of numeric inputs
177
+ * @returns The population standard deviation
178
+ * @example
179
+ * const y = SMath.stdevp([1, 2, 3, 4]); // 1.118...
180
+ */
181
+ export declare function stdevp(data: number[]): number;
182
+ /**
183
+ * Compute the standard deviation of a **sample**.
184
+ * @param data An array of numeric inputs
185
+ * @returns The sample standard deviation
186
+ * @example
187
+ * const y = SMath.stdevs([1, 2, 3, 4]); // 1.29...
188
+ */
189
+ export declare function stdevs(data: number[]): number;
190
+ /**
191
+ * Generate a uniformly-distributed floating-point number within the range.
192
+ * @param min The minimum bound
193
+ * @param max The maximum bound
194
+ * @returns A random float within the range
195
+ * @example
196
+ * const y = SMath.runif(-2, 2); // 0.376...
197
+ */
198
+ export declare function runif(min: number, max: number): number;
199
+ /**
200
+ * Generate a uniformly-distributed integer within the range.
201
+ * @param min The minimum bound (inclusive)
202
+ * @param max The maximum bound (inclusive)
203
+ * @returns A random integer within the range
204
+ * @example
205
+ * const y = SMath.rint(-4, 3); // -4
206
+ */
207
+ export declare function rint(min: number, max: number): number;
208
+ /**
209
+ * Generate a normally-distributed floating-point number.
210
+ * @param mean The mean of the population distribution
211
+ * @param stdev The standard deviation of the population
212
+ * @returns A random float
213
+ * @example
214
+ * const y = SMath.rnorm(2, 3); // 1.627...
215
+ */
216
+ export declare function rnorm(mean?: number, stdev?: number): number;
217
+ /**
218
+ * Generate a population of normally-distributed floating-point numbers.
219
+ * @param count The number of values to generate
220
+ * @param mean The mean of the population distribution
221
+ * @param stdev The standard deviation of the population
222
+ * @returns A population of random floats
223
+ * @example
224
+ * const dataset = SMath.rdist(3); // [ 1.051..., -0.779..., -2.254... ]
225
+ */
226
+ export declare function rdist(count: number, mean?: number, stdev?: number): number[];
227
+ /**
228
+ * Randomize an array of arbitrary elements.
229
+ * @param stack An array of arbitrary elements
230
+ * @returns The `stack` array in a random order
231
+ * @example
232
+ * const shuffled = SMath.shuffle(['a', 'b', 'c']); // [ 'c', 'a', 'b' ]
233
+ */
234
+ export declare function shuffle<T>(stack: T[]): T[];
235
+ /**
236
+ * Select a single item from an array at random with uniform weights.
237
+ * @param stack An array of arbirary item
238
+ * @returns A single randomly selected item
239
+ * @example
240
+ * const selected = SMath.selectRandom([10, 20, 30, 40]); // 30
241
+ */
242
+ export declare function selectRandom<T>(stack: T[]): T;
243
+ /**
244
+ * Select a single index in an array at random with different weights.
245
+ * @param weights The weights for each item
246
+ * @returns The 0-based index of the randomly selected item
247
+ * @example
248
+ * const index = SMath.selectRandomWeighted([3.5, 4, 1]); // 1
249
+ */
250
+ export declare function selectRandomWeighted(weights: number[]): number;
251
+ /**
252
+ * Take the limit of a function. A return value of `NaN` indicates
253
+ * that no limit exists either due to a discontinuity or imaginary value.
254
+ * @param f Function `f(x)`
255
+ * @param x The x-value where to take the limit
256
+ * @param h The approach distance
257
+ * @param discontinuity_cutoff The discontinuity cutoff
258
+ * @returns `lim(f(x->x))`
259
+ * @example
260
+ * const y = SMath.lim(Math.log, 0); // -Infinity
261
+ */
262
+ export declare function lim(f: (x: number) => number, x: number, h?: number, discontinuity_cutoff?: number): number;
263
+ /**
264
+ * Take the derivative of a function.
265
+ * @param f Function `f(x)`
266
+ * @param x The x-value where to evaluate the derivative
267
+ * @param epsilon Small step value
268
+ * @returns `f'(x)`
269
+ * @example
270
+ * const y = SMath.differentiate(x => 3 * x ** 2, 2); // 12
271
+ */
272
+ export declare function differentiate(f: (x: number) => number, x: number, epsilon?: number): number;
273
+ /**
274
+ * Compute the definite integral of a function.
275
+ * @param f Function `f(x)`
276
+ * @param a The miminum integral bound
277
+ * @param b The maximum integral bound
278
+ * @param Ndx The number of rectangles to compute
279
+ * @returns `F(b)-F(a)`
280
+ * @example
281
+ * const y = SMath.integrate(x => 3 * x ** 2, 1, 2); // 7
282
+ */
283
+ export declare function integrate(f: (x: number) => number, a: number, b: number, Ndx?: number): number;
284
+ /**
285
+ * Convert an arbitrary decimal number into a simplified fraction (or ratio).
286
+ * See `mixed()` for instructions on how to break out the whole number part.
287
+ * @param n The decimal number to convert
288
+ * @param epsilon Maximum absolute error
289
+ * @returns An object containing the fraction's numerator and denominator
290
+ * @example
291
+ * const frac = SMath.rat(0.625); // { num: 5, den: 8 }
292
+ */
293
+ export declare function rat(n: number, epsilon?: number): {
294
+ num: number;
295
+ den: number;
296
+ };
297
+ /**
298
+ * Convert an arbitrary decimal number into a simplified fraction, after
299
+ * breaking out the whole number part first. See `rat()` for keeping the
300
+ * number as a ratio without separating the whole number part.
301
+ * @param n A decimal number to convert
302
+ * @param epsilon Maximum absolute error
303
+ * @returns An object containing the whole part and fraction numerator and denominator
304
+ * @example
305
+ * const frac = SMath.mixed(-8 / 6); // { whole: -1, num: 1, den: 3 }
306
+ */
307
+ export declare function mixed(n: number, epsilon?: number): {
308
+ whole: number;
309
+ num: number;
310
+ den: number;
311
+ };