def calculate_diversity(pol):
    """Calculate nucleotide diversity value for the sample"""
    nucleotide_frequencies_per_base = pol[["freq_A", "freq_C", "freq_G", "freq_T"]]
    diversity = nucleotide_frequencies_per_base * (1 - nucleotide_frequencies_per_base)
    pol["diversity"] = diversity.sum(axis=1)
    return pol