/ lib / numpy / random / mtrand.pyi
mtrand.pyi
  1  from collections.abc import Callable
  2  from typing import Any, Union, overload, Literal
  3  
  4  from numpy import (
  5      bool_,
  6      dtype,
  7      float32,
  8      float64,
  9      int8,
 10      int16,
 11      int32,
 12      int64,
 13      int_,
 14      ndarray,
 15      uint,
 16      uint8,
 17      uint16,
 18      uint32,
 19      uint64,
 20  )
 21  from numpy.random.bit_generator import BitGenerator
 22  from numpy._typing import (
 23      ArrayLike,
 24      _ArrayLikeFloat_co,
 25      _ArrayLikeInt_co,
 26      _DoubleCodes,
 27      _DTypeLikeBool,
 28      _DTypeLikeInt,
 29      _DTypeLikeUInt,
 30      _Float32Codes,
 31      _Float64Codes,
 32      _Int8Codes,
 33      _Int16Codes,
 34      _Int32Codes,
 35      _Int64Codes,
 36      _IntCodes,
 37      _ShapeLike,
 38      _SingleCodes,
 39      _SupportsDType,
 40      _UInt8Codes,
 41      _UInt16Codes,
 42      _UInt32Codes,
 43      _UInt64Codes,
 44      _UIntCodes,
 45  )
 46  
 47  _DTypeLikeFloat32 = Union[
 48      dtype[float32],
 49      _SupportsDType[dtype[float32]],
 50      type[float32],
 51      _Float32Codes,
 52      _SingleCodes,
 53  ]
 54  
 55  _DTypeLikeFloat64 = Union[
 56      dtype[float64],
 57      _SupportsDType[dtype[float64]],
 58      type[float],
 59      type[float64],
 60      _Float64Codes,
 61      _DoubleCodes,
 62  ]
 63  
 64  class RandomState:
 65      _bit_generator: BitGenerator
 66      def __init__(self, seed: None | _ArrayLikeInt_co | BitGenerator = ...) -> None: ...
 67      def __repr__(self) -> str: ...
 68      def __str__(self) -> str: ...
 69      def __getstate__(self) -> dict[str, Any]: ...
 70      def __setstate__(self, state: dict[str, Any]) -> None: ...
 71      def __reduce__(self) -> tuple[Callable[[str], RandomState], tuple[str], dict[str, Any]]: ...
 72      def seed(self, seed: None | _ArrayLikeFloat_co = ...) -> None: ...
 73      @overload
 74      def get_state(self, legacy: Literal[False] = ...) -> dict[str, Any]: ...
 75      @overload
 76      def get_state(
 77          self, legacy: Literal[True] = ...
 78      ) -> dict[str, Any] | tuple[str, ndarray[Any, dtype[uint32]], int, int, float]: ...
 79      def set_state(
 80          self, state: dict[str, Any] | tuple[str, ndarray[Any, dtype[uint32]], int, int, float]
 81      ) -> None: ...
 82      @overload
 83      def random_sample(self, size: None = ...) -> float: ...  # type: ignore[misc]
 84      @overload
 85      def random_sample(self, size: _ShapeLike = ...) -> ndarray[Any, dtype[float64]]: ...
 86      @overload
 87      def random(self, size: None = ...) -> float: ...  # type: ignore[misc]
 88      @overload
 89      def random(self, size: _ShapeLike = ...) -> ndarray[Any, dtype[float64]]: ...
 90      @overload
 91      def beta(self, a: float, b: float, size: None = ...) -> float: ...  # type: ignore[misc]
 92      @overload
 93      def beta(
 94          self, a: _ArrayLikeFloat_co, b: _ArrayLikeFloat_co, size: None | _ShapeLike = ...
 95      ) -> ndarray[Any, dtype[float64]]: ...
 96      @overload
 97      def exponential(self, scale: float = ..., size: None = ...) -> float: ...  # type: ignore[misc]
 98      @overload
 99      def exponential(
100          self, scale: _ArrayLikeFloat_co = ..., size: None | _ShapeLike = ...
101      ) -> ndarray[Any, dtype[float64]]: ...
102      @overload
103      def standard_exponential(self, size: None = ...) -> float: ...  # type: ignore[misc]
104      @overload
105      def standard_exponential(self, size: _ShapeLike = ...) -> ndarray[Any, dtype[float64]]: ...
106      @overload
107      def tomaxint(self, size: None = ...) -> int: ...  # type: ignore[misc]
108      @overload
109      def tomaxint(self, size: _ShapeLike = ...) -> ndarray[Any, dtype[int_]]: ...
110      @overload
111      def randint(  # type: ignore[misc]
112          self,
113          low: int,
114          high: None | int = ...,
115      ) -> int: ...
116      @overload
117      def randint(  # type: ignore[misc]
118          self,
119          low: int,
120          high: None | int = ...,
121          size: None = ...,
122          dtype: _DTypeLikeBool = ...,
123      ) -> bool: ...
124      @overload
125      def randint(  # type: ignore[misc]
126          self,
127          low: int,
128          high: None | int = ...,
129          size: None = ...,
130          dtype: _DTypeLikeInt | _DTypeLikeUInt = ...,
131      ) -> int: ...
132      @overload
133      def randint(  # type: ignore[misc]
134          self,
135          low: _ArrayLikeInt_co,
136          high: None | _ArrayLikeInt_co = ...,
137          size: None | _ShapeLike = ...,
138      ) -> ndarray[Any, dtype[int_]]: ...
139      @overload
140      def randint(  # type: ignore[misc]
141          self,
142          low: _ArrayLikeInt_co,
143          high: None | _ArrayLikeInt_co = ...,
144          size: None | _ShapeLike = ...,
145          dtype: _DTypeLikeBool = ...,
146      ) -> ndarray[Any, dtype[bool_]]: ...
147      @overload
148      def randint(  # type: ignore[misc]
149          self,
150          low: _ArrayLikeInt_co,
151          high: None | _ArrayLikeInt_co = ...,
152          size: None | _ShapeLike = ...,
153          dtype: dtype[int8] | type[int8] | _Int8Codes | _SupportsDType[dtype[int8]] = ...,
154      ) -> ndarray[Any, dtype[int8]]: ...
155      @overload
156      def randint(  # type: ignore[misc]
157          self,
158          low: _ArrayLikeInt_co,
159          high: None | _ArrayLikeInt_co = ...,
160          size: None | _ShapeLike = ...,
161          dtype: dtype[int16] | type[int16] | _Int16Codes | _SupportsDType[dtype[int16]] = ...,
162      ) -> ndarray[Any, dtype[int16]]: ...
163      @overload
164      def randint(  # type: ignore[misc]
165          self,
166          low: _ArrayLikeInt_co,
167          high: None | _ArrayLikeInt_co = ...,
168          size: None | _ShapeLike = ...,
169          dtype: dtype[int32] | type[int32] | _Int32Codes | _SupportsDType[dtype[int32]] = ...,
170      ) -> ndarray[Any, dtype[int32]]: ...
171      @overload
172      def randint(  # type: ignore[misc]
173          self,
174          low: _ArrayLikeInt_co,
175          high: None | _ArrayLikeInt_co = ...,
176          size: None | _ShapeLike = ...,
177          dtype: None | dtype[int64] | type[int64] | _Int64Codes | _SupportsDType[dtype[int64]] = ...,
178      ) -> ndarray[Any, dtype[int64]]: ...
179      @overload
180      def randint(  # type: ignore[misc]
181          self,
182          low: _ArrayLikeInt_co,
183          high: None | _ArrayLikeInt_co = ...,
184          size: None | _ShapeLike = ...,
185          dtype: dtype[uint8] | type[uint8] | _UInt8Codes | _SupportsDType[dtype[uint8]] = ...,
186      ) -> ndarray[Any, dtype[uint8]]: ...
187      @overload
188      def randint(  # type: ignore[misc]
189          self,
190          low: _ArrayLikeInt_co,
191          high: None | _ArrayLikeInt_co = ...,
192          size: None | _ShapeLike = ...,
193          dtype: dtype[uint16] | type[uint16] | _UInt16Codes | _SupportsDType[dtype[uint16]] = ...,
194      ) -> ndarray[Any, dtype[uint16]]: ...
195      @overload
196      def randint(  # type: ignore[misc]
197          self,
198          low: _ArrayLikeInt_co,
199          high: None | _ArrayLikeInt_co = ...,
200          size: None | _ShapeLike = ...,
201          dtype: dtype[uint32] | type[uint32] | _UInt32Codes | _SupportsDType[dtype[uint32]] = ...,
202      ) -> ndarray[Any, dtype[uint32]]: ...
203      @overload
204      def randint(  # type: ignore[misc]
205          self,
206          low: _ArrayLikeInt_co,
207          high: None | _ArrayLikeInt_co = ...,
208          size: None | _ShapeLike = ...,
209          dtype: dtype[uint64] | type[uint64] | _UInt64Codes | _SupportsDType[dtype[uint64]] = ...,
210      ) -> ndarray[Any, dtype[uint64]]: ...
211      @overload
212      def randint(  # type: ignore[misc]
213          self,
214          low: _ArrayLikeInt_co,
215          high: None | _ArrayLikeInt_co = ...,
216          size: None | _ShapeLike = ...,
217          dtype: dtype[int_] | type[int] | type[int_] | _IntCodes | _SupportsDType[dtype[int_]] = ...,
218      ) -> ndarray[Any, dtype[int_]]: ...
219      @overload
220      def randint(  # type: ignore[misc]
221          self,
222          low: _ArrayLikeInt_co,
223          high: None | _ArrayLikeInt_co = ...,
224          size: None | _ShapeLike = ...,
225          dtype: dtype[uint] | type[uint] | _UIntCodes | _SupportsDType[dtype[uint]] = ...,
226      ) -> ndarray[Any, dtype[uint]]: ...
227      def bytes(self, length: int) -> bytes: ...
228      @overload
229      def choice(
230          self,
231          a: int,
232          size: None = ...,
233          replace: bool = ...,
234          p: None | _ArrayLikeFloat_co = ...,
235      ) -> int: ...
236      @overload
237      def choice(
238          self,
239          a: int,
240          size: _ShapeLike = ...,
241          replace: bool = ...,
242          p: None | _ArrayLikeFloat_co = ...,
243      ) -> ndarray[Any, dtype[int_]]: ...
244      @overload
245      def choice(
246          self,
247          a: ArrayLike,
248          size: None = ...,
249          replace: bool = ...,
250          p: None | _ArrayLikeFloat_co = ...,
251      ) -> Any: ...
252      @overload
253      def choice(
254          self,
255          a: ArrayLike,
256          size: _ShapeLike = ...,
257          replace: bool = ...,
258          p: None | _ArrayLikeFloat_co = ...,
259      ) -> ndarray[Any, Any]: ...
260      @overload
261      def uniform(self, low: float = ..., high: float = ..., size: None = ...) -> float: ...  # type: ignore[misc]
262      @overload
263      def uniform(
264          self,
265          low: _ArrayLikeFloat_co = ...,
266          high: _ArrayLikeFloat_co = ...,
267          size: None | _ShapeLike = ...,
268      ) -> ndarray[Any, dtype[float64]]: ...
269      @overload
270      def rand(self) -> float: ...
271      @overload
272      def rand(self, *args: int) -> ndarray[Any, dtype[float64]]: ...
273      @overload
274      def randn(self) -> float: ...
275      @overload
276      def randn(self, *args: int) -> ndarray[Any, dtype[float64]]: ...
277      @overload
278      def random_integers(self, low: int, high: None | int = ..., size: None = ...) -> int: ...  # type: ignore[misc]
279      @overload
280      def random_integers(
281          self,
282          low: _ArrayLikeInt_co,
283          high: None | _ArrayLikeInt_co = ...,
284          size: None | _ShapeLike = ...,
285      ) -> ndarray[Any, dtype[int_]]: ...
286      @overload
287      def standard_normal(self, size: None = ...) -> float: ...  # type: ignore[misc]
288      @overload
289      def standard_normal(  # type: ignore[misc]
290          self, size: _ShapeLike = ...
291      ) -> ndarray[Any, dtype[float64]]: ...
292      @overload
293      def normal(self, loc: float = ..., scale: float = ..., size: None = ...) -> float: ...  # type: ignore[misc]
294      @overload
295      def normal(
296          self,
297          loc: _ArrayLikeFloat_co = ...,
298          scale: _ArrayLikeFloat_co = ...,
299          size: None | _ShapeLike = ...,
300      ) -> ndarray[Any, dtype[float64]]: ...
301      @overload
302      def standard_gamma(  # type: ignore[misc]
303          self,
304          shape: float,
305          size: None = ...,
306      ) -> float: ...
307      @overload
308      def standard_gamma(
309          self,
310          shape: _ArrayLikeFloat_co,
311          size: None | _ShapeLike = ...,
312      ) -> ndarray[Any, dtype[float64]]: ...
313      @overload
314      def gamma(self, shape: float, scale: float = ..., size: None = ...) -> float: ...  # type: ignore[misc]
315      @overload
316      def gamma(
317          self,
318          shape: _ArrayLikeFloat_co,
319          scale: _ArrayLikeFloat_co = ...,
320          size: None | _ShapeLike = ...,
321      ) -> ndarray[Any, dtype[float64]]: ...
322      @overload
323      def f(self, dfnum: float, dfden: float, size: None = ...) -> float: ...  # type: ignore[misc]
324      @overload
325      def f(
326          self, dfnum: _ArrayLikeFloat_co, dfden: _ArrayLikeFloat_co, size: None | _ShapeLike = ...
327      ) -> ndarray[Any, dtype[float64]]: ...
328      @overload
329      def noncentral_f(self, dfnum: float, dfden: float, nonc: float, size: None = ...) -> float: ...  # type: ignore[misc]
330      @overload
331      def noncentral_f(
332          self,
333          dfnum: _ArrayLikeFloat_co,
334          dfden: _ArrayLikeFloat_co,
335          nonc: _ArrayLikeFloat_co,
336          size: None | _ShapeLike = ...,
337      ) -> ndarray[Any, dtype[float64]]: ...
338      @overload
339      def chisquare(self, df: float, size: None = ...) -> float: ...  # type: ignore[misc]
340      @overload
341      def chisquare(
342          self, df: _ArrayLikeFloat_co, size: None | _ShapeLike = ...
343      ) -> ndarray[Any, dtype[float64]]: ...
344      @overload
345      def noncentral_chisquare(self, df: float, nonc: float, size: None = ...) -> float: ...  # type: ignore[misc]
346      @overload
347      def noncentral_chisquare(
348          self, df: _ArrayLikeFloat_co, nonc: _ArrayLikeFloat_co, size: None | _ShapeLike = ...
349      ) -> ndarray[Any, dtype[float64]]: ...
350      @overload
351      def standard_t(self, df: float, size: None = ...) -> float: ...  # type: ignore[misc]
352      @overload
353      def standard_t(
354          self, df: _ArrayLikeFloat_co, size: None = ...
355      ) -> ndarray[Any, dtype[float64]]: ...
356      @overload
357      def standard_t(
358          self, df: _ArrayLikeFloat_co, size: _ShapeLike = ...
359      ) -> ndarray[Any, dtype[float64]]: ...
360      @overload
361      def vonmises(self, mu: float, kappa: float, size: None = ...) -> float: ...  # type: ignore[misc]
362      @overload
363      def vonmises(
364          self, mu: _ArrayLikeFloat_co, kappa: _ArrayLikeFloat_co, size: None | _ShapeLike = ...
365      ) -> ndarray[Any, dtype[float64]]: ...
366      @overload
367      def pareto(self, a: float, size: None = ...) -> float: ...  # type: ignore[misc]
368      @overload
369      def pareto(
370          self, a: _ArrayLikeFloat_co, size: None | _ShapeLike = ...
371      ) -> ndarray[Any, dtype[float64]]: ...
372      @overload
373      def weibull(self, a: float, size: None = ...) -> float: ...  # type: ignore[misc]
374      @overload
375      def weibull(
376          self, a: _ArrayLikeFloat_co, size: None | _ShapeLike = ...
377      ) -> ndarray[Any, dtype[float64]]: ...
378      @overload
379      def power(self, a: float, size: None = ...) -> float: ...  # type: ignore[misc]
380      @overload
381      def power(
382          self, a: _ArrayLikeFloat_co, size: None | _ShapeLike = ...
383      ) -> ndarray[Any, dtype[float64]]: ...
384      @overload
385      def standard_cauchy(self, size: None = ...) -> float: ...  # type: ignore[misc]
386      @overload
387      def standard_cauchy(self, size: _ShapeLike = ...) -> ndarray[Any, dtype[float64]]: ...
388      @overload
389      def laplace(self, loc: float = ..., scale: float = ..., size: None = ...) -> float: ...  # type: ignore[misc]
390      @overload
391      def laplace(
392          self,
393          loc: _ArrayLikeFloat_co = ...,
394          scale: _ArrayLikeFloat_co = ...,
395          size: None | _ShapeLike = ...,
396      ) -> ndarray[Any, dtype[float64]]: ...
397      @overload
398      def gumbel(self, loc: float = ..., scale: float = ..., size: None = ...) -> float: ...  # type: ignore[misc]
399      @overload
400      def gumbel(
401          self,
402          loc: _ArrayLikeFloat_co = ...,
403          scale: _ArrayLikeFloat_co = ...,
404          size: None | _ShapeLike = ...,
405      ) -> ndarray[Any, dtype[float64]]: ...
406      @overload
407      def logistic(self, loc: float = ..., scale: float = ..., size: None = ...) -> float: ...  # type: ignore[misc]
408      @overload
409      def logistic(
410          self,
411          loc: _ArrayLikeFloat_co = ...,
412          scale: _ArrayLikeFloat_co = ...,
413          size: None | _ShapeLike = ...,
414      ) -> ndarray[Any, dtype[float64]]: ...
415      @overload
416      def lognormal(self, mean: float = ..., sigma: float = ..., size: None = ...) -> float: ...  # type: ignore[misc]
417      @overload
418      def lognormal(
419          self,
420          mean: _ArrayLikeFloat_co = ...,
421          sigma: _ArrayLikeFloat_co = ...,
422          size: None | _ShapeLike = ...,
423      ) -> ndarray[Any, dtype[float64]]: ...
424      @overload
425      def rayleigh(self, scale: float = ..., size: None = ...) -> float: ...  # type: ignore[misc]
426      @overload
427      def rayleigh(
428          self, scale: _ArrayLikeFloat_co = ..., size: None | _ShapeLike = ...
429      ) -> ndarray[Any, dtype[float64]]: ...
430      @overload
431      def wald(self, mean: float, scale: float, size: None = ...) -> float: ...  # type: ignore[misc]
432      @overload
433      def wald(
434          self, mean: _ArrayLikeFloat_co, scale: _ArrayLikeFloat_co, size: None | _ShapeLike = ...
435      ) -> ndarray[Any, dtype[float64]]: ...
436      @overload
437      def triangular(self, left: float, mode: float, right: float, size: None = ...) -> float: ...  # type: ignore[misc]
438      @overload
439      def triangular(
440          self,
441          left: _ArrayLikeFloat_co,
442          mode: _ArrayLikeFloat_co,
443          right: _ArrayLikeFloat_co,
444          size: None | _ShapeLike = ...,
445      ) -> ndarray[Any, dtype[float64]]: ...
446      @overload
447      def binomial(self, n: int, p: float, size: None = ...) -> int: ...  # type: ignore[misc]
448      @overload
449      def binomial(
450          self, n: _ArrayLikeInt_co, p: _ArrayLikeFloat_co, size: None | _ShapeLike = ...
451      ) -> ndarray[Any, dtype[int_]]: ...
452      @overload
453      def negative_binomial(self, n: float, p: float, size: None = ...) -> int: ...  # type: ignore[misc]
454      @overload
455      def negative_binomial(
456          self, n: _ArrayLikeFloat_co, p: _ArrayLikeFloat_co, size: None | _ShapeLike = ...
457      ) -> ndarray[Any, dtype[int_]]: ...
458      @overload
459      def poisson(self, lam: float = ..., size: None = ...) -> int: ...  # type: ignore[misc]
460      @overload
461      def poisson(
462          self, lam: _ArrayLikeFloat_co = ..., size: None | _ShapeLike = ...
463      ) -> ndarray[Any, dtype[int_]]: ...
464      @overload
465      def zipf(self, a: float, size: None = ...) -> int: ...  # type: ignore[misc]
466      @overload
467      def zipf(
468          self, a: _ArrayLikeFloat_co, size: None | _ShapeLike = ...
469      ) -> ndarray[Any, dtype[int_]]: ...
470      @overload
471      def geometric(self, p: float, size: None = ...) -> int: ...  # type: ignore[misc]
472      @overload
473      def geometric(
474          self, p: _ArrayLikeFloat_co, size: None | _ShapeLike = ...
475      ) -> ndarray[Any, dtype[int_]]: ...
476      @overload
477      def hypergeometric(self, ngood: int, nbad: int, nsample: int, size: None = ...) -> int: ...  # type: ignore[misc]
478      @overload
479      def hypergeometric(
480          self,
481          ngood: _ArrayLikeInt_co,
482          nbad: _ArrayLikeInt_co,
483          nsample: _ArrayLikeInt_co,
484          size: None | _ShapeLike = ...,
485      ) -> ndarray[Any, dtype[int_]]: ...
486      @overload
487      def logseries(self, p: float, size: None = ...) -> int: ...  # type: ignore[misc]
488      @overload
489      def logseries(
490          self, p: _ArrayLikeFloat_co, size: None | _ShapeLike = ...
491      ) -> ndarray[Any, dtype[int_]]: ...
492      def multivariate_normal(
493          self,
494          mean: _ArrayLikeFloat_co,
495          cov: _ArrayLikeFloat_co,
496          size: None | _ShapeLike = ...,
497          check_valid: Literal["warn", "raise", "ignore"] = ...,
498          tol: float = ...,
499      ) -> ndarray[Any, dtype[float64]]: ...
500      def multinomial(
501          self, n: _ArrayLikeInt_co, pvals: _ArrayLikeFloat_co, size: None | _ShapeLike = ...
502      ) -> ndarray[Any, dtype[int_]]: ...
503      def dirichlet(
504          self, alpha: _ArrayLikeFloat_co, size: None | _ShapeLike = ...
505      ) -> ndarray[Any, dtype[float64]]: ...
506      def shuffle(self, x: ArrayLike) -> None: ...
507      @overload
508      def permutation(self, x: int) -> ndarray[Any, dtype[int_]]: ...
509      @overload
510      def permutation(self, x: ArrayLike) -> ndarray[Any, Any]: ...
511  
512  _rand: RandomState
513  
514  beta = _rand.beta
515  binomial = _rand.binomial
516  bytes = _rand.bytes
517  chisquare = _rand.chisquare
518  choice = _rand.choice
519  dirichlet = _rand.dirichlet
520  exponential = _rand.exponential
521  f = _rand.f
522  gamma = _rand.gamma
523  get_state = _rand.get_state
524  geometric = _rand.geometric
525  gumbel = _rand.gumbel
526  hypergeometric = _rand.hypergeometric
527  laplace = _rand.laplace
528  logistic = _rand.logistic
529  lognormal = _rand.lognormal
530  logseries = _rand.logseries
531  multinomial = _rand.multinomial
532  multivariate_normal = _rand.multivariate_normal
533  negative_binomial = _rand.negative_binomial
534  noncentral_chisquare = _rand.noncentral_chisquare
535  noncentral_f = _rand.noncentral_f
536  normal = _rand.normal
537  pareto = _rand.pareto
538  permutation = _rand.permutation
539  poisson = _rand.poisson
540  power = _rand.power
541  rand = _rand.rand
542  randint = _rand.randint
543  randn = _rand.randn
544  random = _rand.random
545  random_integers = _rand.random_integers
546  random_sample = _rand.random_sample
547  rayleigh = _rand.rayleigh
548  seed = _rand.seed
549  set_state = _rand.set_state
550  shuffle = _rand.shuffle
551  standard_cauchy = _rand.standard_cauchy
552  standard_exponential = _rand.standard_exponential
553  standard_gamma = _rand.standard_gamma
554  standard_normal = _rand.standard_normal
555  standard_t = _rand.standard_t
556  triangular = _rand.triangular
557  uniform = _rand.uniform
558  vonmises = _rand.vonmises
559  wald = _rand.wald
560  weibull = _rand.weibull
561  zipf = _rand.zipf
562  # Two legacy that are trivial wrappers around random_sample
563  sample = _rand.random_sample
564  ranf = _rand.random_sample
565  
566  def set_bit_generator(bitgen: BitGenerator) -> None:
567      ...
568  
569  def get_bit_generator() -> BitGenerator:
570      ...