def dist_to_conc(dist, r_min, r_max, rule="trapezoid"):
    """ Converts a swath of a size distribution function to an actual number
    concentration.

    Aerosol size distributions are typically reported by normalizing the
    number density by the size of the aerosol. However, it's sometimes more
    convenient to simply have a histogram of representing several aerosol
    size ranges (bins) and the actual number concentration one should expect
    in those bins. To accomplish this, one only needs to integrate the size
    distribution function over the range spanned by the bin.

    Parameters
    ----------
    dist : object implementing a ``pdf()`` method
        the representation of the size distribution
    r_min, r_max : float
        the lower and upper bounds of the size bin, in the native units of ``dist``
    rule : {'trapezoid', 'simpson', 'other'} (default='trapezoid')
        rule used to integrate the size distribution

    Returns
    -------
    float
        The number concentration of aerosol particles the given bin.

    Examples
    --------

    >>> dist = Lognorm(mu=0.015, sigma=1.6, N=850.0)
    >>> r_min, r_max = 0.00326456461236 0.00335634401598
    >>> dist_to_conc(dist, r_min, r_max)
    0.114256210943

    """
    pdf = dist.pdf
    width = r_max - r_min
    if rule == "trapezoid":
        return width*0.5*(pdf(r_max) + pdf(r_min))
    elif rule == "simpson":
        return (width/6.)*(pdf(r_max) + pdf(r_min) + 4.*pdf(0.5*(r_max + r_min)))
    else:
        return width*pdf(0.5*(r_max + r_min))