import random


def sampleIndexWithinRegionOfLength(length, lengthOfThingToEmbed):
    """Uniformly at random samples integers from 0 to
    ``length``-``lengthOfThingToEmbedIn``.

    Arguments:
        length: length of full region that could be embedded in

        lengthOfThingToEmbed: length of thing being embedded in larger region
    """
    assert lengthOfThingToEmbed <= length
    indexToSample = int(
        random.random() * ((length - lengthOfThingToEmbed) + 1))
    return indexToSample