Question: Need help with fixing the python code to display an output identical the shown in the picture:from numpy import zeros, linspace import matplotlib.pyplot as plt

Need help with fixing the python code to display an output identical the shown in the picture:from numpy import zeros, linspace
import matplotlib.pyplot as plt
from scipy import stats
import math
dt =5
N_t =7
B =[0.015,0.021,0.031,0.04,0.055,0.075,0.106]
dB = zeros(N_t)
Bexp = zeros (N_t)
t = linspace(0, N_t-1, N_t)
t_actual = linspace(0,(N_t-1)*dt, N_t)
for i in range(0, N_t-1):
dB[i]= B[i+1]- B[i]
copy_dB = dB[:(N_t-1)]
copy_B = B[:(N_t-1)]
slope, intercept, r_value, p_value, std_err = stats.linregress (copy_B, copy_dB)
tdouble = math.log(2)/math.log(1+slope)*dt
mu= math.log(2)/tdouble
Bexp[0]= B[0]
for i in range(1, N_t):
Bexp[i]= B[0]* math.exp(mu*t_actual[i])
plt.figure(2)
plt.plot(t_actual, B,"bo", t_actual, B[0]*pow(slope+1,t), t_actual, Bexp, "ro")
plt.legend(["data","B0*(1+c)^(t/5)","B0*exp(mu*t)"], loc= "upper left")
plt.xlabel("time")
plt.ylabel("B")
dt_7=7
t_actual_7= linspace(0,(N_t-1)*dt_7, N_t)
Bexp_7= zeros(N_t)
Bexp_7[0]= B[0]
for i in range (1, N_t):
Bexp_7[i]= Bexp_7[i-1]* math.exp(mu*t_actual[i])
plt.plot(t_actual, B,"bo", t_actual, B[0]*pow(slope+1,t),"r-", t_actual_7, B[0]*2.718**(mu*t_actual_7),"gs")
plt.legend(["data","B0*(1+c)^(t/5)","B[0]*2.718**(mu*t_actual_7)"], loc="upper left")
plt.xlabel("time")
plt.ylabel("B")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!