def simpson_d(num_tokens, freq_spectrum):
    """Calculate Simpson’s D.

    Parameters:
        num_tokens (int): Absolute number of tokens.
        freq_spectrum (pd.Series): Counted occurring frequencies.
    """
    a = freq_spectrum.values / num_tokens
    b = freq_spectrum.index.values - 1
    return (freq_spectrum.values * a * (b / (num_tokens - 1))).sum()
