def test_bifurcation_plot(): pops = simulate(model=logistic_map, num_gens=200, rate_min=0, rate_max=4, num_rates=100, num_discard=100) assert type(pops)==pd.DataFrame assert pops.shape==(200, 100) # returns None bifurcation_plot(pops, save=True, folder=_img_folder, filename='')
def test_bifurcation_plot(): pops = simulate(model=logistic_map, num_gens=200, rate_min=0, rate_max=4, num_rates=100, num_discard=100) assert type(pops) == pd.DataFrame assert pops.shape == (200, 100) # returns None bifurcation_plot(pops, save=True, folder=_img_folder, filename='')
num_discard=100) # Obtain population size after non-breeding season by direct map from X_{t+1} to Y_{t+1} def x_to_y(x): return x * np.exp(rnb * (1 - x / knb)) # Compute bifurcation points for y by mapping from x bif_data_y = x_to_y(bif_data_x) # Make plot of bifurcation bifurcation_plot(bif_data_x, title='Ricker Bifurcation Diagram', xmin=0, xmax=5, ymin=0, ymax=500, save=False) bifurcation_plot(bif_data_y, title='Ricker Bifurcation Diagram', xmin=0, xmax=5, ymin=0, ymax=500, save=False) # Export bifurcation points bif_data_x.to_csv('../data_export/bif_data_x.csv') bif_data_y.to_csv('../data_export/bif_data_y.csv')
import pynamical from pynamical import simulate, bifurcation_plot, save_fig import pandas as pd, numpy as np, matplotlib.pyplot as plt, matplotlib.cm as cm pops = simulate(num_gens=100, rate_min=0., rate_max=3.5, num_rates=1000, num_discard=100) bifurcation_plot(pops, xmax=3.5, filename='logistic-map-bifurcation-1')
x - breeding population size rb - growth rate during breeding season Ouptut: population size after the following breeding season. ''' # Compute population size after non-breeding season based on x xnew = x * np.exp(r - alpha * x) # Output new population size return xnew # Simulate to get bifurcation points bif_data_x = simulate(model=ricker, num_gens=100, rate_min=0, rate_max=3.5, num_rates=1000, num_discard=100) # Bifurcation plot bifurcation_plot(bif_data_x, title='Non-breeding population size', xmin=0, xmax=3.5, ymin=0, ymax=500, save=False, xlabel='Breeding growth rate (rb)')
def test_bifurcation_plot(): pops = simulate(model=logistic_map, num_gens=200, rate_min=0, rate_max=4, num_rates=100, num_discard=100) bifurcation_plot(pops, save=True, folder=_img_folder, filename='')
import pynamical from pynamical import simulate, bifurcation_plot, save_fig import pandas as pd, numpy as np, IPython.display as display, matplotlib.pyplot as plt, matplotlib.cm as cm from pynamical import logistic_map, simulate, bifurcation_plot pops = simulate(model=logistic_map, num_gens=100, rate_min=0, rate_max=4, num_rates=1000, num_discard=100) bifurcation_plot(pops)
@jit(cache=True, nopython=True) # pragma: no cover def map2(x, r): """ Define the equation for the cubic map. Arguments --------- x: float current population value at time t rate: float growth rate parameter values Returns ------- float result of map at time t+1 """ return r - x - np.exp(x) x = simulate(model=map2, num_gens=100, initial_pop=1, rate_min=0, rate_max=5, num_rates=2000, num_discard=100) bifurcation_plot(x, xmin=-10, xmax=10, ymin=-10, ymax=10)
from pynamical import logistic_map, simulate, bifurcation_plot pops = simulate(model=logistic_map, num_gens=100, rate_min=0, rate_max=4, num_rates=1000, num_discard=100) bifurcation_plot(pops) pops = simulate(model=logistic_map, num_gens=100, rate_min=3.7, rate_max=3.9, num_rates=1000, num_discard=100) bifurcation_plot(pops, xmin=3.7, xmax=3.9) from pynamical import cubic_map, phase_diagram_3d pops = simulate(model=cubic_map, num_gens=3000, rate_min=3.5, num_rates=30, num_discard=100) phase_diagram_3d(pops, xmin=-1, xmax=1, ymin=-1, ymax=1, zmin=-1, zmax=1,
import pynamical from pynamical import simulate, bifurcation_plot, save_fig import pandas as pd, numpy as np, matplotlib.pyplot as plt, matplotlib.cm as cm pops = simulate(num_gens=100, rate_min=0., rate_max=4.0, num_rates=200, num_discard=100) bifurcation_plot(pops, xmax=4.0, filename='logistic-map-bifurcation-6')