def matched_sample_distribution(floats_arr: np.array, samples_no: int, granularity: int=100, logmode: bool=False) -> np.array:
    '\n    Tries to guess a distribution of floats and sample from it.\n    uses np.histogram with the number of bins equal to the granularity parameter. For each\n    sample, selects which bin to sample and then picks from the bin a float according to a\n    uniform distribution. if logmode is enabled, histogram will be in the log-space, as well as\n    the sampling.\n\n    :param floats_arr: array of floats for which to match the distribution\n    :param samples_no: number of random samples to retrieve\n    :param granularity: granularity at which to operate\n    :param logmode: if sample in log-space\n    :return: samples drawn from the empirically matched distribution\n    '
    if logmode:
        floats_arr = np.log(floats_arr)
    (hist, bin_edges) = np.histogram(floats_arr, bins=granularity, density=True)
    pad = np.arange(granularity)
    locations = np.choice(pad, samples_no, p=hist)
    samples = []
    for i in locations:
        samples.append(np.random.uniform(bin_edges[i], bin_edges[(i + 1)]))
    if logmode:
        return np.exp(samples)
    else:
        return samples
Tries to guess a distribution of floats and sample from it.
uses np.histogram with the number of bins equal to the granularity parameter. For each
sample, selects which bin to sample and then picks from the bin a float according to a
uniform distribution. if logmode is enabled, histogram will be in the log-space, as well as
the sampling.

:param floats_arr: array of floats for which to match the distribution
:param samples_no: number of random samples to retrieve
:param granularity: granularity at which to operate
:param logmode: if sample in log-space
:return: samples drawn from the empirically matched distribution
def matched_sample_distribution(floats_arr: np.array, samples_no: int, granularity: int=100, logmode: bool=False) -> np.array:
    '\n    Tries to guess a distribution of floats and sample from it.\n    uses np.histogram with the number of bins equal to the granularity parameter. For each\n    sample, selects which bin to sample and then picks from the bin a float according to a\n    uniform distribution. if logmode is enabled, histogram will be in the log-space, as well as\n    the sampling.\n\n    :param floats_arr: array of floats for which to match the distribution\n    :param samples_no: number of random samples to retrieve\n    :param granularity: granularity at which to operate\n    :param logmode: if sample in log-space\n    :return: samples drawn from the empirically matched distribution\n    '
    if logmode:
        floats_arr = np.log(floats_arr)
    (hist, bin_edges) = np.histogram(floats_arr, bins=granularity, density=True)
    pad = np.arange(granularity)
    locations = np.choice(pad, samples_no, p=hist)
    samples = []
    for i in locations:
        samples.append(np.random.uniform(bin_edges[i], bin_edges[(i + 1)]))
    if logmode:
        return np.exp(samples)
    else:
        return samples