uniform_range_coverage_sample() with log_space=True returns incorrect number of samples

Issue #61 new
Thomas Gilgenast created an issue

when calling lib5c.util.sampling.uniform_range_coverage_sample() we expect this last condition to be True - that is, we expect to get the number of samples n that we ask for

>>> import numpy as np
>>> from lib5c.util.sampling import uniform_range_coverage_sample
>>> data = np.exp(np.random.normal(size=1000))
>>> n = 100
>>> centers = uniform_range_coverage_sample(data, n, log_space=True)
>>> centers.shape == (n,)
False

it does work as expected if log_space=False

Comments (1)

  1. Thomas Gilgenast reporter

    this test case is actually non-deterministic:

    >>> np.bincount(
    ...     [uniform_range_coverage_sample(np.exp(np.random.normal(size=1000)),
    ...                                    n, log_space=True).shape[0]
    ...      for _ in range(1000)])[99:101]
    array([337, 663], dtype=int64)
    
  2. Log in to comment