<commit_before>"""Tools for arithmetic error propogation."""
from __future__ import print_function, division
from itertools import repeat

from sympy import Symbol, symbols, Add, Mul, simplify, Pow, exp
from sympy.stats.symbolic_probability import RandomSymbol, Variance


def variance_prop(expr, consts=()):
    """Symbolically propagates variance (sigma^2) for expressions.
    This is computed as as seen in [1]_.

    Parameters
    ==========
    expr : Expr
        A sympy expression to compute the variance for.
    consts : sequence of Symbols, optional
        Represents symbols that are known constants in the expr,
        and thus have zero variance.

    Returns
    =======
    var_expr : Expr
        An expression for the total variance of the expr.
        The variance for the original symbols (e.g. x) are represented
        via instance of the Variance symbol (e.g. Variance(x)).

    Examples<commit_msg>minor doc change<commit_after>"""Tools for arithmetic error propogation."""
from __future__ import print_function, division
from itertools import repeat

from sympy import Symbol, symbols, Add, Mul, simplify, Pow, exp
from sympy.stats.symbolic_probability import RandomSymbol, Variance


def variance_prop(expr, consts=()):
    """Symbolically propagates variance (sigma^2) for expressions.
    This is computed as as seen in [1]_.

    Parameters
    ==========
    expr : Expr
        A sympy expression to compute the variance for.
    consts : sequence of Symbols, optional
        Represents symbols that are known constants in the expr,
        and thus have zero variance. All symbols not in consts are
        assumed to be variant.

    Returns
    =======
    var_expr : Expr
        An expression for the total variance of the expr.
        The variance for the original symbols (e.g. x) are represented
        via instance of the Variance symbol (e.g. Variance(x)).

    Examples
{'fraction_non_alphanumeric': 0.0765625, 'fraction_numerical': 0.0020833333333333333, 'mean_word_length': 3.1943231441048034, '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': '5143187', 'n_tokens_mistral': 510, 'n_tokens_neox': 491, 'n_words': 225}