<commit_before>.. perplexity.rst

**********
Perplexity
**********

The perplexity is a trivial measure to make the entropy more intuitive.

.. autofunction:: dit.algorithms.perplexity<commit_msg>a bit of docs about perplexity<commit_after>.. perplexity.rst

**********
Perplexity
**********

The perplexity is a trivial measure to make the entropy more intuitive.

.. math::

   \P[X] = 2^{\H[X]}

The perplexity of a random variable is the size of a uniform distribution that
would have the same entropy. For example, a distribution with 2 bits of entropy
has a perplexity of 4, and so could be said to be "as random" as a four-sided
die.

.. autofunction:: dit.algorithms.perplexity
{'fraction_non_alphanumeric': 0.12700729927007298, 'fraction_numerical': 0.004379562043795621, 'mean_word_length': 4.276923076923077, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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}}
{'dir': 'git-commits-cleaned', 'id': '7561014', 'n_tokens_mistral': 215, 'n_tokens_neox': 196, 'n_words': 87}