def contract_by_lifespan(agent_stats, lifespans):
    'Pull agents close to their mean according to how short-lived they were. For punishing abundance of premature death\n   when rewarding diversity.'
    weights = sigmoid_lifespan(lifespans)
    n_agents = lifespans.shape[0]
    mean_agent = agent_stats.mean(axis=0)
    mean_agents = np.repeat(mean_agent.reshape(1, mean_agent.shape[0]), n_agents, axis=0)
    agent_deltas = (mean_agents - agent_stats)
    agent_skills = (agent_stats + (weights * agent_deltas.T).T)
    return agent_skills
Pull agents close to their mean according to how short-lived they were. For punishing abundance of premature death
when rewarding diversity.
def contract_by_lifespan(agent_stats, lifespans):
    'Pull agents close to their mean according to how short-lived they were. For punishing abundance of premature death\n   when rewarding diversity.'
    weights = sigmoid_lifespan(lifespans)
    n_agents = lifespans.shape[0]
    mean_agent = agent_stats.mean(axis=0)
    mean_agents = np.repeat(mean_agent.reshape(1, mean_agent.shape[0]), n_agents, axis=0)
    agent_deltas = (mean_agents - agent_stats)
    agent_skills = (agent_stats + (weights * agent_deltas.T).T)
    return agent_skills