def _approximate_mode(class_counts, n_draws, rng):
 continuous = ((n_draws * class_counts) / class_counts.sum())
 floored = np.floor(continuous)
 need_to_add = int((n_draws - floored.sum()))
 if (need_to_add > 0):
  remainder = (continuous - floored)
  values = np.sort(np.unique(remainder))[::(-1)]
  for value in values:
   (inds,) = np.where((remainder == value))
   add_now = min(len(inds), need_to_add)
   inds = choice(inds, size=add_now, replace=False, random_state=rng)
   floored[inds] += 1
   need_to_add -= add_now
   if (need_to_add == 0):
    break
 return floored.astype(np.int)

def _approximate_mode ( class_counts , n_draws , rng ) : continuous = ( ( n_draws * class_counts ) / class_counts . sum ( ) ) floored = np . floor ( continuous ) need_to_add = int ( ( n_draws - floored . sum ( ) ) ) if ( need_to_add > 0 ) : remainder = ( continuous - floored ) values = np . sort ( np . unique ( remainder ) ) [ : : ( - 1 ) ] for value in values : ( inds , ) = np . where ( ( remainder == value ) ) add_now = min ( len ( inds ) , need_to_add ) inds = choice ( inds , size = add_now , replace = False , random_state = rng ) floored [ inds ] += 1 need_to_add -= add_now if ( need_to_add == 0 ) : break return floored . astype ( np . int )
computes approximate mode of multivariate hypergeometric .