def lastList(abar, bCtoS, alpha, beta, N, M, start, time, t_1, iter): #runs app_sim 'iter' times and lists the last element per iteration probVal = [] for i in range(iter): x = app.app_sim(abar, bCtoS, alpha, beta, N, M, start, time, t_1)[-1] if x == 0: probVal.append(0.0) else: probVal.append(1.0) return probVal
import applause_functions as app import matplotlib.pyplot as plt import numpy as np N = 10 M = 10 population = N * M time = 100 t_1 = 3 aStoC = 1.0 bCtoS = 0.5 alpha = 0.8 beta = 2 fig = plt.figure() ax = fig.add_subplot(111) plt.plot(app.app_sim(aStoC, bCtoS, alpha, beta, N, M, time, t_1)) plt.axhline(app.steady_nC(aStoC, bCtoS, alpha, beta, population, 0), color='r') ax.text(0.5 * time, app.steady_nC(aStoC, bCtoS, alpha, beta, population, -1) + 1, 'Steady-state: ' + str(app.steady_nC(aStoC, bCtoS, alpha, beta, population, -1)), fontsize=20) ax.text(90, 100, 'N = ' + str(population)) plt.title('a = ' + str(aStoC) + ' b = ' + str(bCtoS) + ' alpha = ' + str(alpha) + ' beta = ' + str(beta)) plt.xlabel('Time') plt.ylabel('State C') plt.savefig('a = ' + str(aStoC) + ' b = ' + str(bCtoS) + ' alpha = ' + str(alpha) + ' beta = ' + str(beta) + '.png') plt.show()
for alpha_iter in range(1, 3, 1): for bCtoS_iter in range(1, 3, 1): #lists to be graphed duration = [] durationSTD = [] population = [] for pop in popSet: #goes thru popSet appDurationTrials = [] #temporary holder of trials to be averaged for j in range( trials): #simulates parameters and population TRAIL times N = pop sim = app.app_sim(aStoC, bCtoS_iter * 0.1, alpha_iter * 0.1, beta, N, N, C, t, t_1) appDurationTrials.append(indexFilter(0, sim, 1, t)) duration.append(np.mean(appDurationTrials)) durationSTD.append(np.std(appDurationTrials)) population.append(N * N) #scatter plot with error bars #plt.subplot(111, xscale="log") fig = plt.figure() ax = fig.add_subplot(111, xscale="log") x = population y = duration plt.errorbar(x, y, xerr=0, yerr=durationSTD, fmt='o') plt.title('$a = $' + str(aStoC) + ' $b = $' + str(bCtoS_iter * 0.1) + r' $\alpha=$' + str(alpha_iter * 0.1) + r' $\beta=$' +
N = 10 M = 10 population = N * M t = 500 t_1 = 1 C = 0 aStoC = 0.7 bCtoS = 0.8 alpha = 0.5 beta = 4 start_time = time.time() fig = plt.figure() ax = fig.add_subplot(111) sim1 = app.app_sim(aStoC, bCtoS, alpha, beta, N, M, C, t, t_1) sim2 = app.feed_space(aStoC, bCtoS, alpha, beta, N, M, C, t, t_1,M,0) sim3 = app.feed_space(aStoC, bCtoS, alpha, beta, N, M, C, t, t_1,0,1) sim4 = app.feed_space(aStoC, bCtoS, alpha, beta, N, M, C, t, t_1,0,0) plt.plot(sim1, color='b', label="FC") plt.plot(sim2, color='r', label="180deg") plt.plot(sim3, color='g', label="90deg") plt.plot(sim4, color='y', label="0deg") plt.legend(loc=4) ax.text(1,5,'N = '+str(population), fontsize=15) plt.title('$a = $'+str(aStoC)+' $b = $'+str(bCtoS)+r' $\alpha=$'+str(alpha)+r' $\beta=$'+str(beta),fontsize=20) plt.xlabel('Time',fontsize=18) plt.ylabel('State'+r' $n_{c}$',fontsize=18) plt.xlim(0,30)
import numpy as np N = 10 M = 10 population = N * M time = 500 t_1 = 2 C = 0 aStoC = 1 bCtoS = 0.8 alpha = 0.6 beta = 1 fig = plt.figure() ax = fig.add_subplot(111) sim = app.app_sim(aStoC, bCtoS, alpha, beta, N, M, C, time, t_1) plt.plot(sim) ax.text(0.45 * time, 1, 'Steady-state:' + str(round(app.steady_nC(aStoC, bCtoS, alpha, beta, population, 1), 0)), fontsize=20) ax.text(0.45 * time, 10, 'Mean: ' + str(round(np.mean(sim), 1)) + '$\pm$' + str(round(np.std(sim), 2)), fontsize=20) ax.text(10, 100, 'N = ' + str(population), fontsize=15) plt.axhline(np.mean(sim), color='r') plt.axhline(app.steady_nC(aStoC, bCtoS, alpha, beta, population, 1), color='g') plt.title('$a = $' + str(aStoC) + ' $b = $' + str(bCtoS) + r' $\alpha=$' +