'Generate a string similar to samples previously fed in.'

def generate(self):

    start = weighted_lottery(self.starts)
    desired_length = weighted_lottery(self.start_lengths[start])
    desired_length = max(desired_length, self.order)
    generated = []
    generated.extend(start)
    while (len(generated) < desired_length):
        for (order, model) in reversed(list(enumerate(self.models, 1))):
            current_prefix = ''.join(generated[(- order):])
            frequencies = model[current_prefix]
            if frequencies:
                generated.append(weighted_lottery(frequencies))
                break
        else:
            generated.append(random.choice(string.lowercase))
    return ''.join(generated)
