def calc_differential_entropy(agent_stats, skill_headers=None, verbose=False, infos={}, pop=None, punish_youth=True):
    agent_skills = get_pop_stats(agent_stats['skills'], pop)
    lifespans = get_pop_stats(agent_stats['lifespans'], pop)
    a_skills = agent_skills
    a_lifespans = lifespans
    assert (a_skills.shape[0] == a_lifespans.shape[0])
    if verbose:
        print(skill_headers)
        print(a_skills.transpose())
        print(len(agent_skills), 'populations')
        print('lifespans')
        print(a_lifespans)
    if punish_youth:
        a_skills = contract_by_lifespan(a_skills, a_lifespans)
    mean = np.average(a_skills, axis=0)
    cov = np.cov(a_skills, rowvar=0)
    gaussian = scipy.stats.multivariate_normal(mean=mean, cov=cov, allow_singular=True)
    infos['gaussian'] = gaussian
    score = gaussian.entropy()
    if verbose:
        print('score:', score)
    return score
def calc_differential_entropy(agent_stats, skill_headers=None, verbose=False, infos={}, pop=None, punish_youth=True):
    agent_skills = get_pop_stats(agent_stats['skills'], pop)
    lifespans = get_pop_stats(agent_stats['lifespans'], pop)
    a_skills = agent_skills
    a_lifespans = lifespans
    assert (a_skills.shape[0] == a_lifespans.shape[0])
    if verbose:
        print(skill_headers)
        print(a_skills.transpose())
        print(len(agent_skills), 'populations')
        print('lifespans')
        print(a_lifespans)
    if punish_youth:
        a_skills = contract_by_lifespan(a_skills, a_lifespans)
    mean = np.average(a_skills, axis=0)
    cov = np.cov(a_skills, rowvar=0)
    gaussian = scipy.stats.multivariate_normal(mean=mean, cov=cov, allow_singular=True)
    infos['gaussian'] = gaussian
    score = gaussian.entropy()
    if verbose:
        print('score:', score)
    return score