numpy-ts 0.11.0 → 0.13.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.
Files changed (145) hide show
  1. package/README.md +29 -25
  2. package/dist/esm/common/broadcasting.js +1 -0
  3. package/dist/esm/common/complex.js +1 -0
  4. package/dist/esm/common/dtype.js +1 -0
  5. package/dist/esm/common/internal/compute.js +1 -0
  6. package/dist/esm/common/internal/indexing.js +1 -0
  7. package/dist/esm/common/ndarray-core.js +1 -0
  8. package/dist/esm/common/ops/advanced.js +1 -0
  9. package/dist/esm/common/ops/arithmetic.js +1 -0
  10. package/dist/esm/common/ops/bitwise.js +1 -0
  11. package/dist/esm/common/ops/comparison.js +1 -0
  12. package/dist/esm/common/ops/complex.js +1 -0
  13. package/dist/esm/common/ops/exponential.js +1 -0
  14. package/dist/esm/common/ops/fft.js +1 -0
  15. package/dist/esm/common/ops/formatting.js +2 -0
  16. package/dist/esm/common/ops/gradient.js +1 -0
  17. package/dist/esm/common/ops/hyperbolic.js +1 -0
  18. package/dist/esm/common/ops/linalg.js +2 -0
  19. package/dist/esm/common/ops/logic.js +1 -0
  20. package/dist/esm/common/ops/random.js +1 -0
  21. package/dist/esm/common/ops/reduction.js +1 -0
  22. package/dist/esm/common/ops/rounding.js +1 -0
  23. package/dist/esm/common/ops/sets.js +1 -0
  24. package/dist/esm/common/ops/shape.js +1 -0
  25. package/dist/esm/common/ops/sorting.js +1 -0
  26. package/dist/esm/common/ops/statistics.js +1 -0
  27. package/dist/esm/common/ops/trig.js +1 -0
  28. package/dist/esm/common/slicing.js +1 -0
  29. package/dist/esm/common/storage.js +1 -0
  30. package/dist/esm/core/advanced.js +1 -0
  31. package/dist/esm/core/arithmetic.js +1 -0
  32. package/dist/esm/core/bitwise.js +1 -0
  33. package/dist/esm/core/complex.js +1 -0
  34. package/dist/esm/core/creation.js +1 -0
  35. package/dist/esm/core/formatting.js +1 -0
  36. package/dist/esm/core/gradient.js +1 -0
  37. package/dist/esm/core/index.js +1 -0
  38. package/dist/esm/core/linalg.js +1 -0
  39. package/dist/esm/core/logic.js +1 -0
  40. package/dist/esm/core/polynomial.js +1 -0
  41. package/dist/esm/core/reduction.js +1 -0
  42. package/dist/esm/core/rounding.js +1 -0
  43. package/dist/esm/core/sets.js +1 -0
  44. package/dist/esm/core/shape-extra.js +1 -0
  45. package/dist/esm/core/shape.js +1 -0
  46. package/dist/esm/core/sorting.js +1 -0
  47. package/dist/esm/core/statistics.js +1 -0
  48. package/dist/esm/core/trig.js +1 -0
  49. package/dist/esm/core/typechecking.js +1 -0
  50. package/dist/esm/core/types.js +1 -0
  51. package/dist/esm/core/utility.js +1 -0
  52. package/dist/esm/core.js +1 -0
  53. package/dist/esm/full/index.js +1 -0
  54. package/dist/esm/full/ndarray.js +1 -0
  55. package/dist/esm/index.js +1 -0
  56. package/dist/esm/io/index.js +1 -0
  57. package/dist/esm/io/npy/format.js +1 -0
  58. package/dist/esm/io/npy/index.js +1 -0
  59. package/dist/esm/io/npy/parser.js +1 -0
  60. package/dist/esm/io/npy/serializer.js +2 -0
  61. package/dist/esm/io/npz/index.js +1 -0
  62. package/dist/esm/io/npz/parser.js +1 -0
  63. package/dist/esm/io/npz/serializer.js +1 -0
  64. package/dist/esm/io/txt/index.js +1 -0
  65. package/dist/esm/io/txt/parser.js +1 -0
  66. package/dist/esm/io/txt/serializer.js +2 -0
  67. package/dist/esm/io/zip/index.js +1 -0
  68. package/dist/esm/io/zip/reader.js +1 -0
  69. package/dist/esm/io/zip/types.js +1 -0
  70. package/dist/esm/io/zip/writer.js +1 -0
  71. package/dist/esm/node.js +1 -0
  72. package/dist/numpy-ts.browser.js +5 -2
  73. package/dist/numpy-ts.node-io.cjs +5 -3
  74. package/dist/numpy-ts.node-io.cjs.map +4 -4
  75. package/dist/numpy-ts.node-io.mjs +5 -3
  76. package/dist/numpy-ts.node-io.mjs.map +4 -4
  77. package/dist/numpy-ts.node.cjs +5 -2
  78. package/dist/numpy-ts.node.cjs.map +4 -4
  79. package/dist/types/common/complex.d.ts +94 -0
  80. package/dist/types/{internal → common/internal}/compute.d.ts +1 -1
  81. package/dist/types/{internal → common/internal}/indexing.d.ts +6 -0
  82. package/dist/types/common/ndarray-core.d.ts +126 -0
  83. package/dist/types/{ops → common/ops}/advanced.d.ts +67 -2
  84. package/dist/types/{ops → common/ops}/arithmetic.d.ts +100 -1
  85. package/dist/types/{ops → common/ops}/bitwise.d.ts +31 -1
  86. package/dist/types/{ops → common/ops}/comparison.d.ts +1 -1
  87. package/dist/types/{ops → common/ops}/complex.d.ts +1 -1
  88. package/dist/types/{ops → common/ops}/exponential.d.ts +1 -1
  89. package/dist/types/common/ops/fft.d.ts +166 -0
  90. package/dist/types/common/ops/formatting.d.ts +229 -0
  91. package/dist/types/{ops → common/ops}/gradient.d.ts +1 -1
  92. package/dist/types/{ops → common/ops}/hyperbolic.d.ts +1 -1
  93. package/dist/types/{ops → common/ops}/linalg.d.ts +148 -3
  94. package/dist/types/{ops → common/ops}/logic.d.ts +2 -2
  95. package/dist/types/common/ops/random.d.ts +376 -0
  96. package/dist/types/{ops → common/ops}/reduction.d.ts +10 -2
  97. package/dist/types/{ops → common/ops}/rounding.d.ts +1 -1
  98. package/dist/types/common/ops/sets.d.ts +87 -0
  99. package/dist/types/{ops → common/ops}/shape.d.ts +14 -1
  100. package/dist/types/{ops → common/ops}/sorting.d.ts +1 -1
  101. package/dist/types/{ops → common/ops}/statistics.d.ts +23 -1
  102. package/dist/types/{ops → common/ops}/trig.d.ts +1 -1
  103. package/dist/types/{core → common}/storage.d.ts +1 -0
  104. package/dist/types/core/advanced.d.ts +54 -0
  105. package/dist/types/core/arithmetic.d.ts +110 -0
  106. package/dist/types/core/bitwise.d.ts +34 -0
  107. package/dist/types/core/complex.d.ts +15 -90
  108. package/dist/types/core/creation.d.ts +98 -0
  109. package/dist/types/core/formatting.d.ts +29 -0
  110. package/dist/types/core/gradient.d.ts +14 -0
  111. package/dist/types/core/index.d.ts +40 -0
  112. package/dist/types/core/linalg.d.ts +141 -0
  113. package/dist/types/core/logic.d.ts +72 -0
  114. package/dist/types/core/polynomial.d.ts +50 -0
  115. package/dist/types/core/reduction.d.ts +82 -0
  116. package/dist/types/core/rounding.d.ts +24 -0
  117. package/dist/types/core/sets.d.ts +48 -0
  118. package/dist/types/core/shape-extra.d.ts +24 -0
  119. package/dist/types/core/shape.d.ts +77 -0
  120. package/dist/types/core/sorting.d.ts +34 -0
  121. package/dist/types/core/statistics.d.ts +32 -0
  122. package/dist/types/core/trig.d.ts +58 -0
  123. package/dist/types/core/typechecking.d.ts +50 -0
  124. package/dist/types/core/types.d.ts +43 -0
  125. package/dist/types/core/utility.d.ts +30 -0
  126. package/dist/types/core.d.ts +30 -0
  127. package/dist/types/full/index.d.ts +603 -0
  128. package/dist/types/full/ndarray.d.ts +880 -0
  129. package/dist/types/index.d.ts +140 -26
  130. package/dist/types/io/npy/format.d.ts +1 -1
  131. package/dist/types/io/npy/parser.d.ts +3 -3
  132. package/dist/types/io/npy/serializer.d.ts +2 -2
  133. package/dist/types/io/npz/parser.d.ts +4 -4
  134. package/dist/types/io/npz/serializer.d.ts +6 -6
  135. package/dist/types/io/txt/parser.d.ts +5 -5
  136. package/dist/types/io/txt/serializer.d.ts +2 -2
  137. package/dist/types/node.d.ts +12 -8
  138. package/package.json +31 -30
  139. package/dist/numpy-ts.esm.js +0 -2
  140. package/dist/types/core/ndarray.d.ts +0 -3166
  141. package/dist/types/ops/random.d.ts +0 -136
  142. package/dist/types/ops/sets.d.ts +0 -38
  143. /package/dist/types/{core → common}/broadcasting.d.ts +0 -0
  144. /package/dist/types/{core → common}/dtype.d.ts +0 -0
  145. /package/dist/types/{core → common}/slicing.d.ts +0 -0
@@ -0,0 +1,376 @@
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 '../storage';
11
+ import { type DType } from '../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
+ /**
137
+ * Return random floats in the half-open interval [0.0, 1.0)
138
+ * Alias for random()
139
+ * @param size - Output shape
140
+ */
141
+ export declare function random_sample(size?: number | number[]): ArrayStorage | number;
142
+ /**
143
+ * Return random floats in the half-open interval [0.0, 1.0)
144
+ * Alias for random()
145
+ * @param size - Output shape
146
+ */
147
+ export declare function ranf(size?: number | number[]): ArrayStorage | number;
148
+ /**
149
+ * Return random floats in the half-open interval [0.0, 1.0)
150
+ * Alias for random()
151
+ * @param size - Output shape
152
+ */
153
+ export declare function sample(size?: number | number[]): ArrayStorage | number;
154
+ /**
155
+ * Return random integers between low and high, inclusive (DEPRECATED)
156
+ * @deprecated Use randint instead
157
+ * @param low - Lowest integer
158
+ * @param high - Highest integer (inclusive, unlike randint)
159
+ * @param size - Output shape
160
+ */
161
+ export declare function random_integers(low: number, high?: number, size?: number | number[]): ArrayStorage | number;
162
+ /**
163
+ * Return random bytes
164
+ * @param length - Number of bytes to return
165
+ */
166
+ export declare function bytes(length: number): Uint8Array;
167
+ interface BitGenerator {
168
+ name: string;
169
+ state: object;
170
+ }
171
+ /**
172
+ * Get the current bit generator
173
+ * @returns The current bit generator object
174
+ */
175
+ export declare function get_bit_generator(): BitGenerator;
176
+ /**
177
+ * Set the bit generator
178
+ * @param bitgen - The bit generator to use
179
+ */
180
+ export declare function set_bit_generator(bitgen: BitGenerator): void;
181
+ /**
182
+ * Draw samples from the standard exponential distribution (scale=1)
183
+ * @param size - Output shape
184
+ */
185
+ export declare function standard_exponential(size?: number | number[]): ArrayStorage | number;
186
+ /**
187
+ * Draw samples from a standard gamma distribution
188
+ * Uses Marsaglia and Tsang's method
189
+ * @param shape - Shape parameter (alpha, must be > 0)
190
+ * @param size - Output shape
191
+ */
192
+ export declare function standard_gamma(shape: number, size?: number | number[]): ArrayStorage | number;
193
+ /**
194
+ * Draw samples from a standard Cauchy distribution
195
+ * @param size - Output shape
196
+ */
197
+ export declare function standard_cauchy(size?: number | number[]): ArrayStorage | number;
198
+ /**
199
+ * Draw samples from a standard Student's t distribution with df degrees of freedom
200
+ * @param df - Degrees of freedom (must be > 0)
201
+ * @param size - Output shape
202
+ */
203
+ export declare function standard_t(df: number, size?: number | number[]): ArrayStorage | number;
204
+ /**
205
+ * Draw samples from a Gamma distribution
206
+ * @param shape - Shape parameter (k, alpha) (must be > 0)
207
+ * @param scale - Scale parameter (theta) (default 1.0)
208
+ * @param size - Output shape
209
+ */
210
+ export declare function gamma(shape: number, scale?: number, size?: number | number[]): ArrayStorage | number;
211
+ /**
212
+ * Draw samples from a Beta distribution
213
+ * @param a - Alpha parameter (must be > 0)
214
+ * @param b - Beta parameter (must be > 0)
215
+ * @param size - Output shape
216
+ */
217
+ export declare function beta(a: number, b: number, size?: number | number[]): ArrayStorage | number;
218
+ /**
219
+ * Draw samples from a Laplace (double exponential) distribution
220
+ * @param loc - Location parameter (default 0)
221
+ * @param scale - Scale parameter (default 1)
222
+ * @param size - Output shape
223
+ */
224
+ export declare function laplace(loc?: number, scale?: number, size?: number | number[]): ArrayStorage | number;
225
+ /**
226
+ * Draw samples from a logistic distribution
227
+ * @param loc - Location parameter (default 0)
228
+ * @param scale - Scale parameter (default 1)
229
+ * @param size - Output shape
230
+ */
231
+ export declare function logistic(loc?: number, scale?: number, size?: number | number[]): ArrayStorage | number;
232
+ /**
233
+ * Draw samples from a log-normal distribution
234
+ * @param mean - Mean of the underlying normal distribution (default 0)
235
+ * @param sigma - Standard deviation of the underlying normal (default 1)
236
+ * @param size - Output shape
237
+ */
238
+ export declare function lognormal(mean?: number, sigma?: number, size?: number | number[]): ArrayStorage | number;
239
+ /**
240
+ * Draw samples from a Gumbel distribution
241
+ * @param loc - Location parameter (default 0)
242
+ * @param scale - Scale parameter (default 1)
243
+ * @param size - Output shape
244
+ */
245
+ export declare function gumbel(loc?: number, scale?: number, size?: number | number[]): ArrayStorage | number;
246
+ /**
247
+ * Draw samples from a Pareto II (Lomax) distribution
248
+ * @param a - Shape parameter (must be > 0)
249
+ * @param size - Output shape
250
+ */
251
+ export declare function pareto(a: number, size?: number | number[]): ArrayStorage | number;
252
+ /**
253
+ * Draw samples from a power distribution with positive exponent a-1
254
+ * @param a - Shape parameter (must be > 0)
255
+ * @param size - Output shape
256
+ */
257
+ export declare function power(a: number, size?: number | number[]): ArrayStorage | number;
258
+ /**
259
+ * Draw samples from a Rayleigh distribution
260
+ * @param scale - Scale parameter (default 1)
261
+ * @param size - Output shape
262
+ */
263
+ export declare function rayleigh(scale?: number, size?: number | number[]): ArrayStorage | number;
264
+ /**
265
+ * Draw samples from a triangular distribution
266
+ * @param left - Lower limit
267
+ * @param mode - Mode (peak)
268
+ * @param right - Upper limit
269
+ * @param size - Output shape
270
+ */
271
+ export declare function triangular(left: number, mode: number, right: number, size?: number | number[]): ArrayStorage | number;
272
+ /**
273
+ * Draw samples from a Wald (inverse Gaussian) distribution
274
+ * @param mean - Mean of distribution (must be > 0)
275
+ * @param scale - Scale parameter (must be > 0)
276
+ * @param size - Output shape
277
+ */
278
+ export declare function wald(mean: number, scale: number, size?: number | number[]): ArrayStorage | number;
279
+ /**
280
+ * Draw samples from a Weibull distribution
281
+ * @param a - Shape parameter (must be > 0)
282
+ * @param size - Output shape
283
+ */
284
+ export declare function weibull(a: number, size?: number | number[]): ArrayStorage | number;
285
+ /**
286
+ * Draw samples from a chi-square distribution
287
+ * @param df - Degrees of freedom (must be > 0)
288
+ * @param size - Output shape
289
+ */
290
+ export declare function chisquare(df: number, size?: number | number[]): ArrayStorage | number;
291
+ /**
292
+ * Draw samples from a noncentral chi-square distribution
293
+ * @param df - Degrees of freedom (must be > 0)
294
+ * @param nonc - Non-centrality parameter (must be >= 0)
295
+ * @param size - Output shape
296
+ */
297
+ export declare function noncentral_chisquare(df: number, nonc: number, size?: number | number[]): ArrayStorage | number;
298
+ /**
299
+ * Draw samples from an F distribution
300
+ * @param dfnum - Degrees of freedom in numerator (must be > 0)
301
+ * @param dfden - Degrees of freedom in denominator (must be > 0)
302
+ * @param size - Output shape
303
+ */
304
+ export declare function f(dfnum: number, dfden: number, size?: number | number[]): ArrayStorage | number;
305
+ /**
306
+ * Draw samples from a noncentral F distribution
307
+ * @param dfnum - Degrees of freedom in numerator (must be > 0)
308
+ * @param dfden - Degrees of freedom in denominator (must be > 0)
309
+ * @param nonc - Non-centrality parameter (must be >= 0)
310
+ * @param size - Output shape
311
+ */
312
+ export declare function noncentral_f(dfnum: number, dfden: number, nonc: number, size?: number | number[]): ArrayStorage | number;
313
+ /**
314
+ * Draw samples from a geometric distribution
315
+ * @param p - Probability of success (0 < p <= 1)
316
+ * @param size - Output shape
317
+ */
318
+ export declare function geometric(p: number, size?: number | number[]): ArrayStorage | number;
319
+ /**
320
+ * Draw samples from a hypergeometric distribution
321
+ * @param ngood - Number of good elements in population
322
+ * @param nbad - Number of bad elements in population
323
+ * @param nsample - Number of items to sample
324
+ * @param size - Output shape
325
+ */
326
+ export declare function hypergeometric(ngood: number, nbad: number, nsample: number, size?: number | number[]): ArrayStorage | number;
327
+ /**
328
+ * Draw samples from a logarithmic series distribution
329
+ * @param p - Shape parameter (0 < p < 1)
330
+ * @param size - Output shape
331
+ */
332
+ export declare function logseries(p: number, size?: number | number[]): ArrayStorage | number;
333
+ /**
334
+ * Draw samples from a negative binomial distribution
335
+ * @param n - Number of successes (must be > 0)
336
+ * @param p - Probability of success (0 < p <= 1)
337
+ * @param size - Output shape
338
+ */
339
+ export declare function negative_binomial(n: number, p: number, size?: number | number[]): ArrayStorage | number;
340
+ /**
341
+ * Draw samples from a Zipf distribution
342
+ * @param a - Distribution parameter (must be > 1)
343
+ * @param size - Output shape
344
+ */
345
+ export declare function zipf(a: number, size?: number | number[]): ArrayStorage | number;
346
+ /**
347
+ * Draw samples from a multinomial distribution
348
+ * @param n - Number of experiments
349
+ * @param pvals - Probabilities of each category (must sum to 1)
350
+ * @param size - Output shape (number of experiments to run)
351
+ */
352
+ export declare function multinomial(n: number, pvals: number[] | ArrayStorage, size?: number | number[]): ArrayStorage;
353
+ /**
354
+ * Draw samples from a multivariate normal distribution
355
+ * @param mean - Mean of the distribution (1-D array of length N)
356
+ * @param cov - Covariance matrix (N x N array)
357
+ * @param size - Number of samples to draw
358
+ * @param check_valid - Check validity of covariance matrix (default 'warn')
359
+ * @param tol - Tolerance for checking positive semi-definiteness
360
+ */
361
+ export declare function multivariate_normal(mean: number[] | ArrayStorage, cov: number[][] | ArrayStorage, size?: number | number[], check_valid?: 'warn' | 'raise' | 'ignore', tol?: number): ArrayStorage;
362
+ /**
363
+ * Draw samples from a Dirichlet distribution
364
+ * @param alpha - Concentration parameters (must all be > 0)
365
+ * @param size - Number of samples to draw
366
+ */
367
+ export declare function dirichlet(alpha: number[] | ArrayStorage, size?: number | number[]): ArrayStorage;
368
+ /**
369
+ * Draw samples from a von Mises distribution
370
+ * @param mu - Mode (center) of the distribution (in radians)
371
+ * @param kappa - Concentration parameter (must be >= 0)
372
+ * @param size - Output shape
373
+ */
374
+ export declare function vonmises(mu: number, kappa: number, size?: number | number[]): ArrayStorage | number;
375
+ export {};
376
+ //# sourceMappingURL=random.d.ts.map
@@ -4,8 +4,8 @@
4
4
  * Pure functions for reducing arrays along axes.
5
5
  * @module ops/reduction
6
6
  */
7
- import { ArrayStorage } from '../core/storage';
8
- import { Complex } from '../core/complex';
7
+ import { ArrayStorage } from '../storage';
8
+ import { Complex } from '../complex';
9
9
  /**
10
10
  * Sum array elements over a given axis
11
11
  */
@@ -142,4 +142,12 @@ export declare function nancumprod(storage: ArrayStorage, axis?: number): ArrayS
142
142
  * Compute median ignoring NaN values
143
143
  */
144
144
  export declare function nanmedian(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number;
145
+ /**
146
+ * Compute the q-th quantile of data along specified axis, ignoring NaNs
147
+ */
148
+ export declare function nanquantile(storage: ArrayStorage, q: number, axis?: number, keepdims?: boolean): ArrayStorage | number;
149
+ /**
150
+ * Compute the q-th percentile of data along specified axis, ignoring NaNs
151
+ */
152
+ export declare function nanpercentile(storage: ArrayStorage, q: number, axis?: number, keepdims?: boolean): ArrayStorage | number;
145
153
  //# sourceMappingURL=reduction.d.ts.map
@@ -7,7 +7,7 @@
7
7
  * Note: Rounding operations are not defined for complex numbers.
8
8
  * All functions throw TypeError for complex dtypes.
9
9
  */
10
- import { ArrayStorage } from '../core/storage';
10
+ import { ArrayStorage } from '../storage';
11
11
  /**
12
12
  * Round an array to the given number of decimals
13
13
  */
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Set operations
3
+ */
4
+ import { ArrayStorage } from '../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
+ /**
39
+ * Trim leading and/or trailing zeros from a 1-D array.
40
+ *
41
+ * @param filt - Input 1-D array
42
+ * @param trim - 'fb' to trim front and back, 'f' for front only, 'b' for back only (default: 'fb')
43
+ * @returns Trimmed array
44
+ */
45
+ export declare function trim_zeros(filt: ArrayStorage, trim?: 'f' | 'b' | 'fb'): ArrayStorage;
46
+ /**
47
+ * Find the unique elements of an array, returning all optional outputs.
48
+ *
49
+ * @param x - Input array (flattened for uniqueness)
50
+ * @returns Object with values, indices, inverse_indices, and counts
51
+ */
52
+ export declare function unique_all(x: ArrayStorage): {
53
+ values: ArrayStorage;
54
+ indices: ArrayStorage;
55
+ inverse_indices: ArrayStorage;
56
+ counts: ArrayStorage;
57
+ };
58
+ /**
59
+ * Find the unique elements of an array and their counts.
60
+ *
61
+ * @param x - Input array (flattened for uniqueness)
62
+ * @returns Object with values and counts
63
+ */
64
+ export declare function unique_counts(x: ArrayStorage): {
65
+ values: ArrayStorage;
66
+ counts: ArrayStorage;
67
+ };
68
+ /**
69
+ * Find the unique elements of an array and their inverse indices.
70
+ *
71
+ * @param x - Input array (flattened for uniqueness)
72
+ * @returns Object with values and inverse_indices
73
+ */
74
+ export declare function unique_inverse(x: ArrayStorage): {
75
+ values: ArrayStorage;
76
+ inverse_indices: ArrayStorage;
77
+ };
78
+ /**
79
+ * Find the unique elements of an array (values only).
80
+ *
81
+ * This is equivalent to unique(x) but with a clearer name for the Array API.
82
+ *
83
+ * @param x - Input array (flattened for uniqueness)
84
+ * @returns Array of unique values, sorted
85
+ */
86
+ export declare function unique_values(x: ArrayStorage): ArrayStorage;
87
+ //# sourceMappingURL=sets.d.ts.map
@@ -4,7 +4,7 @@
4
4
  * Pure functions for reshaping, transposing, and manipulating array dimensions.
5
5
  * @module ops/shape
6
6
  */
7
- import { ArrayStorage } from '../core/storage';
7
+ import { ArrayStorage } from '../storage';
8
8
  /**
9
9
  * Reshape array to a new shape
10
10
  * Returns a view if array is C-contiguous, otherwise copies data
@@ -141,4 +141,17 @@ export declare function atleast2d(storages: ArrayStorage[]): ArrayStorage[];
141
141
  * Convert arrays to at least 3D
142
142
  */
143
143
  export declare function atleast3d(storages: ArrayStorage[]): ArrayStorage[];
144
+ /**
145
+ * Alias for concatenate
146
+ */
147
+ export declare function concat(storages: ArrayStorage[], axis?: number): ArrayStorage;
148
+ /**
149
+ * Split an array into a sequence of sub-arrays along an axis (inverse of stack)
150
+ */
151
+ export declare function unstack(storage: ArrayStorage, axis?: number): ArrayStorage[];
152
+ /**
153
+ * Assemble an nd-array from nested lists of blocks
154
+ * For a simple list [a, b] of nD arrays, concatenates along the last axis (like np.block)
155
+ */
156
+ export declare function block(storages: ArrayStorage[], _depth?: number): ArrayStorage;
144
157
  //# sourceMappingURL=shape.d.ts.map
@@ -4,7 +4,7 @@
4
4
  * Functions for sorting arrays, finding sorted indices, and searching.
5
5
  * @module ops/sorting
6
6
  */
7
- import { ArrayStorage } from '../core/storage';
7
+ import { ArrayStorage } from '../storage';
8
8
  /**
9
9
  * Return a sorted copy of an array
10
10
  * @param storage - Input array storage
@@ -4,7 +4,7 @@
4
4
  * Pure functions for statistical analysis.
5
5
  * @module ops/statistics
6
6
  */
7
- import { ArrayStorage } from '../core/storage';
7
+ import { ArrayStorage } from '../storage';
8
8
  /**
9
9
  * Count number of occurrences of each value in array of non-negative ints.
10
10
  *
@@ -105,4 +105,26 @@ export declare function cov(m: ArrayStorage, y?: ArrayStorage, rowvar?: boolean,
105
105
  * @returns Correlation coefficient matrix
106
106
  */
107
107
  export declare function corrcoef(x: ArrayStorage, y?: ArrayStorage, rowvar?: boolean): ArrayStorage;
108
+ /**
109
+ * Compute the edges of the bins for histogram.
110
+ *
111
+ * This function computes the bin edges without computing the histogram itself.
112
+ *
113
+ * @param a - Input data (flattened if not 1D)
114
+ * @param bins - Number of bins (default: 10) or a string specifying the bin algorithm
115
+ * @param range - Lower and upper range of bins. If not provided, uses [a.min(), a.max()]
116
+ * @param weights - Optional weights for each data point (used for some algorithms)
117
+ * @returns Array of bin edges (length = bins + 1)
118
+ */
119
+ export declare function histogram_bin_edges(a: ArrayStorage, bins?: number | 'auto' | 'fd' | 'doane' | 'scott' | 'stone' | 'rice' | 'sturges' | 'sqrt', range?: [number, number], _weights?: ArrayStorage): ArrayStorage;
120
+ /**
121
+ * Integrate along the given axis using the composite trapezoidal rule.
122
+ *
123
+ * @param y - Input array to integrate
124
+ * @param x - Optional sample points corresponding to y values. If not provided, spacing is assumed to be 1.
125
+ * @param dx - Spacing between sample points when x is not given (default: 1.0)
126
+ * @param axis - The axis along which to integrate (default: -1, meaning last axis)
127
+ * @returns Definite integral approximated using the composite trapezoidal rule
128
+ */
129
+ export declare function trapezoid(y: ArrayStorage, x?: ArrayStorage, dx?: number, axis?: number): ArrayStorage | number;
108
130
  //# sourceMappingURL=statistics.d.ts.map
@@ -7,7 +7,7 @@
7
7
  * These functions are used by NDArray methods but are separated
8
8
  * to keep the codebase modular and testable.
9
9
  */
10
- import { ArrayStorage } from '../core/storage';
10
+ import { ArrayStorage } from '../storage';
11
11
  /**
12
12
  * Sine of each element (element-wise)
13
13
  * NumPy behavior: Always promotes to float64 for integer types
@@ -17,6 +17,7 @@ export declare class ArrayStorage {
17
17
  private _strides;
18
18
  private _offset;
19
19
  private _dtype;
20
+ private _isCContiguous;
20
21
  constructor(data: TypedArray, shape: readonly number[], strides: readonly number[], offset: number, dtype: DType);
21
22
  /**
22
23
  * Shape of the array
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Advanced indexing and data manipulation functions
3
+ *
4
+ * Tree-shakeable standalone functions that wrap the underlying ops.
5
+ */
6
+ import { NDArrayCore } from '../common/ndarray-core';
7
+ import * as advancedOps from '../common/ops/advanced';
8
+ /** Broadcast array to a new shape - returns a view */
9
+ export declare function broadcast_to(a: NDArrayCore, shape: number[]): NDArrayCore;
10
+ export declare function broadcast_arrays(...arrays: NDArrayCore[]): NDArrayCore[];
11
+ export declare function broadcast_shapes(...shapes: number[][]): number[];
12
+ export declare function take(a: NDArrayCore, indices: number[], axis?: number): NDArrayCore;
13
+ export declare function put(a: NDArrayCore, indices: number[], values: NDArrayCore | number[]): void;
14
+ export declare function take_along_axis(arr: NDArrayCore, indices: NDArrayCore, axis: number): NDArrayCore;
15
+ export declare function put_along_axis(arr: NDArrayCore, indices: NDArrayCore, values: NDArrayCore, axis: number): void;
16
+ export declare function choose(a: NDArrayCore, choices: NDArrayCore[]): NDArrayCore;
17
+ export declare function compress(condition: NDArrayCore, a: NDArrayCore, axis?: number): NDArrayCore;
18
+ /**
19
+ * Integer array indexing (fancy indexing)
20
+ *
21
+ * Select elements using an array of indices.
22
+ */
23
+ export declare function iindex(a: NDArrayCore, indices: NDArrayCore | number[] | number[][], axis?: number): NDArrayCore;
24
+ /**
25
+ * Boolean array indexing (fancy indexing with mask)
26
+ *
27
+ * Select elements where a boolean mask is true.
28
+ */
29
+ export declare function bindex(a: NDArrayCore, mask: NDArrayCore, axis?: number): NDArrayCore;
30
+ export declare function select(condlist: NDArrayCore[], choicelist: NDArrayCore[], defaultVal?: number): NDArrayCore;
31
+ export declare function place(a: NDArrayCore, mask: NDArrayCore, vals: NDArrayCore): void;
32
+ export declare function putmask(a: NDArrayCore, mask: NDArrayCore, values: NDArrayCore): void;
33
+ export declare function copyto(dst: NDArrayCore, src: NDArrayCore | number | bigint): void;
34
+ export declare function indices(dimensions: number[], dtype?: 'int32' | 'int64' | 'float64'): NDArrayCore;
35
+ export declare function ix_(...args: NDArrayCore[]): NDArrayCore[];
36
+ export declare function ravel_multi_index(multi_index: NDArrayCore[], dims: number[], mode?: 'raise' | 'wrap' | 'clip'): NDArrayCore;
37
+ export declare function unravel_index(indices: NDArrayCore | number, shape: number[]): NDArrayCore[];
38
+ export declare function diag_indices(n: number, ndim?: number): NDArrayCore[];
39
+ export declare function diag_indices_from(a: NDArrayCore): NDArrayCore[];
40
+ export declare function fill_diagonal(a: NDArrayCore, val: number, wrap?: boolean): void;
41
+ export declare function tril_indices(n: number, k?: number, m?: number): NDArrayCore[];
42
+ export declare function tril_indices_from(a: NDArrayCore, k?: number): NDArrayCore[];
43
+ export declare function triu_indices(n: number, k?: number, m?: number): NDArrayCore[];
44
+ export declare function triu_indices_from(a: NDArrayCore, k?: number): NDArrayCore[];
45
+ export declare function mask_indices(n: number, mask_func: (n: number, k: number) => NDArrayCore, k?: number): NDArrayCore[];
46
+ export declare function array_equal(a: NDArrayCore, b: NDArrayCore, equal_nan?: boolean): boolean;
47
+ export declare function array_equiv(a: NDArrayCore, b: NDArrayCore): boolean;
48
+ export declare function apply_along_axis(func1d: (arr: NDArrayCore) => NDArrayCore | number, axis: number, arr: NDArrayCore): NDArrayCore;
49
+ export declare function apply_over_axes(func: (arr: NDArrayCore, axis: number) => NDArrayCore, a: NDArrayCore, axes: number[]): NDArrayCore;
50
+ export declare function may_share_memory(a: NDArrayCore, b: NDArrayCore): boolean;
51
+ export declare function shares_memory(a: NDArrayCore, b: NDArrayCore): boolean;
52
+ export declare const geterr: typeof advancedOps.geterr;
53
+ export declare const seterr: typeof advancedOps.seterr;
54
+ //# sourceMappingURL=advanced.d.ts.map