<commit_before>import itertools as it
import logging
import os
import numbers
from matplotlib import pyplot as plt, transforms as mtransforms, collections as mcollections
import numpy as np
from scipy.stats import gaussian_kde

from .util import autospace, acorr


logger = logging.getLogger(__name__)


def kde_plot(x, factor=0.1, num=50, ax=None, **kwargs):
    """
    Plot a univariate kernel density estimate.

    Parameters
    ----------
    x : array_like
        values to plot
    ax : Axes
        axes to plot into
    factor : float
        factor by which to extend the range
    kwargs : dict
        additional keyword arguments passed to `ax.plot`
    """
    ax = ax or plt.gca()
    kde = gaussian_kde(x)
    linx = autospace(x, num, factor=factor)
    y = kde(linx)
    return ax.plot(linx, y, **kwargs)


def density_plot(samples, burn_in=0, step=1, name=None, value=None, bins=10, num=50, ax=None, **kwargs):
    """
    Plot the density of a parameter (and a vertical indicating the true value).

    Parameters
    ----------
    samples : array_like
        samples of the parameters
    burn_in : int
        number of initial values to discard
    step : int
        lag between consecutive samples
    name : str
        name of the parameter
    value : float
        true value
    bins : int
        number of bins for the histogram
    ax : Axes
        axes to plot into
    """
    ax = ax or plt.gca()
    x = samples[burn_in::step]

    # Create a histogram
    if bins is not None:
        ax.hist(x, bins, normed=True, histtype='stepfilled', facecolor='silver', edgecolor='none')

    # Plot the kde
    kde_plot(x, num, ax=ax, **kwargs)
    if name:
        ax.set_xlabel(name)

    # Plot true values
    if value is not None:
        ax.axvline(value, ls='dotted', color='r')<commit_msg>Fix typo.<commit_after>import itertools as it
import logging
import os
import numbers
from matplotlib import pyplot as plt, transforms as mtransforms, collections as mcollections
import numpy as np
from scipy.stats import gaussian_kde

from .util import autospace, acorr


logger = logging.getLogger(__name__)


def kde_plot(x, factor=0.1, num=50, ax=None, **kwargs):
    """
    Plot a univariate kernel density estimate.

    Parameters
    ----------
    x : array_like
        values to plot
    ax : Axes
        axes to plot into
    factor : float
        factor by which to extend the range
    kwargs : dict
        additional keyword arguments passed to `ax.plot`
    """
    ax = ax or plt.gca()
    kde = gaussian_kde(x)
    linx = autospace(x, num, factor=factor)
    y = kde(linx)
    return ax.plot(linx, y, **kwargs)


def density_plot(samples, burn_in=0, step=1, name=None, value=None, bins=10, num=50, ax=None, **kwargs):
    """
    Plot the density of a parameter (and a vertical indicating the true value).

    Parameters
    ----------
    samples : array_like
        samples of the parameters
    burn_in : int
        number of initial values to discard
    step : int
        lag between consecutive samples
    name : str
        name of the parameter
    value : float
        true value
    bins : int
        number of bins for the histogram
    ax : Axes
        axes to plot into
    """
    ax = ax or plt.gca()
    x = samples[burn_in::step]

    # Create a histogram
    if bins is not None:
        ax.hist(x, bins, normed=True, histtype='stepfilled', facecolor='silver', edgecolor='none')

    # Plot the kde
    kde_plot(x, num=num, ax=ax, **kwargs)
    if name:
        ax.set_xlabel(name)

    # Plot true values
    if value is not None:
        ax.axvline(value, ls='dotted', color='r')
{'fraction_non_alphanumeric': 0.09513395297977037, 'fraction_numerical': 0.005467468562055768, 'mean_word_length': 2.4682464454976305, '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': '5955548', 'n_tokens_mistral': 1161, 'n_tokens_neox': 1104, 'n_words': 406}