numpy-ts 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 +45 -26
- 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/complex.d.ts +94 -0
- package/dist/types/core/dtype.d.ts +62 -3
- package/dist/types/core/ndarray.d.ts +663 -37
- package/dist/types/core/storage.d.ts +15 -4
- package/dist/types/index.d.ts +41 -1
- package/dist/types/ops/advanced.d.ts +7 -0
- package/dist/types/ops/arithmetic.d.ts +53 -0
- package/dist/types/ops/comparison.d.ts +6 -0
- package/dist/types/ops/complex.d.ts +65 -0
- package/dist/types/ops/exponential.d.ts +9 -0
- package/dist/types/ops/hyperbolic.d.ts +6 -0
- package/dist/types/ops/linalg.d.ts +6 -5
- package/dist/types/ops/logic.d.ts +219 -0
- package/dist/types/ops/random.d.ts +136 -0
- package/dist/types/ops/reduction.d.ts +26 -18
- package/dist/types/ops/rounding.d.ts +3 -0
- package/dist/types/ops/sorting.d.ts +8 -0
- package/dist/types/ops/statistics.d.ts +108 -0
- package/dist/types/ops/trig.d.ts +6 -0
- package/package.json +2 -2
|
@@ -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
|
|
@@ -5,30 +5,29 @@
|
|
|
5
5
|
* @module ops/reduction
|
|
6
6
|
*/
|
|
7
7
|
import { ArrayStorage } from '../core/storage';
|
|
8
|
+
import { Complex } from '../core/complex';
|
|
8
9
|
/**
|
|
9
10
|
* Sum array elements over a given axis
|
|
10
11
|
*/
|
|
11
|
-
export declare function sum(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number;
|
|
12
|
+
export declare function sum(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number | Complex;
|
|
12
13
|
/**
|
|
13
14
|
* Compute the arithmetic mean along the specified axis
|
|
14
15
|
* Note: mean() returns float64 for integer dtypes, matching NumPy behavior
|
|
16
|
+
* For complex arrays, returns complex mean
|
|
15
17
|
*/
|
|
16
|
-
export declare function mean(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number;
|
|
18
|
+
export declare function mean(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number | Complex;
|
|
17
19
|
/**
|
|
18
20
|
* Return the maximum along a given axis
|
|
19
21
|
*/
|
|
20
|
-
export declare function max(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number;
|
|
22
|
+
export declare function max(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number | Complex;
|
|
21
23
|
/**
|
|
22
24
|
* Product array elements over a given axis
|
|
23
25
|
*/
|
|
24
|
-
export declare function prod(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number;
|
|
26
|
+
export declare function prod(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number | Complex;
|
|
25
27
|
/**
|
|
26
28
|
* Return the minimum along a given axis
|
|
27
29
|
*/
|
|
28
|
-
export declare function min(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number;
|
|
29
|
-
/**
|
|
30
|
-
* Return the indices of the minimum values along a given axis
|
|
31
|
-
*/
|
|
30
|
+
export declare function min(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number | Complex;
|
|
32
31
|
export declare function argmin(storage: ArrayStorage, axis?: number): ArrayStorage | number;
|
|
33
32
|
/**
|
|
34
33
|
* Return the indices of the maximum values along a given axis
|
|
@@ -40,6 +39,9 @@ export declare function argmax(storage: ArrayStorage, axis?: number): ArrayStora
|
|
|
40
39
|
* @param axis - Axis along which to compute variance
|
|
41
40
|
* @param ddof - Delta degrees of freedom (default: 0)
|
|
42
41
|
* @param keepdims - Keep dimensions (default: false)
|
|
42
|
+
*
|
|
43
|
+
* For complex arrays: Var(X) = E[|X - E[X]|²] where |z|² = re² + im²
|
|
44
|
+
* Returns real values (float64) for both real and complex input
|
|
43
45
|
*/
|
|
44
46
|
export declare function variance(storage: ArrayStorage, axis?: number, ddof?: number, keepdims?: boolean): ArrayStorage | number;
|
|
45
47
|
/**
|
|
@@ -48,6 +50,9 @@ export declare function variance(storage: ArrayStorage, axis?: number, ddof?: nu
|
|
|
48
50
|
* @param axis - Axis along which to compute std
|
|
49
51
|
* @param ddof - Delta degrees of freedom (default: 0)
|
|
50
52
|
* @param keepdims - Keep dimensions (default: false)
|
|
53
|
+
*
|
|
54
|
+
* For complex arrays: returns sqrt(Var(X)) where Var(X) = E[|X - E[X]|²]
|
|
55
|
+
* Returns real values (float64) for both real and complex input
|
|
51
56
|
*/
|
|
52
57
|
export declare function std(storage: ArrayStorage, axis?: number, ddof?: number, keepdims?: boolean): ArrayStorage | number;
|
|
53
58
|
/**
|
|
@@ -60,16 +65,19 @@ export declare function all(storage: ArrayStorage, axis?: number, keepdims?: boo
|
|
|
60
65
|
export declare function any(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | boolean;
|
|
61
66
|
/**
|
|
62
67
|
* Return cumulative sum of elements along a given axis
|
|
68
|
+
* For complex arrays: returns complex cumulative sum
|
|
63
69
|
*/
|
|
64
70
|
export declare function cumsum(storage: ArrayStorage, axis?: number): ArrayStorage;
|
|
65
71
|
/**
|
|
66
72
|
* Return cumulative product of elements along a given axis
|
|
73
|
+
* For complex arrays: returns complex cumulative product
|
|
74
|
+
* Complex multiplication: (a+bi)(c+di) = (ac-bd) + (ad+bc)i
|
|
67
75
|
*/
|
|
68
76
|
export declare function cumprod(storage: ArrayStorage, axis?: number): ArrayStorage;
|
|
69
77
|
/**
|
|
70
78
|
* Peak to peak (maximum - minimum) value along a given axis
|
|
71
79
|
*/
|
|
72
|
-
export declare function ptp(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number;
|
|
80
|
+
export declare function ptp(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number | Complex;
|
|
73
81
|
/**
|
|
74
82
|
* Compute the median along the specified axis
|
|
75
83
|
*/
|
|
@@ -85,41 +93,40 @@ export declare function quantile(storage: ArrayStorage, q: number, axis?: number
|
|
|
85
93
|
/**
|
|
86
94
|
* Compute the weighted average along the specified axis
|
|
87
95
|
*/
|
|
88
|
-
export declare function average(storage: ArrayStorage, axis?: number, weights?: ArrayStorage, keepdims?: boolean): ArrayStorage | number;
|
|
89
|
-
|
|
90
|
-
* Return sum of elements, treating NaNs as zero
|
|
91
|
-
*/
|
|
92
|
-
export declare function nansum(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number;
|
|
96
|
+
export declare function average(storage: ArrayStorage, axis?: number, weights?: ArrayStorage, keepdims?: boolean): ArrayStorage | number | Complex;
|
|
97
|
+
export declare function nansum(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number | Complex;
|
|
93
98
|
/**
|
|
94
99
|
* Return product of elements, treating NaNs as one
|
|
95
100
|
*/
|
|
96
|
-
export declare function nanprod(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number;
|
|
101
|
+
export declare function nanprod(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number | Complex;
|
|
97
102
|
/**
|
|
98
103
|
* Compute mean ignoring NaN values
|
|
99
104
|
*/
|
|
100
|
-
export declare function nanmean(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number;
|
|
105
|
+
export declare function nanmean(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number | Complex;
|
|
101
106
|
/**
|
|
102
107
|
* Compute variance ignoring NaN values
|
|
103
108
|
*/
|
|
104
109
|
export declare function nanvar(storage: ArrayStorage, axis?: number, ddof?: number, keepdims?: boolean): ArrayStorage | number;
|
|
105
110
|
/**
|
|
106
111
|
* Compute standard deviation ignoring NaN values
|
|
112
|
+
* For complex arrays: returns sqrt of variance (always real values)
|
|
107
113
|
*/
|
|
108
114
|
export declare function nanstd(storage: ArrayStorage, axis?: number, ddof?: number, keepdims?: boolean): ArrayStorage | number;
|
|
109
115
|
/**
|
|
110
116
|
* Return minimum ignoring NaN values
|
|
111
117
|
*/
|
|
112
|
-
export declare function nanmin(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number;
|
|
118
|
+
export declare function nanmin(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number | Complex;
|
|
113
119
|
/**
|
|
114
120
|
* Return maximum ignoring NaN values
|
|
115
121
|
*/
|
|
116
|
-
export declare function nanmax(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number;
|
|
122
|
+
export declare function nanmax(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number | Complex;
|
|
117
123
|
/**
|
|
118
124
|
* Return indices of minimum value, ignoring NaNs
|
|
119
125
|
*/
|
|
120
126
|
export declare function nanargmin(storage: ArrayStorage, axis?: number): ArrayStorage | number;
|
|
121
127
|
/**
|
|
122
128
|
* Return indices of maximum value, ignoring NaNs
|
|
129
|
+
* For complex arrays: uses lexicographic ordering (real first, then imaginary)
|
|
123
130
|
*/
|
|
124
131
|
export declare function nanargmax(storage: ArrayStorage, axis?: number): ArrayStorage | number;
|
|
125
132
|
/**
|
|
@@ -128,6 +135,7 @@ export declare function nanargmax(storage: ArrayStorage, axis?: number): ArraySt
|
|
|
128
135
|
export declare function nancumsum(storage: ArrayStorage, axis?: number): ArrayStorage;
|
|
129
136
|
/**
|
|
130
137
|
* Return cumulative product, treating NaNs as one
|
|
138
|
+
* For complex arrays: NaN values (either part NaN) are treated as 1+0i
|
|
131
139
|
*/
|
|
132
140
|
export declare function nancumprod(storage: ArrayStorage, axis?: number): ArrayStorage;
|
|
133
141
|
/**
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Pure functions for element-wise rounding operations:
|
|
5
5
|
* around, ceil, fix, floor, rint, round, trunc
|
|
6
|
+
*
|
|
7
|
+
* Note: Rounding operations are not defined for complex numbers.
|
|
8
|
+
* All functions throw TypeError for complex dtypes.
|
|
6
9
|
*/
|
|
7
10
|
import { ArrayStorage } from '../core/storage';
|
|
8
11
|
/**
|
|
@@ -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/dist/types/ops/trig.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { ArrayStorage } from '../core/storage';
|
|
|
11
11
|
/**
|
|
12
12
|
* Sine of each element (element-wise)
|
|
13
13
|
* NumPy behavior: Always promotes to float64 for integer types
|
|
14
|
+
* For complex: sin(a+bi) = sin(a)cosh(b) + i*cos(a)sinh(b)
|
|
14
15
|
*
|
|
15
16
|
* @param a - Input array storage (angles in radians)
|
|
16
17
|
* @returns Result storage with sin applied
|
|
@@ -19,6 +20,7 @@ export declare function sin(a: ArrayStorage): ArrayStorage;
|
|
|
19
20
|
/**
|
|
20
21
|
* Cosine of each element (element-wise)
|
|
21
22
|
* NumPy behavior: Always promotes to float64 for integer types
|
|
23
|
+
* For complex: cos(a+bi) = cos(a)cosh(b) - i*sin(a)sinh(b)
|
|
22
24
|
*
|
|
23
25
|
* @param a - Input array storage (angles in radians)
|
|
24
26
|
* @returns Result storage with cos applied
|
|
@@ -27,6 +29,7 @@ export declare function cos(a: ArrayStorage): ArrayStorage;
|
|
|
27
29
|
/**
|
|
28
30
|
* Tangent of each element (element-wise)
|
|
29
31
|
* NumPy behavior: Always promotes to float64 for integer types
|
|
32
|
+
* For complex: tan(a+bi) = (sin(2a) + i*sinh(2b)) / (cos(2a) + cosh(2b))
|
|
30
33
|
*
|
|
31
34
|
* @param a - Input array storage (angles in radians)
|
|
32
35
|
* @returns Result storage with tan applied
|
|
@@ -35,6 +38,7 @@ export declare function tan(a: ArrayStorage): ArrayStorage;
|
|
|
35
38
|
/**
|
|
36
39
|
* Inverse sine of each element (element-wise)
|
|
37
40
|
* NumPy behavior: Always promotes to float64 for integer types
|
|
41
|
+
* For complex: arcsin(z) = -i * log(iz + sqrt(1 - z²))
|
|
38
42
|
*
|
|
39
43
|
* @param a - Input array storage (values in range [-1, 1])
|
|
40
44
|
* @returns Result storage with arcsin applied (radians)
|
|
@@ -43,6 +47,7 @@ export declare function arcsin(a: ArrayStorage): ArrayStorage;
|
|
|
43
47
|
/**
|
|
44
48
|
* Inverse cosine of each element (element-wise)
|
|
45
49
|
* NumPy behavior: Always promotes to float64 for integer types
|
|
50
|
+
* For complex: arccos(z) = -i * log(z + i*sqrt(1 - z²))
|
|
46
51
|
*
|
|
47
52
|
* @param a - Input array storage (values in range [-1, 1])
|
|
48
53
|
* @returns Result storage with arccos applied (radians)
|
|
@@ -51,6 +56,7 @@ export declare function arccos(a: ArrayStorage): ArrayStorage;
|
|
|
51
56
|
/**
|
|
52
57
|
* Inverse tangent of each element (element-wise)
|
|
53
58
|
* NumPy behavior: Always promotes to float64 for integer types
|
|
59
|
+
* For complex: arctan(z) = (i/2) * log((1 - iz) / (1 + iz))
|
|
54
60
|
*
|
|
55
61
|
* @param a - Input array storage
|
|
56
62
|
* @returns Result storage with arctan applied (radians)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "numpy-ts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.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"
|