def two_dim_wright_fisher_figure(N, m, mu=0.01, incentive_func=replicator): """ Plot relative entropies and stationary distribution for the Wright-Fisher process. """ n = len(m[0]) fitness_landscape = linear_fitness_landscape(m) incentive = incentive_func(fitness_landscape) if not mu: mu = 1. / N edge_func = wright_fisher.multivariate_transitions(N, incentive, mu=mu, num_types=n) states = list(simplex_generator(N, d=n - 1)) s = stationary_distribution(edge_func, states=states, iterations=4 * N) s0 = expected_divergence(edge_func, states=states, q_d=0) s1 = expected_divergence(edge_func, states=states, q_d=1) # Set up plots gs = gridspec.GridSpec(2, 1) ax2 = pyplot.subplot(gs[0, 0]) ax2.set_title("Relative Entropy") plot_dictionary(s0, ax=ax2) plot_dictionary(s1, ax=ax2) ax3 = pyplot.subplot(gs[1, 0]) ax3.set_title("Stationary Distribution") plot_dictionary(s, ax=ax3) ax3.set_xlabel("Number of A individuals (i)")
def two_dim_wright_fisher_figure(N, m, mu=0.01, incentive_func=replicator): """ Plot relative entropies and stationary distribution for the Wright-Fisher process. """ n = len(m[0]) fitness_landscape = linear_fitness_landscape(m) incentive = incentive_func(fitness_landscape) if not mu: mu = 1./ N edge_func = wright_fisher.multivariate_transitions(N, incentive, mu=mu, num_types=n) states = list(simplex_generator(N, d=n-1)) s = stationary_distribution(edge_func, states=states, iterations=4*N) s0 = expected_divergence(edge_func, states=states, q_d=0) s1 = expected_divergence(edge_func, states=states, q_d=1) # Set up plots gs = gridspec.GridSpec(2, 1) ax2 = pyplot.subplot(gs[0, 0]) ax2.set_title("Relative Entropy") plot_dictionary(s0, ax=ax2) plot_dictionary(s1, ax=ax2) ax3 = pyplot.subplot(gs[1, 0]) ax3.set_title("Stationary Distribution") plot_dictionary(s, ax=ax3) ax3.set_xlabel("Number of A individuals (i)")
def two_dim_transitions_figure(N, m, mu=0.01, incentive_func=replicator): """ Plot transition entropies and stationary distributions. """ n = len(m[0]) fitness_landscape = linear_fitness_landscape(m) incentive = incentive_func(fitness_landscape) if not mu: mu = 1./ N edges = incentive_process.multivariate_transitions(N, incentive, num_types=n, mu=mu) s = stationary_distribution(edges, exact=True) d = edges_to_edge_dict(edges) # Set up plots gs = gridspec.GridSpec(3, 1) ax1 = pyplot.subplot(gs[0, 0]) ax1.set_title("Transition Probabilities") ups, downs, _ = two_dim_transitions(edges) xs = range(0, N+1) ax1.plot(xs, ups) ax1.plot(xs, downs) ax2 = pyplot.subplot(gs[1, 0]) ax2.set_title("Relative Entropy") divs1 = expected_divergence(edges) divs2 = expected_divergence(edges, q_d=0) plot_dictionary(divs1, ax=ax2) plot_dictionary(divs2, ax=ax2) ax3 = pyplot.subplot(gs[2, 0]) ax3.set_title("Stationary Distribution") plot_dictionary(s, ax=ax3) ax3.set_xlabel("Number of A individuals (i)")
def two_dim_transitions_figure(N, m, mu=0.01, incentive_func=replicator): """ Plot transition entropies and stationary distributions. """ n = len(m[0]) fitness_landscape = linear_fitness_landscape(m) incentive = incentive_func(fitness_landscape) if not mu: mu = 1. / N edges = incentive_process.multivariate_transitions(N, incentive, num_types=n, mu=mu) s = stationary_distribution(edges, exact=True) d = edges_to_edge_dict(edges) # Set up plots gs = gridspec.GridSpec(3, 1) ax1 = pyplot.subplot(gs[0, 0]) ax1.set_title("Transition Probabilities") ups, downs, _ = two_dim_transitions(edges) xs = range(0, N + 1) ax1.plot(xs, ups) ax1.plot(xs, downs) ax2 = pyplot.subplot(gs[1, 0]) ax2.set_title("Relative Entropy") divs1 = expected_divergence(edges) divs2 = expected_divergence(edges, q_d=0) plot_dictionary(divs1, ax=ax2) plot_dictionary(divs2, ax=ax2) ax3 = pyplot.subplot(gs[2, 0]) ax3.set_title("Stationary Distribution") plot_dictionary(s, ax=ax3) ax3.set_xlabel("Number of A individuals (i)")