numpy-ts 0.12.0 → 0.13.1

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 (144) hide show
  1. package/README.md +18 -14
  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 +4 -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 +7 -2
  73. package/dist/numpy-ts.node-io.cjs +7 -3
  74. package/dist/numpy-ts.node-io.cjs.map +4 -4
  75. package/dist/numpy-ts.node-io.mjs +7 -3
  76. package/dist/numpy-ts.node-io.mjs.map +4 -4
  77. package/dist/numpy-ts.node.cjs +7 -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 +2 -2
  84. package/dist/types/{ops → common/ops}/arithmetic.d.ts +1 -1
  85. package/dist/types/{ops → common/ops}/bitwise.d.ts +1 -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 +24 -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 +2 -2
  97. package/dist/types/{ops → common/ops}/rounding.d.ts +1 -1
  98. package/dist/types/{ops → common/ops}/sets.d.ts +1 -1
  99. package/dist/types/{ops → common/ops}/shape.d.ts +1 -1
  100. package/dist/types/{ops → common/ops}/sorting.d.ts +1 -1
  101. package/dist/types/{ops → common/ops}/statistics.d.ts +1 -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 +30 -29
  139. package/dist/numpy-ts.esm.js +0 -2
  140. package/dist/types/core/ndarray.d.ts +0 -3923
  141. package/dist/types/ops/random.d.ts +0 -136
  142. /package/dist/types/{core → common}/broadcasting.d.ts +0 -0
  143. /package/dist/types/{core → common}/dtype.d.ts +0 -0
  144. /package/dist/types/{core → common}/slicing.d.ts +0 -0
@@ -0,0 +1,229 @@
1
+ /**
2
+ * Array printing and formatting operations
3
+ *
4
+ * Functions for converting arrays and numbers to string representations.
5
+ * @module ops/formatting
6
+ */
7
+ import { ArrayStorage } from '../storage';
8
+ /**
9
+ * Print options configuration
10
+ */
11
+ export interface PrintOptions {
12
+ /** Total number of array elements that trigger summarization (default: 1000) */
13
+ threshold: number;
14
+ /** Number of elements to print at edges when summarizing (default: 3) */
15
+ edgeitems: number;
16
+ /** Number of digits of precision for floating point output (default: 8) */
17
+ precision: number;
18
+ /** Characters per line for array output (default: 75) */
19
+ linewidth: number;
20
+ /** If true, always use exponential format; if false, never; if null, auto (default: null) */
21
+ floatmode: 'fixed' | 'unique' | 'maxprec' | 'maxprec_equal';
22
+ /** If true, suppress printing of small floating point values (default: true) */
23
+ suppress: boolean;
24
+ /** String inserted between elements (default: ' ') */
25
+ separator: string;
26
+ /** Prefix for array string */
27
+ prefix: string;
28
+ /** Suffix for array string */
29
+ suffix: string;
30
+ /** String representation of nan (default: 'nan') */
31
+ nanstr: string;
32
+ /** String representation of inf (default: 'inf') */
33
+ infstr: string;
34
+ /** If true, use legacy printing mode (default: false) */
35
+ legacy: string | false;
36
+ /** Whether to print the sign of positive values (default: false) */
37
+ sign: ' ' | '+' | '-';
38
+ }
39
+ /**
40
+ * Set printing options for array output
41
+ *
42
+ * These options determine how arrays are converted to strings.
43
+ *
44
+ * @param options - Options to set
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * set_printoptions({ precision: 4, threshold: 100 });
49
+ * ```
50
+ */
51
+ export declare function set_printoptions(options: Partial<PrintOptions>): void;
52
+ /**
53
+ * Get current print options
54
+ *
55
+ * @returns Current print options
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * const opts = get_printoptions();
60
+ * console.log(opts.precision); // 8
61
+ * ```
62
+ */
63
+ export declare function get_printoptions(): PrintOptions;
64
+ /**
65
+ * Context manager for temporarily setting print options
66
+ *
67
+ * In JavaScript, this returns an object with enter/exit methods
68
+ * that can be used with try/finally.
69
+ *
70
+ * @param options - Options to set temporarily
71
+ * @returns Object with enter() and exit() methods
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * const ctx = printoptions({ precision: 2 });
76
+ * ctx.enter();
77
+ * try {
78
+ * console.log(array2string(arr));
79
+ * } finally {
80
+ * ctx.exit();
81
+ * }
82
+ * ```
83
+ */
84
+ export declare function printoptions(options: Partial<PrintOptions>): {
85
+ enter: () => void;
86
+ exit: () => void;
87
+ apply: <T>(fn: () => T) => T;
88
+ _savedOptions: PrintOptions | null;
89
+ };
90
+ /**
91
+ * Format a floating-point number in positional notation
92
+ *
93
+ * @param x - Value to format
94
+ * @param precision - Number of digits after decimal point (default: from printoptions)
95
+ * @param unique - If true, use shortest representation (default: true)
96
+ * @param fractional - If true, always include fractional part (default: true)
97
+ * @param trim - Trim trailing zeros: 'k' (keep), '.' (trim after decimal), '0' (trim zeros), '-' (trim point and zeros)
98
+ * @param sign - Sign handling: '-' (only negative), '+' (always), ' ' (space for positive)
99
+ * @param pad_left - Pad left with spaces to this width
100
+ * @param pad_right - Pad right with zeros to this width
101
+ * @param min_digits - Minimum digits after decimal point
102
+ * @returns Formatted string
103
+ *
104
+ * @example
105
+ * ```typescript
106
+ * format_float_positional(3.14159265, 4); // '3.1416'
107
+ * format_float_positional(1000.0, 2); // '1000.00'
108
+ * ```
109
+ */
110
+ export declare function format_float_positional(x: number, precision?: number | null, unique?: boolean, fractional?: boolean, trim?: 'k' | '.' | '0' | '-', sign?: '-' | '+' | ' ', pad_left?: number | null, pad_right?: number | null, min_digits?: number | null): string;
111
+ /**
112
+ * Format a floating-point number in scientific notation
113
+ *
114
+ * @param x - Value to format
115
+ * @param precision - Number of digits after decimal point (default: from printoptions)
116
+ * @param unique - If true, use shortest representation (default: true)
117
+ * @param trim - Trim trailing zeros: 'k' (keep), '.' (trim after decimal), '0' (trim zeros), '-' (trim point and zeros)
118
+ * @param sign - Sign handling: '-' (only negative), '+' (always), ' ' (space for positive)
119
+ * @param pad_left - Pad left with spaces to this width
120
+ * @param exp_digits - Minimum digits in exponent
121
+ * @param min_digits - Minimum digits after decimal point
122
+ * @returns Formatted string
123
+ *
124
+ * @example
125
+ * ```typescript
126
+ * format_float_scientific(3.14159265, 4); // '3.1416e+00'
127
+ * format_float_scientific(12345.0, 2); // '1.23e+04'
128
+ * ```
129
+ */
130
+ export declare function format_float_scientific(x: number, precision?: number | null, _unique?: boolean, trim?: 'k' | '.' | '0' | '-', sign?: '-' | '+' | ' ', pad_left?: number | null, exp_digits?: number, min_digits?: number | null): string;
131
+ /**
132
+ * Return a string representation of a number in the given base
133
+ *
134
+ * For base 2, -36. Negative numbers are represented using two's complement
135
+ * if padding is specified, otherwise prefixed with '-'.
136
+ *
137
+ * @param number - Number to convert
138
+ * @param base - Base for representation (2-36, default: 2)
139
+ * @param padding - Minimum number of digits (pads with zeros)
140
+ * @returns String representation in the given base
141
+ *
142
+ * @example
143
+ * ```typescript
144
+ * base_repr(10, 2); // '1010'
145
+ * base_repr(10, 16); // 'A'
146
+ * base_repr(-10, 2, 8); // '11110110' (two's complement)
147
+ * ```
148
+ */
149
+ export declare function base_repr(number: number, base?: number, padding?: number): string;
150
+ /**
151
+ * Return the binary representation of the input number as a string
152
+ *
153
+ * For negative numbers, two's complement is used if width is specified,
154
+ * otherwise a minus sign is prefixed.
155
+ *
156
+ * @param num - Integer to convert
157
+ * @param width - Minimum width of the result (pads with zeros, uses two's complement for negatives)
158
+ * @returns Binary string representation
159
+ *
160
+ * @example
161
+ * ```typescript
162
+ * binary_repr(10); // '1010'
163
+ * binary_repr(-10); // '-1010'
164
+ * binary_repr(-10, 8); // '11110110' (two's complement)
165
+ * ```
166
+ */
167
+ export declare function binary_repr(num: number, width?: number | null): string;
168
+ /**
169
+ * Convert an array to a string representation
170
+ *
171
+ * @param a - Input array storage
172
+ * @param max_line_width - Maximum line width (default: from printoptions)
173
+ * @param precision - Number of digits of precision (default: from printoptions)
174
+ * @param suppress_small - Suppress small floating point values (default: from printoptions)
175
+ * @param separator - Separator between elements (default: from printoptions)
176
+ * @param prefix - Prefix string (default: '')
177
+ * @param suffix - Suffix string (default: '')
178
+ * @param threshold - Threshold for summarization (default: from printoptions)
179
+ * @param edgeitems - Number of edge items when summarizing (default: from printoptions)
180
+ * @returns String representation of the array
181
+ *
182
+ * @example
183
+ * ```typescript
184
+ * const arr = array([[1, 2, 3], [4, 5, 6]]);
185
+ * console.log(array2string(arr.storage));
186
+ * // [[1 2 3]
187
+ * // [4 5 6]]
188
+ * ```
189
+ */
190
+ export declare function array2string(a: ArrayStorage, max_line_width?: number | null, precision?: number | null, suppress_small?: boolean | null, separator?: string, prefix?: string, suffix?: string, threshold?: number | null, edgeitems?: number | null, floatmode?: 'fixed' | 'unique' | 'maxprec' | 'maxprec_equal' | null, sign?: ' ' | '+' | '-' | null): string;
191
+ /**
192
+ * Return the string representation of an array
193
+ *
194
+ * Similar to array2string but includes the 'array(' prefix.
195
+ *
196
+ * @param a - Input array storage
197
+ * @param max_line_width - Maximum line width
198
+ * @param precision - Number of digits of precision
199
+ * @param suppress_small - Suppress small floating point values
200
+ * @returns String representation
201
+ *
202
+ * @example
203
+ * ```typescript
204
+ * const arr = array([1, 2, 3]);
205
+ * console.log(array_repr(arr.storage));
206
+ * // array([1, 2, 3])
207
+ * ```
208
+ */
209
+ export declare function array_repr(a: ArrayStorage, max_line_width?: number | null, precision?: number | null, suppress_small?: boolean | null): string;
210
+ /**
211
+ * Return a string representation of the data in an array
212
+ *
213
+ * Similar to array2string but returns just the data without array() wrapper.
214
+ *
215
+ * @param a - Input array storage
216
+ * @param max_line_width - Maximum line width
217
+ * @param precision - Number of digits of precision
218
+ * @param suppress_small - Suppress small floating point values
219
+ * @returns String representation of the data
220
+ *
221
+ * @example
222
+ * ```typescript
223
+ * const arr = array([1, 2, 3]);
224
+ * console.log(array_str(arr.storage));
225
+ * // [1 2 3]
226
+ * ```
227
+ */
228
+ export declare function array_str(a: ArrayStorage, max_line_width?: number | null, precision?: number | null, suppress_small?: boolean | null): string;
229
+ //# sourceMappingURL=formatting.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
  * Calculate the n-th discrete difference along the given axis.
13
13
  *
@@ -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
  * Hyperbolic sine of each element (element-wise)
13
13
  * NumPy behavior: Always promotes to float64 for integer types
@@ -4,8 +4,8 @@
4
4
  * Pure functions for matrix operations (matmul, etc.).
5
5
  * @module ops/linalg
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
  * Dot product of two arrays (fully NumPy-compatible)
11
11
  *
@@ -158,7 +158,7 @@ export declare function kron(a: ArrayStorage, b: ArrayStorage): ArrayStorage;
158
158
  * @param axis - If defined, the axis of a, b and c that defines the vectors
159
159
  * @returns Cross product of a and b
160
160
  */
161
- export declare function cross(a: ArrayStorage, b: ArrayStorage, axisa?: number, axisb?: number, axisc?: number, axis?: number): ArrayStorage | number;
161
+ export declare function cross(a: ArrayStorage, b: ArrayStorage, axisa?: number, axisb?: number, axisc?: number, axis?: number): ArrayStorage | number | Complex;
162
162
  /**
163
163
  * Vector norm.
164
164
  *
@@ -488,4 +488,25 @@ export declare function tensorinv(a: ArrayStorage, ind?: number): ArrayStorage;
488
488
  * @returns Solution tensor x
489
489
  */
490
490
  export declare function tensorsolve(a: ArrayStorage, b: ArrayStorage, axes?: number[] | null): ArrayStorage;
491
+ /**
492
+ * Evaluate the lowest cost contraction order for an einsum expression
493
+ *
494
+ * This function analyzes an einsum expression and finds an optimized contraction
495
+ * path that minimizes the total number of operations (FLOPs).
496
+ *
497
+ * @param subscripts - Einsum subscript string (e.g., 'ij,jk,kl->il')
498
+ * @param operands - Input arrays (or their shapes)
499
+ * @param optimize - Optimization strategy: 'greedy' (default), 'optimal', or false for no optimization
500
+ * @returns A tuple of [path, string_representation] where path is an array of index pairs
501
+ *
502
+ * @example
503
+ * ```typescript
504
+ * const a = ones([10, 10]);
505
+ * const b = ones([10, 10]);
506
+ * const c = ones([10, 10]);
507
+ * const [path, info] = einsum_path('ij,jk,kl->il', a.storage, b.storage, c.storage);
508
+ * // path: [[0, 1], [0, 1]] - contract first two, then result with third
509
+ * ```
510
+ */
511
+ export declare function einsum_path(subscripts: string, ...operands: (ArrayStorage | number[])[]): [Array<[number, number] | number[]>, string];
491
512
  //# sourceMappingURL=linalg.d.ts.map
@@ -8,8 +8,8 @@
8
8
  * These operations convert values to boolean (non-zero = true, zero = false)
9
9
  * and return boolean arrays (dtype: 'bool').
10
10
  */
11
- import { ArrayStorage } from '../core/storage';
12
- import { type DType } from '../core/dtype';
11
+ import { ArrayStorage } from '../storage';
12
+ import { type DType } from '../dtype';
13
13
  /**
14
14
  * Logical AND of two arrays or array and scalar
15
15
  *
@@ -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