class_docstr: Latin hypercube sampling (LHS).
  
  A Latin hypercube sample [1]_ generates :math:`n` points in
  :math:`[0,1)^{d}`. Each univariate marginal distribution is stratified,
  placing exactly one point in :math:`[j/n, (j+1)/n)` for
  :math:`j=0,1,...,n-1`. They are still applicable when :math:`n << d`.
  LHS is extremely effective on integrands that are nearly additive [2]_.
  LHS on :math:`n` points never has more variance than plain MC on
  :math:`n-1` points [3]_. There is a central limit theorem for LHS [4]_,
  but not necessarily for optimized LHS.
  
  Parameters
  ----------
  d : int
      Dimension of the parameter space.
  centered : bool, optional
      Center the point within the multi-dimensional grid. Default is False.
  seed : {None, int, `numpy.random.Generator`}, optional
      If `seed` is None the `numpy.random.Generator` singleton is used.
      If `seed` is an int, a new ``Generator`` instance is used,
      seeded with `seed`.
      If `seed` is already a ``Generator`` instance then that instance is
      used.
  
  References
  ----------
  .. [1] Mckay et al., "A Comparison of Three Methods for Selecting Values
     of Input Variables in the Analysis of Output from a Computer Code",
     Technometrics, 1979.
  .. [2] M. Stein, "Large sample properties of simulations using Latin
     hypercube sampling." Technometrics 29, no. 2: 143-151, 1987.
  .. [3] A. B. Owen, "Monte Carlo variance of scrambled net quadrature."
     SIAM Journal on Numerical Analysis 34, no. 5: 1884-1910, 1997
  .. [4]  Loh, W.-L. "On Latin hypercube sampling." The annals of statistics
     24, no. 5: 2058-2080, 1996.
  
  Examples
  --------
  Generate samples from a Latin hypercube generator.
  
  >>> from scipy.stats import qmc
  >>> sampler = qmc.LatinHypercube(d=2)
  >>> sample = sampler.random(n=5)
  >>> sample
  array([[0.1545328 , 0.53664833],  # random
         [0.84052691, 0.06474907],
         [0.52177809, 0.93343721],
         [0.68033825, 0.36265316],
         [0.26544879, 0.61163943]])
  
  Compute the quality of the sample using the discrepancy criterion.
  
  >>> qmc.discrepancy(sample)
  0.019558034794794565  # random
  
  Finally, samples can be scaled to bounds.
  
  >>> l_bounds = [0, 2]
  >>> u_bounds = [10, 5]
  >>> qmc.scale(sample, l_bounds, u_bounds)
  array([[1.54532796, 3.609945  ],  # random
         [8.40526909, 2.1942472 ],
         [5.2177809 , 4.80031164],
         [6.80338249, 3.08795949],
         [2.65448791, 3.83491828]])
class_docstr_tok: ["Latin","hypercube","sampling","(","LHS",")",".","A","Latin","hypercube","sample","[","1","]","_","generates",":","math",":","`","n","`","points","in",":","math",":","`","[","0,1",")","^","{","d","}","`",".","Each","univariate","marginal","distribution","is","stratified",",","placing","exactly","one","point","in",":","math",":","`","[","j\/n",",","(","j+1",")","\/n",")","`","for",":","math",":","`","j=0,1",",","...",",","n-1","`",".","They","are","still","applicable","when",":","math",":","`","n","<","<","d","`",".","LHS","is","extremely","effective","on","integrands","that","are","nearly","additive","[","2","]","_.","LHS","on",":","math",":","`","n","`","points","never","has","more","variance","than","plain","MC","on",":","math",":","`","n-1","`","points","[","3","]","_",".","There","is","a","central","limit","theorem","for","LHS","[","4","]","_",",","but","not","necessarily","for","optimized","LHS",".","Parameters","--","--","--","--","--","d",":","int","Dimension","of","the","parameter","space",".","centered",":","bool",",","optional","Center","the","point","within","the","multi-dimensional","grid",".","Default","is","False",".","seed",":","{","None",",","int",",","`","numpy.random.Generator","`","}",",","optional","If","`","seed","`","is","None","the","`","numpy.random.Generator","`","singleton","is","used",".","If","`","seed","`","is","an","int",",","a","new","``","Generator","``","instance","is","used",",","seeded","with","`","seed","`",".","If","`","seed","`","is","already","a","``","Generator","``","instance","then","that","instance","is","used",".","References","--","--","--","--","--","..","[","1","]","Mckay","et","al.",",","``","A","Comparison","of","Three","Methods","for","Selecting","Values","of","Input","Variables","in","the","Analysis","of","Output","from","a","Computer","Code","''",",","Technometrics",",","1979",".","..","[","2","]","M.","Stein",",","``","Large","sample","properties","of","simulations","using","Latin","hypercube","sampling",".","''","Technometrics","29",",","no",".","2",":","143-151",",","1987",".","..","[","3","]","A",".","B.","Owen",",","``","Monte","Carlo","variance","of","scrambled","net","quadrature",".","''","SIAM","Journal","on","Numerical","Analysis","34",",","no",".","5",":","1884-1910",",","1997","..","[","4","]","Loh",",","W.-L.","``","On","Latin","hypercube","sampling",".","''","The","annals","of","statistics","24",",","no",".","5",":","2058-2080",",","1996",".","Examples","--","--","--","--","Generate","samples","from","a","Latin","hypercube","generator",".",">",">",">","from","scipy.stats","import","qmc",">",">",">","sampler","=","qmc.LatinHypercube","(","d=2",")",">",">",">","sample","=","sampler.random","(","n=5",")",">",">",">","sample","array","(","[","[","0.1545328",",","0.53664833","]",",","#","random","[","0.84052691",",","0.06474907","]",",","[","0.52177809",",","0.93343721","]",",","[","0.68033825",",","0.36265316","]",",","[","0.26544879",",","0.61163943","]","]",")","Compute","the","quality","of","the","sample","using","the","discrepancy","criterion",".",">",">",">","qmc.discrepancy","(","sample",")","0.019558034794794565","#","random","Finally",",","samples","can","be","scaled","to","bounds",".",">",">",">","l_bounds","=","[","0",",","2","]",">",">",">","u_bounds","=","[","10",",","5","]",">",">",">","qmc.scale","(","sample",",","l_bounds",",","u_bounds",")","array","(","[","[","1.54532796",",","3.609945","]",",","#","random","[","8.40526909",",","2.1942472","]",",","[","5.2177809",",","4.80031164","]",",","[","6.80338249",",","3.08795949","]",",","[","2.65448791",",","3.83491828","]","]",")"]
docstr: Draw `n` in the half-open interval ``[0, 1)``.
  
  Parameters
  ----------
  n : int, optional
      Number of samples to generate in the parameter space. Default is 1.
  
  Returns
  -------
  sample : array_like (n, d)
      LHS sample.
code: def random(self, n: IntNumber = 1) -> np.ndarray:
      """Draw `n` in the half-open interval ``[0, 1)``.
  
      Parameters
      ----------
      n : int, optional
          Number of samples to generate in the parameter space. Default is 1.
  
      Returns
      -------
      sample : array_like (n, d)
          LHS sample.
  
      """
      if self.centered:
          samples = 0.5
      else:
          samples = self.rng.uniform(size=(n, self.d))  # type: ignore[assignment]
  
      perms = np.tile(np.arange(1, n + 1), (self.d, 1))
      for i in range(self.d):  # type: ignore[arg-type]
          self.rng.shuffle(perms[i, :])
      perms = perms.T
  
      samples = (perms - samples) / n
      self.num_generated += n
      return samples
  
imports: from __future__ import annotations
  import os
  import copy
  import numbers
  from abc import ABC, abstractmethod
  import math
  from typing import ClassVar, List, Optional, overload, TYPE_CHECKING
  import warnings
  import numpy
  import scipy.stats
  from scipy._lib._util import rng_integers
  from scipy.stats._sobol import initialize_v, _cscramble, _fill_p_cumulative, _draw, _fast_forward, _categorize, initialize_direction_numbers, _MAXDIM, _MAXBIT
  from scipy.stats._qmc_cy import _cy_wrapper_centered_discrepancy, _cy_wrapper_wrap_around_discrepancy, _cy_wrapper_mixture_discrepancy, _cy_wrapper_l2_star_discrepancy, _cy_wrapper_update_discrepancy
label_desc: Use image node_id 2 for calling the LatinHypercube obj's underlying member method code with example usage: obj.random(n) and returns: samples