def test_extrema_moran_5(lim=1e-16): """ Test for extrema of the stationary distribution. """ n = 3 N = 60 mu = (3. / 2) * 1. / N m = [[0, 1, 1], [1, 0, 1], [1, 1, 0]] maxes = set([(20, 20, 20), (0, 0, 60), (0, 60, 0), (60, 0, 0), (30, 0, 30), (0, 30, 30), (30, 30, 0)]) fitness_landscape = linear_fitness_landscape(m) incentive = fermi(fitness_landscape, beta=0.1) edges = incentive_process.multivariate_transitions(N, incentive, num_types=n, mu=mu) s = stationary_distribution(edges, lim=lim) s2 = expected_divergence(edges, q_d=0) flow = inflow_outflow(edges) # These sets should all correspond assert_equal(find_local_maxima(s), set(maxes)) assert_equal(find_local_minima(s2), set(maxes)) assert_equal(find_local_minima(flow), set(maxes)) # The minima are pathological assert_equal(find_local_minima(s), set([(3, 3, 54), (3, 54, 3), (54, 3, 3)])) assert_equal(find_local_maxima(s2), set([(4, 52, 4), (4, 4, 52), (52, 4, 4)])) assert_equal(find_local_maxima(flow), set([(1, 58, 1), (1, 1, 58), (58, 1, 1)]))
def test_extrema_moran_5(lim=1e-16): """ Test for extrema of the stationary distribution. """ n = 3 N = 60 mu = (3./2) * 1./N m = [[0, 1, 1], [1, 0, 1], [1, 1, 0]] maxes = set([(20, 20, 20), (0, 0, 60), (0, 60, 0), (60, 0, 0), (30, 0, 30), (0, 30, 30), (30, 30, 0)]) fitness_landscape = linear_fitness_landscape(m) incentive = fermi(fitness_landscape, beta=0.1) edges = incentive_process.multivariate_transitions( N, incentive, num_types=n, mu=mu) s = stationary_distribution(edges, lim=lim) s2 = expected_divergence(edges, q_d=0) flow = inflow_outflow(edges) # These sets should all correspond assert_equal(find_local_maxima(s), set(maxes)) assert_equal(find_local_minima(s2), set(maxes)) assert_equal(find_local_minima(flow), set(maxes)) # The minima are pathological assert_equal(find_local_minima(s), set([(3, 3, 54), (3, 54, 3), (54, 3, 3)])) assert_equal(find_local_maxima(s2), set([(4, 52, 4), (4, 4, 52), (52, 4, 4)])) assert_equal(find_local_maxima(flow), set([(1, 58, 1), (1, 1, 58), (58, 1, 1)]))
def test_extrema_moran_3(lim=1e-12): """ Test for extrema of the stationary distribution. """ n = 2 N = 100 mu = 6. / 25 m = [[1, 0], [0, 1]] maxes = set([(38, 62), (62, 38)]) mins = set([(50, 50), (100, 0), (0, 100)]) fitness_landscape = linear_fitness_landscape(m) incentive = replicator(fitness_landscape) edges = incentive_process.multivariate_transitions(N, incentive, num_types=n, mu=mu) s = stationary_distribution(edges, lim=lim) flow = inflow_outflow(edges) for q_d in [0, 1]: s2 = incentive_process.kl(edges, q_d=1) assert_equal(find_local_maxima(s), set(maxes)) assert_equal(find_local_minima(s), set(mins)) assert_equal(find_local_minima(s2), set([(50, 50), (40, 60), (60, 40)])) assert_equal(find_local_maxima(flow), set(mins))
def test_extrema_moran_3(lim=1e-12): """ Test for extrema of the stationary distribution. """ n = 2 N = 100 mu = 6./ 25 m = [[1, 0], [0, 1]] maxes = set([(38, 62), (62, 38)]) mins = set([(50, 50), (100, 0), (0, 100)]) fitness_landscape = linear_fitness_landscape(m) incentive = replicator(fitness_landscape) edges = incentive_process.multivariate_transitions(N, incentive, num_types=n, mu=mu) s = stationary_distribution(edges, lim=lim) flow = inflow_outflow(edges) for q_d in [0, 1]: s2 = expected_divergence(edges, q_d=1) assert_equal(find_local_maxima(s), set(maxes)) assert_equal(find_local_minima(s), set(mins)) assert_equal(find_local_minima(s2), set([(50,50), (40, 60), (60, 40)])) assert_equal(find_local_maxima(flow), set(mins))