{'fraction_non_alphanumeric': 0.027093596059113302, 'fraction_numerical': 0.0024630541871921183, 'mean_word_length': 4.977941176470588, '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}}
Counting and random generation of strings in regular languages

We study the problems of counting and random generation of strings of a fixed length in regular languages. The regular language is described by a non-deterministic finite automaton or regular expression and the length of the desired strings is given in unary. The problem of exact counting is #P-complete. We give randomized algorithms for approximate counting and almost uniform generation that run in expected time n”(‘sn). We also describe a number of special cases that can be solved in polynomial time. This problem has a variety of applications in computational biology. In addition, there has been considerable theoretical interest in recent years[5] in the complexity of counting and random generation. Our result generalizes work by ([6]).