def METHOD_NAME(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)