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: Create distribution instance from data using histogram binning.
  
  Classmethod to construct a distribution instance.
  
  Parameters
  ----------
  data : array_like
      Data with observation in rows and random variables in columns.
      Data can be 1-dimensional in the univariate case.
  k_bins : int or list
      Number or edges of bins to be used in numpy histogramdd.
      If k_bins is a scalar int, then the number of bins of each
      component will be equal to it.
  
  Returns
  -------
  Instance of a Bernstein distribution
docstr_tok: ["Create","distribution","instance","from","data","using","histogram","binning",".","Classmethod","to","construct","a","distribution","instance",".","Parameters","--","--","--","--","--","data",":","array_like","Data","with","observation","in","rows","and","random","variables","in","columns",".","Data","can","be","1-dimensional","in","the","univariate","case",".","k_bins",":","int","or","list","Number","or","edges","of","bins","to","be","used","in","numpy","histogramdd",".","If","k_bins","is","a","scalar","int",",","then","the","number","of","bins","of","each","component","will","be","equal","to","it",".","Returns","--","--","--","-","Instance","of","a","Bernstein","distribution"]
code: def from_data(cls, data, k_bins):
      """Create distribution instance from data using histogram binning.
  
      Classmethod to construct a distribution instance.
  
      Parameters
      ----------
      data : array_like
          Data with observation in rows and random variables in columns.
          Data can be 1-dimensional in the univariate case.
      k_bins : int or list
          Number or edges of bins to be used in numpy histogramdd.
          If k_bins is a scalar int, then the number of bins of each
          component will be equal to it.
  
      Returns
      -------
      Instance of a Bernstein distribution
      """
      data = np.asarray(data)
      if np.any(data < 0) or np.any(data > 1):
          raise ValueError("data needs to be in [0, 1]")
  
      if data.ndim == 1:
          data = data[:, None]
  
      k_dim = data.shape[1]
      if np.size(k_bins) == 1:
          k_bins = [k_bins] * k_dim
      bins = [np.linspace(-1 / ni, 1, ni + 2) for ni in k_bins]
      c, e = np.histogramdd(data, bins=bins, density=False)
      # TODO: check when we have zero observations, which bin?
      # check bins start at 0 exept leading bin
      assert all([ei[1] == 0 for ei in e])
      c /= len(data)
  
      cdf_grid = prob2cdf_grid(c)
      return cls(cdf_grid)
  
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 2 for calling the BernsteinDistribution obj's underlying member method code with example usage: obj.from_data(cls, data, k_bins) and returns: cls