numpy-ts 0.8.0 → 0.10.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 +33 -27
- package/dist/numpy-ts.browser.js +2 -2
- package/dist/numpy-ts.esm.js +2 -2
- package/dist/numpy-ts.node-io.cjs +3 -3
- package/dist/numpy-ts.node-io.cjs.map +4 -4
- package/dist/numpy-ts.node-io.mjs +3 -3
- package/dist/numpy-ts.node-io.mjs.map +4 -4
- package/dist/numpy-ts.node.cjs +2 -2
- package/dist/numpy-ts.node.cjs.map +4 -4
- package/dist/types/core/ndarray.d.ts +887 -0
- package/dist/types/index.d.ts +40 -1
- package/dist/types/ops/advanced.d.ts +7 -0
- package/dist/types/ops/arithmetic.d.ts +49 -0
- package/dist/types/ops/exponential.d.ts +79 -1
- package/dist/types/ops/gradient.d.ts +57 -0
- package/dist/types/ops/linalg.d.ts +220 -0
- package/dist/types/ops/logic.d.ts +201 -0
- package/dist/types/ops/random.d.ts +136 -0
- package/dist/types/ops/rounding.d.ts +36 -0
- package/dist/types/ops/sets.d.ts +38 -0
- package/dist/types/ops/sorting.d.ts +8 -0
- package/dist/types/ops/statistics.d.ts +108 -0
- package/package.json +2 -2
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logic operations
|
|
3
|
+
*
|
|
4
|
+
* Pure functions for element-wise logical operations:
|
|
5
|
+
* logical_and, logical_or, logical_not, logical_xor,
|
|
6
|
+
* isfinite, isinf, isnan, isnat, copysign, signbit, nextafter, spacing
|
|
7
|
+
*
|
|
8
|
+
* These operations convert values to boolean (non-zero = true, zero = false)
|
|
9
|
+
* and return boolean arrays (dtype: 'bool').
|
|
10
|
+
*/
|
|
11
|
+
import { ArrayStorage } from '../core/storage';
|
|
12
|
+
import { type DType } from '../core/dtype';
|
|
13
|
+
/**
|
|
14
|
+
* Logical AND of two arrays or array and scalar
|
|
15
|
+
*
|
|
16
|
+
* Returns a boolean array where each element is the logical AND
|
|
17
|
+
* of corresponding elements (non-zero = true, zero = false).
|
|
18
|
+
*
|
|
19
|
+
* @param a - First array storage
|
|
20
|
+
* @param b - Second array storage or scalar
|
|
21
|
+
* @returns Boolean result storage
|
|
22
|
+
*/
|
|
23
|
+
export declare function logical_and(a: ArrayStorage, b: ArrayStorage | number): ArrayStorage;
|
|
24
|
+
/**
|
|
25
|
+
* Logical OR of two arrays or array and scalar
|
|
26
|
+
*
|
|
27
|
+
* Returns a boolean array where each element is the logical OR
|
|
28
|
+
* of corresponding elements (non-zero = true, zero = false).
|
|
29
|
+
*
|
|
30
|
+
* @param a - First array storage
|
|
31
|
+
* @param b - Second array storage or scalar
|
|
32
|
+
* @returns Boolean result storage
|
|
33
|
+
*/
|
|
34
|
+
export declare function logical_or(a: ArrayStorage, b: ArrayStorage | number): ArrayStorage;
|
|
35
|
+
/**
|
|
36
|
+
* Logical NOT of an array
|
|
37
|
+
*
|
|
38
|
+
* Returns a boolean array where each element is the logical NOT
|
|
39
|
+
* of the input (non-zero = false, zero = true).
|
|
40
|
+
*
|
|
41
|
+
* @param a - Input array storage
|
|
42
|
+
* @returns Boolean result storage
|
|
43
|
+
*/
|
|
44
|
+
export declare function logical_not(a: ArrayStorage): ArrayStorage;
|
|
45
|
+
/**
|
|
46
|
+
* Logical XOR of two arrays or array and scalar
|
|
47
|
+
*
|
|
48
|
+
* Returns a boolean array where each element is the logical XOR
|
|
49
|
+
* of corresponding elements (non-zero = true, zero = false).
|
|
50
|
+
*
|
|
51
|
+
* @param a - First array storage
|
|
52
|
+
* @param b - Second array storage or scalar
|
|
53
|
+
* @returns Boolean result storage
|
|
54
|
+
*/
|
|
55
|
+
export declare function logical_xor(a: ArrayStorage, b: ArrayStorage | number): ArrayStorage;
|
|
56
|
+
/**
|
|
57
|
+
* Test element-wise for finiteness (not infinity and not NaN)
|
|
58
|
+
*
|
|
59
|
+
* @param a - Input array storage
|
|
60
|
+
* @returns Boolean result storage
|
|
61
|
+
*/
|
|
62
|
+
export declare function isfinite(a: ArrayStorage): ArrayStorage;
|
|
63
|
+
/**
|
|
64
|
+
* Test element-wise for positive or negative infinity
|
|
65
|
+
*
|
|
66
|
+
* @param a - Input array storage
|
|
67
|
+
* @returns Boolean result storage
|
|
68
|
+
*/
|
|
69
|
+
export declare function isinf(a: ArrayStorage): ArrayStorage;
|
|
70
|
+
/**
|
|
71
|
+
* Test element-wise for NaN (Not a Number)
|
|
72
|
+
*
|
|
73
|
+
* @param a - Input array storage
|
|
74
|
+
* @returns Boolean result storage
|
|
75
|
+
*/
|
|
76
|
+
export declare function isnan(a: ArrayStorage): ArrayStorage;
|
|
77
|
+
/**
|
|
78
|
+
* Test element-wise for NaT (Not a Time)
|
|
79
|
+
*
|
|
80
|
+
* In NumPy, NaT is the datetime equivalent of NaN.
|
|
81
|
+
* Since we don't have datetime support, this always returns false.
|
|
82
|
+
*
|
|
83
|
+
* @param a - Input array storage
|
|
84
|
+
* @returns Boolean result storage (all false)
|
|
85
|
+
*/
|
|
86
|
+
export declare function isnat(a: ArrayStorage): ArrayStorage;
|
|
87
|
+
/**
|
|
88
|
+
* Change the sign of x1 to that of x2, element-wise
|
|
89
|
+
*
|
|
90
|
+
* Returns a value with the magnitude of x1 and the sign of x2.
|
|
91
|
+
*
|
|
92
|
+
* @param x1 - Values to change sign of (magnitude source)
|
|
93
|
+
* @param x2 - Values whose sign is used (sign source)
|
|
94
|
+
* @returns Array with magnitude from x1 and sign from x2
|
|
95
|
+
*/
|
|
96
|
+
export declare function copysign(x1: ArrayStorage, x2: ArrayStorage | number): ArrayStorage;
|
|
97
|
+
/**
|
|
98
|
+
* Returns element-wise True where signbit is set (less than zero)
|
|
99
|
+
*
|
|
100
|
+
* @param a - Input array storage
|
|
101
|
+
* @returns Boolean result storage
|
|
102
|
+
*/
|
|
103
|
+
export declare function signbit(a: ArrayStorage): ArrayStorage;
|
|
104
|
+
/**
|
|
105
|
+
* Return the next floating-point value after x1 towards x2, element-wise
|
|
106
|
+
*
|
|
107
|
+
* @param x1 - Values to find the next representable value of
|
|
108
|
+
* @param x2 - Direction to look in for the next representable value
|
|
109
|
+
* @returns Array of next representable values
|
|
110
|
+
*/
|
|
111
|
+
export declare function nextafter(x1: ArrayStorage, x2: ArrayStorage | number): ArrayStorage;
|
|
112
|
+
/**
|
|
113
|
+
* Return the distance between x and the nearest adjacent number
|
|
114
|
+
*
|
|
115
|
+
* This is the difference between x and the next representable floating-point value.
|
|
116
|
+
*
|
|
117
|
+
* @param a - Input array storage
|
|
118
|
+
* @returns Array of spacing values
|
|
119
|
+
*/
|
|
120
|
+
export declare function spacing(a: ArrayStorage): ArrayStorage;
|
|
121
|
+
/**
|
|
122
|
+
* Test element-wise for complex number
|
|
123
|
+
* Since numpy-ts doesn't support complex numbers, always returns false
|
|
124
|
+
* @param a - Input array storage
|
|
125
|
+
* @returns Boolean array (all false)
|
|
126
|
+
*/
|
|
127
|
+
export declare function iscomplex(a: ArrayStorage): ArrayStorage;
|
|
128
|
+
/**
|
|
129
|
+
* Check whether object is complex type array
|
|
130
|
+
* Since numpy-ts doesn't support complex numbers, always returns false
|
|
131
|
+
* @param _a - Input array storage (unused)
|
|
132
|
+
* @returns false
|
|
133
|
+
*/
|
|
134
|
+
export declare function iscomplexobj(_a: ArrayStorage): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Test element-wise for real number (not complex)
|
|
137
|
+
* Since numpy-ts doesn't support complex numbers, always returns true
|
|
138
|
+
* @param a - Input array storage
|
|
139
|
+
* @returns Boolean array (all true)
|
|
140
|
+
*/
|
|
141
|
+
export declare function isreal(a: ArrayStorage): ArrayStorage;
|
|
142
|
+
/**
|
|
143
|
+
* Check whether object is real type array (not complex)
|
|
144
|
+
* Since numpy-ts doesn't support complex numbers, always returns true
|
|
145
|
+
* @param _a - Input array storage (unused)
|
|
146
|
+
* @returns true
|
|
147
|
+
*/
|
|
148
|
+
export declare function isrealobj(_a: ArrayStorage): boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Test element-wise for negative infinity
|
|
151
|
+
* @param a - Input array storage
|
|
152
|
+
* @returns Boolean array
|
|
153
|
+
*/
|
|
154
|
+
export declare function isneginf(a: ArrayStorage): ArrayStorage;
|
|
155
|
+
/**
|
|
156
|
+
* Test element-wise for positive infinity
|
|
157
|
+
* @param a - Input array storage
|
|
158
|
+
* @returns Boolean array
|
|
159
|
+
*/
|
|
160
|
+
export declare function isposinf(a: ArrayStorage): ArrayStorage;
|
|
161
|
+
/**
|
|
162
|
+
* Check if array is Fortran contiguous (column-major order)
|
|
163
|
+
* @param a - Input array storage
|
|
164
|
+
* @returns true if F-contiguous
|
|
165
|
+
*/
|
|
166
|
+
export declare function isfortran(a: ArrayStorage): boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Returns complex array with complex parts close to zero set to real
|
|
169
|
+
* Since numpy-ts doesn't support complex numbers, returns copy
|
|
170
|
+
* @param a - Input array storage
|
|
171
|
+
* @param _tol - Tolerance (unused, for API compatibility)
|
|
172
|
+
* @returns Copy of input array
|
|
173
|
+
*/
|
|
174
|
+
export declare function real_if_close(a: ArrayStorage, _tol?: number): ArrayStorage;
|
|
175
|
+
/**
|
|
176
|
+
* Check if element is a scalar type
|
|
177
|
+
* @param val - Value to check
|
|
178
|
+
* @returns true if scalar
|
|
179
|
+
*/
|
|
180
|
+
export declare function isscalar(val: unknown): boolean;
|
|
181
|
+
/**
|
|
182
|
+
* Check if object is iterable
|
|
183
|
+
* @param obj - Object to check
|
|
184
|
+
* @returns true if iterable
|
|
185
|
+
*/
|
|
186
|
+
export declare function iterable(obj: unknown): boolean;
|
|
187
|
+
/**
|
|
188
|
+
* Check if dtype meets specified criteria
|
|
189
|
+
* @param dtype - Dtype to check
|
|
190
|
+
* @param kind - Kind of dtype ('b' bool, 'i' int, 'u' uint, 'f' float)
|
|
191
|
+
* @returns true if dtype matches kind
|
|
192
|
+
*/
|
|
193
|
+
export declare function isdtype(dtype: DType, kind: string): boolean;
|
|
194
|
+
/**
|
|
195
|
+
* Find the dtype that can represent both input dtypes
|
|
196
|
+
* @param dtype1 - First dtype
|
|
197
|
+
* @param dtype2 - Second dtype
|
|
198
|
+
* @returns Promoted dtype
|
|
199
|
+
*/
|
|
200
|
+
export declare function promote_types(dtype1: DType, dtype2: DType): DType;
|
|
201
|
+
//# sourceMappingURL=logic.d.ts.map
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Random number generation module
|
|
3
|
+
*
|
|
4
|
+
* Implements NumPy-compatible random functions:
|
|
5
|
+
* - Legacy API (np.random.seed, random, rand, uniform, etc.) uses MT19937
|
|
6
|
+
* - Modern API (np.random.default_rng) uses PCG64 with SeedSequence
|
|
7
|
+
*
|
|
8
|
+
* Both implementations produce identical output to NumPy when seeded.
|
|
9
|
+
*/
|
|
10
|
+
import { ArrayStorage } from '../core/storage';
|
|
11
|
+
import { type DType } from '../core/dtype';
|
|
12
|
+
/**
|
|
13
|
+
* Random number generator class (matches NumPy's Generator from default_rng)
|
|
14
|
+
*/
|
|
15
|
+
export declare class Generator {
|
|
16
|
+
private _pcgState;
|
|
17
|
+
constructor(seedValue?: number);
|
|
18
|
+
private _randomFloat;
|
|
19
|
+
random(size?: number | number[]): ArrayStorage | number;
|
|
20
|
+
integers(low: number, high?: number, size?: number | number[]): ArrayStorage | number;
|
|
21
|
+
standard_normal(size?: number | number[]): ArrayStorage | number;
|
|
22
|
+
normal(loc?: number, scale?: number, size?: number | number[]): ArrayStorage | number;
|
|
23
|
+
uniform(low?: number, high?: number, size?: number | number[]): ArrayStorage | number;
|
|
24
|
+
choice(a: number | ArrayStorage, size?: number | number[], replace?: boolean, p?: ArrayStorage | number[]): ArrayStorage | number;
|
|
25
|
+
permutation(x: number | ArrayStorage): ArrayStorage;
|
|
26
|
+
shuffle(x: ArrayStorage): void;
|
|
27
|
+
exponential(scale?: number, size?: number | number[]): ArrayStorage | number;
|
|
28
|
+
poisson(lam?: number, size?: number | number[]): ArrayStorage | number;
|
|
29
|
+
binomial(n: number, p: number, size?: number | number[]): ArrayStorage | number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Create a new Generator instance (matches np.random.default_rng)
|
|
33
|
+
* @param seedValue - Optional seed value
|
|
34
|
+
*/
|
|
35
|
+
export declare function default_rng(seedValue?: number): Generator;
|
|
36
|
+
/**
|
|
37
|
+
* Seed the random number generator (legacy API)
|
|
38
|
+
* @param seedValue - Seed value (integer)
|
|
39
|
+
*/
|
|
40
|
+
export declare function seed(seedValue?: number | null): void;
|
|
41
|
+
/**
|
|
42
|
+
* Get the internal state of the random number generator
|
|
43
|
+
* @returns State object that can be used with set_state
|
|
44
|
+
*/
|
|
45
|
+
export declare function get_state(): {
|
|
46
|
+
mt: number[];
|
|
47
|
+
mti: number;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Set the internal state of the random number generator
|
|
51
|
+
* @param state - State object from get_state
|
|
52
|
+
*/
|
|
53
|
+
export declare function set_state(state: {
|
|
54
|
+
mt: number[];
|
|
55
|
+
mti: number;
|
|
56
|
+
}): void;
|
|
57
|
+
/**
|
|
58
|
+
* Generate random floats in the half-open interval [0.0, 1.0)
|
|
59
|
+
* @param size - Output shape. If not provided, returns a single float.
|
|
60
|
+
*/
|
|
61
|
+
export declare function random(size?: number | number[]): ArrayStorage | number;
|
|
62
|
+
/**
|
|
63
|
+
* Random values in a given shape (alias for random with shape)
|
|
64
|
+
* @param d0, d1, ..., dn - The dimensions of the returned array
|
|
65
|
+
*/
|
|
66
|
+
export declare function rand(...shape: number[]): ArrayStorage | number;
|
|
67
|
+
/**
|
|
68
|
+
* Return random floats from standard normal distribution
|
|
69
|
+
* @param d0, d1, ..., dn - The dimensions of the returned array
|
|
70
|
+
*/
|
|
71
|
+
export declare function randn(...shape: number[]): ArrayStorage | number;
|
|
72
|
+
/**
|
|
73
|
+
* Return random integers from low (inclusive) to high (exclusive)
|
|
74
|
+
* @param low - Lowest integer (or high if high is not provided)
|
|
75
|
+
* @param high - One above the highest integer (optional)
|
|
76
|
+
* @param size - Output shape
|
|
77
|
+
* @param dtype - Output dtype (default 'int64')
|
|
78
|
+
*/
|
|
79
|
+
export declare function randint(low: number, high?: number | null, size?: number | number[], dtype?: DType): ArrayStorage | number;
|
|
80
|
+
/**
|
|
81
|
+
* Draw samples from a uniform distribution
|
|
82
|
+
* @param low - Lower boundary (default 0)
|
|
83
|
+
* @param high - Upper boundary (default 1)
|
|
84
|
+
* @param size - Output shape
|
|
85
|
+
*/
|
|
86
|
+
export declare function uniform(low?: number, high?: number, size?: number | number[]): ArrayStorage | number;
|
|
87
|
+
/**
|
|
88
|
+
* Draw samples from a normal (Gaussian) distribution
|
|
89
|
+
* @param loc - Mean of the distribution (default 0)
|
|
90
|
+
* @param scale - Standard deviation (default 1)
|
|
91
|
+
* @param size - Output shape
|
|
92
|
+
*/
|
|
93
|
+
export declare function normal(loc?: number, scale?: number, size?: number | number[]): ArrayStorage | number;
|
|
94
|
+
/**
|
|
95
|
+
* Draw samples from a standard normal distribution (mean=0, std=1)
|
|
96
|
+
* @param size - Output shape
|
|
97
|
+
*/
|
|
98
|
+
export declare function standard_normal(size?: number | number[]): ArrayStorage | number;
|
|
99
|
+
/**
|
|
100
|
+
* Draw samples from an exponential distribution
|
|
101
|
+
* @param scale - The scale parameter (beta = 1/lambda) (default 1)
|
|
102
|
+
* @param size - Output shape
|
|
103
|
+
*/
|
|
104
|
+
export declare function exponential(scale?: number, size?: number | number[]): ArrayStorage | number;
|
|
105
|
+
/**
|
|
106
|
+
* Draw samples from a Poisson distribution
|
|
107
|
+
* @param lam - Expected number of events (lambda) (default 1)
|
|
108
|
+
* @param size - Output shape
|
|
109
|
+
*/
|
|
110
|
+
export declare function poisson(lam?: number, size?: number | number[]): ArrayStorage | number;
|
|
111
|
+
/**
|
|
112
|
+
* Draw samples from a binomial distribution
|
|
113
|
+
* @param n - Number of trials
|
|
114
|
+
* @param p - Probability of success
|
|
115
|
+
* @param size - Output shape
|
|
116
|
+
*/
|
|
117
|
+
export declare function binomial(n: number, p: number, size?: number | number[]): ArrayStorage | number;
|
|
118
|
+
/**
|
|
119
|
+
* Generate a random sample from a given 1-D array
|
|
120
|
+
* @param a - Input array or int. If int, samples from arange(a)
|
|
121
|
+
* @param size - Output shape
|
|
122
|
+
* @param replace - Whether sampling with replacement (default true)
|
|
123
|
+
* @param p - Probabilities associated with each entry
|
|
124
|
+
*/
|
|
125
|
+
export declare function choice(a: number | ArrayStorage, size?: number | number[], replace?: boolean, p?: ArrayStorage | number[]): ArrayStorage | number;
|
|
126
|
+
/**
|
|
127
|
+
* Randomly permute a sequence, or return a permuted range
|
|
128
|
+
* @param x - Input array or int. If int, returns permutation of arange(x)
|
|
129
|
+
*/
|
|
130
|
+
export declare function permutation(x: number | ArrayStorage): ArrayStorage;
|
|
131
|
+
/**
|
|
132
|
+
* Modify a sequence in-place by shuffling its contents
|
|
133
|
+
* @param x - Array to be shuffled
|
|
134
|
+
*/
|
|
135
|
+
export declare function shuffle(x: ArrayStorage): void;
|
|
136
|
+
//# sourceMappingURL=random.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rounding operations
|
|
3
|
+
*
|
|
4
|
+
* Pure functions for element-wise rounding operations:
|
|
5
|
+
* around, ceil, fix, floor, rint, round, trunc
|
|
6
|
+
*/
|
|
7
|
+
import { ArrayStorage } from '../core/storage';
|
|
8
|
+
/**
|
|
9
|
+
* Round an array to the given number of decimals
|
|
10
|
+
*/
|
|
11
|
+
export declare function around(a: ArrayStorage, decimals?: number): ArrayStorage;
|
|
12
|
+
/**
|
|
13
|
+
* Return the ceiling of the input, element-wise
|
|
14
|
+
*/
|
|
15
|
+
export declare function ceil(a: ArrayStorage): ArrayStorage;
|
|
16
|
+
/**
|
|
17
|
+
* Round to nearest integer towards zero
|
|
18
|
+
*/
|
|
19
|
+
export declare function fix(a: ArrayStorage): ArrayStorage;
|
|
20
|
+
/**
|
|
21
|
+
* Return the floor of the input, element-wise
|
|
22
|
+
*/
|
|
23
|
+
export declare function floor(a: ArrayStorage): ArrayStorage;
|
|
24
|
+
/**
|
|
25
|
+
* Round elements of the array to the nearest integer (banker's rounding)
|
|
26
|
+
*/
|
|
27
|
+
export declare function rint(a: ArrayStorage): ArrayStorage;
|
|
28
|
+
/**
|
|
29
|
+
* Alias for around
|
|
30
|
+
*/
|
|
31
|
+
export declare function round(a: ArrayStorage, decimals?: number): ArrayStorage;
|
|
32
|
+
/**
|
|
33
|
+
* Return the truncated value of the input, element-wise
|
|
34
|
+
*/
|
|
35
|
+
export declare function trunc(a: ArrayStorage): ArrayStorage;
|
|
36
|
+
//# sourceMappingURL=rounding.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Set operations
|
|
3
|
+
*/
|
|
4
|
+
import { ArrayStorage } from '../core/storage';
|
|
5
|
+
/**
|
|
6
|
+
* Find the unique elements of an array
|
|
7
|
+
*/
|
|
8
|
+
export declare function unique(a: ArrayStorage, returnIndex?: boolean, returnInverse?: boolean, returnCounts?: boolean): ArrayStorage | {
|
|
9
|
+
values: ArrayStorage;
|
|
10
|
+
indices?: ArrayStorage;
|
|
11
|
+
inverse?: ArrayStorage;
|
|
12
|
+
counts?: ArrayStorage;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Test whether each element of a 1-D array is also present in a second array
|
|
16
|
+
*/
|
|
17
|
+
export declare function in1d(ar1: ArrayStorage, ar2: ArrayStorage): ArrayStorage;
|
|
18
|
+
/**
|
|
19
|
+
* Find the intersection of two arrays
|
|
20
|
+
*/
|
|
21
|
+
export declare function intersect1d(ar1: ArrayStorage, ar2: ArrayStorage): ArrayStorage;
|
|
22
|
+
/**
|
|
23
|
+
* Test whether each element of an ND array is also present in a second array
|
|
24
|
+
*/
|
|
25
|
+
export declare function isin(element: ArrayStorage, testElements: ArrayStorage): ArrayStorage;
|
|
26
|
+
/**
|
|
27
|
+
* Find the set difference of two arrays
|
|
28
|
+
*/
|
|
29
|
+
export declare function setdiff1d(ar1: ArrayStorage, ar2: ArrayStorage): ArrayStorage;
|
|
30
|
+
/**
|
|
31
|
+
* Find the set exclusive-or of two arrays
|
|
32
|
+
*/
|
|
33
|
+
export declare function setxor1d(ar1: ArrayStorage, ar2: ArrayStorage): ArrayStorage;
|
|
34
|
+
/**
|
|
35
|
+
* Find the union of two arrays
|
|
36
|
+
*/
|
|
37
|
+
export declare function union1d(ar1: ArrayStorage, ar2: ArrayStorage): ArrayStorage;
|
|
38
|
+
//# sourceMappingURL=sets.d.ts.map
|
|
@@ -56,6 +56,14 @@ export declare function sort_complex(storage: ArrayStorage): ArrayStorage;
|
|
|
56
56
|
* @returns Tuple of arrays, one for each dimension
|
|
57
57
|
*/
|
|
58
58
|
export declare function nonzero(storage: ArrayStorage): ArrayStorage[];
|
|
59
|
+
/**
|
|
60
|
+
* Find the indices of array elements that are non-zero, grouped by element
|
|
61
|
+
* Returns a 2D array where each row is the index of a non-zero element.
|
|
62
|
+
* This is equivalent to transpose(nonzero(a)).
|
|
63
|
+
* @param storage - Input array storage
|
|
64
|
+
* @returns 2D array of shape (N, ndim) where N is number of non-zero elements
|
|
65
|
+
*/
|
|
66
|
+
export declare function argwhere(storage: ArrayStorage): ArrayStorage;
|
|
59
67
|
/**
|
|
60
68
|
* Return indices of non-zero elements in flattened array
|
|
61
69
|
* @param storage - Input array storage
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Statistics operations (histogram, bincount, correlate, cov, etc.)
|
|
3
|
+
*
|
|
4
|
+
* Pure functions for statistical analysis.
|
|
5
|
+
* @module ops/statistics
|
|
6
|
+
*/
|
|
7
|
+
import { ArrayStorage } from '../core/storage';
|
|
8
|
+
/**
|
|
9
|
+
* Count number of occurrences of each value in array of non-negative ints.
|
|
10
|
+
*
|
|
11
|
+
* @param x - Input array (must contain non-negative integers)
|
|
12
|
+
* @param weights - Optional weights, same shape as x
|
|
13
|
+
* @param minlength - Minimum number of bins for output (default: 0)
|
|
14
|
+
* @returns Array of bin counts
|
|
15
|
+
*/
|
|
16
|
+
export declare function bincount(x: ArrayStorage, weights?: ArrayStorage, minlength?: number): ArrayStorage;
|
|
17
|
+
/**
|
|
18
|
+
* Return the indices of the bins to which each value in input array belongs.
|
|
19
|
+
*
|
|
20
|
+
* @param x - Input array to be binned
|
|
21
|
+
* @param bins - Array of bins (monotonically increasing or decreasing)
|
|
22
|
+
* @param right - If true, intervals are closed on the right (default: false)
|
|
23
|
+
* @returns Array of bin indices
|
|
24
|
+
*/
|
|
25
|
+
export declare function digitize(x: ArrayStorage, bins: ArrayStorage, right?: boolean): ArrayStorage;
|
|
26
|
+
/**
|
|
27
|
+
* Compute the histogram of a set of data.
|
|
28
|
+
*
|
|
29
|
+
* @param a - Input data (flattened if not 1D)
|
|
30
|
+
* @param bins - Number of bins (default: 10) or array of bin edges
|
|
31
|
+
* @param range - Lower and upper range of bins. If not provided, uses [a.min(), a.max()]
|
|
32
|
+
* @param density - If true, return probability density function (default: false)
|
|
33
|
+
* @param weights - Optional weights for each data point
|
|
34
|
+
* @returns Tuple of [hist, bin_edges]
|
|
35
|
+
*/
|
|
36
|
+
export declare function histogram(a: ArrayStorage, bins?: number | ArrayStorage, range?: [number, number], density?: boolean, weights?: ArrayStorage): {
|
|
37
|
+
hist: ArrayStorage;
|
|
38
|
+
bin_edges: ArrayStorage;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Compute the bi-dimensional histogram of two data samples.
|
|
42
|
+
*
|
|
43
|
+
* @param x - Array of x coordinates
|
|
44
|
+
* @param y - Array of y coordinates (must have same length as x)
|
|
45
|
+
* @param bins - Number of bins or [nx, ny] or [x_edges, y_edges]
|
|
46
|
+
* @param range - [[xmin, xmax], [ymin, ymax]]
|
|
47
|
+
* @param density - If true, return probability density function
|
|
48
|
+
* @param weights - Optional weights for each data point
|
|
49
|
+
* @returns Object with hist, x_edges, y_edges
|
|
50
|
+
*/
|
|
51
|
+
export declare function histogram2d(x: ArrayStorage, y: ArrayStorage, bins?: number | [number, number] | [ArrayStorage, ArrayStorage], range?: [[number, number], [number, number]], density?: boolean, weights?: ArrayStorage): {
|
|
52
|
+
hist: ArrayStorage;
|
|
53
|
+
x_edges: ArrayStorage;
|
|
54
|
+
y_edges: ArrayStorage;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Compute the multidimensional histogram of some data.
|
|
58
|
+
*
|
|
59
|
+
* @param sample - Array of shape (N, D) where N is number of samples and D is number of dimensions
|
|
60
|
+
* @param bins - Number of bins for all axes, or array of bin counts per axis
|
|
61
|
+
* @param range - Array of [min, max] for each dimension
|
|
62
|
+
* @param density - If true, return probability density function
|
|
63
|
+
* @param weights - Optional weights for each sample
|
|
64
|
+
* @returns Object with hist and edges (array of edge arrays)
|
|
65
|
+
*/
|
|
66
|
+
export declare function histogramdd(sample: ArrayStorage, bins?: number | number[], range?: [number, number][], density?: boolean, weights?: ArrayStorage): {
|
|
67
|
+
hist: ArrayStorage;
|
|
68
|
+
edges: ArrayStorage[];
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Cross-correlation of two 1-dimensional sequences.
|
|
72
|
+
*
|
|
73
|
+
* @param a - First input sequence
|
|
74
|
+
* @param v - Second input sequence
|
|
75
|
+
* @param mode - 'full', 'same', or 'valid' (default: 'full')
|
|
76
|
+
* @returns Cross-correlation of a and v
|
|
77
|
+
*/
|
|
78
|
+
export declare function correlate(a: ArrayStorage, v: ArrayStorage, mode?: 'full' | 'same' | 'valid'): ArrayStorage;
|
|
79
|
+
/**
|
|
80
|
+
* Discrete, linear convolution of two one-dimensional sequences.
|
|
81
|
+
*
|
|
82
|
+
* @param a - First input sequence
|
|
83
|
+
* @param v - Second input sequence
|
|
84
|
+
* @param mode - 'full', 'same', or 'valid' (default: 'full')
|
|
85
|
+
* @returns Convolution of a and v
|
|
86
|
+
*/
|
|
87
|
+
export declare function convolve(a: ArrayStorage, v: ArrayStorage, mode?: 'full' | 'same' | 'valid'): ArrayStorage;
|
|
88
|
+
/**
|
|
89
|
+
* Estimate a covariance matrix.
|
|
90
|
+
*
|
|
91
|
+
* @param m - Input array (1D or 2D). Each row represents a variable, columns are observations.
|
|
92
|
+
* @param y - Optional second array (for 2 variable case)
|
|
93
|
+
* @param rowvar - If true, each row is a variable (default: true)
|
|
94
|
+
* @param bias - If true, use N for normalization; if false, use N-1 (default: false)
|
|
95
|
+
* @param ddof - Delta degrees of freedom (overrides bias if provided)
|
|
96
|
+
* @returns Covariance matrix
|
|
97
|
+
*/
|
|
98
|
+
export declare function cov(m: ArrayStorage, y?: ArrayStorage, rowvar?: boolean, bias?: boolean, ddof?: number): ArrayStorage;
|
|
99
|
+
/**
|
|
100
|
+
* Return Pearson product-moment correlation coefficients.
|
|
101
|
+
*
|
|
102
|
+
* @param x - Input array (1D or 2D)
|
|
103
|
+
* @param y - Optional second array (for 2 variable case)
|
|
104
|
+
* @param rowvar - If true, each row is a variable (default: true)
|
|
105
|
+
* @returns Correlation coefficient matrix
|
|
106
|
+
*/
|
|
107
|
+
export declare function corrcoef(x: ArrayStorage, y?: ArrayStorage, rowvar?: boolean): ArrayStorage;
|
|
108
|
+
//# sourceMappingURL=statistics.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "numpy-ts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Complete NumPy implementation for TypeScript and JavaScript (under construction)",
|
|
5
5
|
"main": "dist/numpy-ts.node.cjs",
|
|
6
6
|
"browser": "dist/numpy-ts.browser.js",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"license": "MIT",
|
|
91
91
|
"repository": {
|
|
92
92
|
"type": "git",
|
|
93
|
-
"url": "https://github.com/dupontcyborg/numpy-ts.git"
|
|
93
|
+
"url": "git+https://github.com/dupontcyborg/numpy-ts.git"
|
|
94
94
|
},
|
|
95
95
|
"bugs": {
|
|
96
96
|
"url": "https://github.com/dupontcyborg/numpy-ts/issues"
|