class_docstr: Distribution based on Bernstein Polynomials on unit hypercube.
  
  Parameters
  ----------
  cdf_grid : array_like
      cdf values on a equal spaced grid of the unit hypercube [0, 1]^d.
      The dimension of the arrays define how many random variables are
      included in the multivariate distribution.
  
  Attributes
  ----------
  cdf_grid : grid of cdf values
  prob_grid : grid of cell or bin probabilities
  k_dim : (int) number of components, dimension of random variable
  k_grid : (tuple) shape of cdf_grid
  k_grid_product : (int) total number of bins in grid
  _grid : Grid instance with helper methods and attributes
class_docstr_tok: ["Distribution","based","on","Bernstein","Polynomials","on","unit","hypercube",".","Parameters","--","--","--","--","--","cdf_grid",":","array_like","cdf","values","on","a","equal","spaced","grid","of","the","unit","hypercube","[","0",",","1","]","^d",".","The","dimension","of","the","arrays","define","how","many","random","variables","are","included","in","the","multivariate","distribution",".","Attributes","--","--","--","--","--","cdf_grid",":","grid","of","cdf","values","prob_grid",":","grid","of","cell","or","bin","probabilities","k_dim",":","(","int",")","number","of","components",",","dimension","of","random","variable","k_grid",":","(","tuple",")","shape","of","cdf_grid","k_grid_product",":","(","int",")","total","number","of","bins","in","grid","_grid",":","Grid","instance","with","helper","methods","and","attributes"]
docstr: Generate random numbers from distribution.
  
  Parameters
  ----------
  nobs : int
      Number of random observations to generate.
docstr_tok: ["Generate","random","numbers","from","distribution",".","Parameters","--","--","--","--","--","nobs",":","int","Number","of","random","observations","to","generate","."]
code: def rvs(self, nobs):
      """Generate random numbers from distribution.
  
      Parameters
      ----------
      nobs : int
          Number of random observations to generate.
      """
      rvs_mnl = np.random.multinomial(nobs, self.prob_grid.flatten())
      k_comp = self.k_dim
      rvs_m = []
      for i in range(len(rvs_mnl)):
          if rvs_mnl[i] != 0:
              idx = np.unravel_index(i, self.prob_grid.shape)
              rvsi = []
              for j in range(k_comp):
                  n = self.k_grid[j]
                  xgi = self._grid.x_marginal[j][idx[j]]
                  # Note: x_marginal starts at 0
                  #       x_marginal ends with 1 but that is not used by idx
                  rvsi.append(
                      stats.beta.rvs(
                          n * xgi + 1,
                          n * (1 - xgi) + 0,
                          size=rvs_mnl[i],
                      )
                  )
              rvs_m.append(np.column_stack(rvsi))
  
      rvsm = np.concatenate(rvs_m)
      return rvsm
  
file_path: statsmodels/statsmodels/distributions/bernstein.py
imports: import numpy
  from scipy import stats
  from statsmodels.tools.decorators import cache_readonly
  from statsmodels.distributions.tools import _Grid, cdf2prob_grid, prob2cdf_grid, _eval_bernstein_dd, _eval_bernstein_2d, _eval_bernstein_1d
label_desc: Use image node_id 7 for calling the BernsteinDistribution obj's underlying member method code with example usage: obj.rvs(nobs) and returns: rvsm