ravens/utils.py
def sample_distribution(prob, n_samples=1):
    """Sample data point from a custom distribution."""
    flat_prob = np.ndarray.flatten(prob) / np.sum(prob)
    rand_ind = np.random.choice(
        np.arange(len(flat_prob)), n_samples, p=flat_prob, replace=False)
    rand_ind_coords = np.array(np.unravel_index(rand_ind, prob.shape)).T
    return np.int32(rand_ind_coords.squeeze())
Sample data point from a custom distribution.
Sample data point from a custom distribution.
Sample data point from a custom distribution .
def sample_distribution(prob, n_samples=1):
    flat_prob = np.ndarray.flatten(prob) / np.sum(prob)
    rand_ind = np.random.choice(
        np.arange(len(flat_prob)), n_samples, p=flat_prob, replace=False)
    rand_ind_coords = np.array(np.unravel_index(rand_ind, prob.shape)).T
    return np.int32(rand_ind_coords.squeeze())
def sample_distribution ( prob , n_samples = 1 ) : flat_prob = np . ndarray . flatten ( prob ) / np . sum ( prob ) rand_ind = np . random . choice ( np . arange ( len ( flat_prob ) ) , n_samples , p = flat_prob , replace = False ) rand_ind_coords = np . array ( np . unravel_index ( rand_ind , prob . shape ) ) . T return np . int32 ( rand_ind_coords . squeeze ( ) )
Sample data point from a custom distribution.
Sample data point from a custom distribution .
"""Sample data point from a custom distribution."""
prob
n_samples