Histogram (Hist)

A Hist object represents a mapping from quantities to their frequencies or counts.

Hist is a subclass of a Pandas Series, so it has all Series methods, although some are overridden to change their behavior.

Bases: Pmf

Represents a Pmf that maps from values to frequencies/counts.

Source code in empiricaldist/empiricaldist.py
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
class Hist(Pmf):
    """Represents a Pmf that maps from values to frequencies/counts."""

    @staticmethod
    def from_seq(seq, normalize=False, **options):
        """Make a distribution from a sequence of values.

        Args:
            seq: sequence of anything
            normalize: whether to normalize the probabilities
            options: passed along to Pmf

        Returns:  Counter object
        """
        pmf = Pmf.from_seq(seq, normalize=normalize, **options)
        return Hist(pmf, copy=False)

    def _repr_html_(self):
        """Returns an HTML representation of the series.

        Mostly used for Jupyter notebooks.
        """
        df = pd.DataFrame(dict(freqs=self))
        return df._repr_html_()

from_seq(seq, normalize=False, **options) staticmethod

Make a distribution from a sequence of values.

Parameters:
  • seq

    sequence of anything

  • normalize

    whether to normalize the probabilities

  • options

    passed along to Pmf

Returns: Counter object

Source code in empiricaldist/empiricaldist.py
899
900
901
902
903
904
905
906
907
908
909
910
911
@staticmethod
def from_seq(seq, normalize=False, **options):
    """Make a distribution from a sequence of values.

    Args:
        seq: sequence of anything
        normalize: whether to normalize the probabilities
        options: passed along to Pmf

    Returns:  Counter object
    """
    pmf = Pmf.from_seq(seq, normalize=normalize, **options)
    return Hist(pmf, copy=False)