{'fraction_non_alphanumeric': 0.015815085158150853, 'fraction_numerical': 0.0, 'mean_word_length': 4.963768115942029, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Optimal random number generation from a biased coin

We study the optimal generation of random numbers using a biased coin in two cases: first, when the bias is unknown, and second, when the bias is known. In the first case, we characterize the functions that use a discrete random source of unknown distribution to simulate a target discrete random variable with a given rational distribution. We identify the functions that minimize the ratio of source inputs to target outputs. We show that these optimal functions are efficiently computable. In the second case, we prove that it is impossible to construct an optimal tree algorithm recursively, using a model based on the algebraic decision tree. Our model of computation is sufficiently general to encompass virtually all previously known algorithms for this problem.