quasi_random_indices(number_of_total_items, [number_of_desired_items]) -> index

  Yields an iterator to a quasi-random list of indices that will contain exactly the number of desired indices (or the number of total items in the list, if this is smaller).

  This function can be used to retrieve a consistent and reproducible list of indices of the data, in case the ``number_of_total_items`` is lower that the given ``number_of_desired_items``.

  **Parameters:**

  ``number_of_total_items`` : int
    The total number of elements in the collection, which should be sub-sampled

  ``number_of_desired_items`` : int or ``None``
    The number of items that should be used; if ``None`` or greater than ``number_of_total_items``, all indices are yielded

  **Yields:**

  ``index`` : int
    An iterator to indices, which will span ``number_of_total_items`` evenly.

def quasi_random_indices(number_of_total_items, number_of_desired_items = None):
  """quasi_random_indices(number_of_total_items, [number_of_desired_items]) -> index

  Yields an iterator to a quasi-random list of indices that will contain exactly the number of desired indices (or the number of total items in the list, if this is smaller).

  This function can be used to retrieve a consistent and reproducible list of indices of the data, in case the ``number_of_total_items`` is lower that the given ``number_of_desired_items``.

  **Parameters:**

  ``number_of_total_items`` : int
    The total number of elements in the collection, which should be sub-sampled

  ``number_of_desired_items`` : int or ``None``
    The number of items that should be used; if ``None`` or greater than ``number_of_total_items``, all indices are yielded

  **Yields:**

  ``index`` : int
    An iterator to indices, which will span ``number_of_total_items`` evenly.
  """
  # check if we need to compute a sublist at all
  if number_of_desired_items is None or number_of_desired_items >= number_of_total_items or number_of_desired_items < 0:
    for i in range(number_of_total_items):
      yield i
  else:
    increase = float(number_of_total_items)/float(number_of_desired_items)
    # generate a regular quasi-random index list
    for i in range(number_of_desired_items):
      yield int((i +.5)*increase)