def calc_discrete_entropy(agent_stats, skill_headers=None, pop=None):
    agent_skills = get_pop_stats(agent_stats['skills'], pop)
    lifespans = get_pop_stats(agent_stats['lifespans'], pop)
    agent_skills_0 = np.vstack(agent_skills)
    agent_lifespans = np.hstack(lifespans)
    weights = sigmoid_lifespan(agent_lifespans)
    agent_skills = (agent_skills_0.transpose() * weights)
    agent_skills = agent_skills.transpose()
    BASE_VAL = 0.0001
    n_skills = len(agent_skills[0])
    n_pop = len(agent_skills)
    agent_sums = [sum(skills) for skills in agent_skills]
    i = 0
    for a in agent_sums:
        if (a == 0):
            agent_sums[i] = (BASE_VAL * n_skills)
        i += 1
    skill_sums = [0 for i in range(n_skills)]
    for i in range(n_skills):
        for a_skills in agent_skills:
            skill_sums[i] += a_skills[i]
        if (skill_sums[i] == 0):
            skill_sums[i] = (BASE_VAL * n_pop)
    skill_ents = []
    for i in range(n_skills):
        skill_ent = 0
        for j in range(n_pop):
            a_skill = agent_skills[j][i]
            if (a_skill == 0):
                a_skill = BASE_VAL
            p = (a_skill / skill_sums[i])
            if (p == 0):
                skill_ent += 0
            else:
                skill_ent += (p * np.log(p))
        skill_ent = (skill_ent / n_pop)
        skill_ents.append(skill_ent)
    agent_ents = []
    for j in range(n_pop):
        agent_ent = 0
        for i in range(n_skills):
            a_skill = agent_skills[j][i]
            if (a_skill == 0):
                a_skill = BASE_VAL
            p = (a_skill / agent_sums[j])
            if (p == 0):
                agent_ent += 0
            else:
                agent_ent += (p * np.log(p))
        agent_ent = (agent_ent / n_skills)
        agent_ents.append(agent_ent)
    agent_score = np.mean(agent_ents)
    skill_score = np.mean(skill_ents)
    score = (- (skill_score * agent_score))
    score = (score * 100)
    print('agent skills:\n{}\n{}'.format(skill_headers, np.array(agent_skills_0.transpose())))
    print('lifespans:\n{}'.format(lifespans))
    print('score:\n{}'.format(score))
    return score
def calc_discrete_entropy(agent_stats, skill_headers=None, pop=None):
    agent_skills = get_pop_stats(agent_stats['skills'], pop)
    lifespans = get_pop_stats(agent_stats['lifespans'], pop)
    agent_skills_0 = np.vstack(agent_skills)
    agent_lifespans = np.hstack(lifespans)
    weights = sigmoid_lifespan(agent_lifespans)
    agent_skills = (agent_skills_0.transpose() * weights)
    agent_skills = agent_skills.transpose()
    BASE_VAL = 0.0001
    n_skills = len(agent_skills[0])
    n_pop = len(agent_skills)
    agent_sums = [sum(skills) for skills in agent_skills]
    i = 0
    for a in agent_sums:
        if (a == 0):
            agent_sums[i] = (BASE_VAL * n_skills)
        i += 1
    skill_sums = [0 for i in range(n_skills)]
    for i in range(n_skills):
        for a_skills in agent_skills:
            skill_sums[i] += a_skills[i]
        if (skill_sums[i] == 0):
            skill_sums[i] = (BASE_VAL * n_pop)
    skill_ents = []
    for i in range(n_skills):
        skill_ent = 0
        for j in range(n_pop):
            a_skill = agent_skills[j][i]
            if (a_skill == 0):
                a_skill = BASE_VAL
            p = (a_skill / skill_sums[i])
            if (p == 0):
                skill_ent += 0
            else:
                skill_ent += (p * np.log(p))
        skill_ent = (skill_ent / n_pop)
        skill_ents.append(skill_ent)
    agent_ents = []
    for j in range(n_pop):
        agent_ent = 0
        for i in range(n_skills):
            a_skill = agent_skills[j][i]
            if (a_skill == 0):
                a_skill = BASE_VAL
            p = (a_skill / agent_sums[j])
            if (p == 0):
                agent_ent += 0
            else:
                agent_ent += (p * np.log(p))
        agent_ent = (agent_ent / n_skills)
        agent_ents.append(agent_ent)
    agent_score = np.mean(agent_ents)
    skill_score = np.mean(skill_ents)
    score = (- (skill_score * agent_score))
    score = (score * 100)
    print('agent skills:\n{}\n{}'.format(skill_headers, np.array(agent_skills_0.transpose())))
    print('lifespans:\n{}'.format(lifespans))
    print('score:\n{}'.format(score))
    return score