Question: using python with the code below, I want to use the function at the bottom that I put in bold to essentially substitute dpre for
using python with the code below, I want to use the function at the bottom that I put in bold to essentially substitute dpre for v1 and for v2 use dpre_alpha_plus, then minus, then dpre_h_plus then minus, and finally dpre_A0_plus, then minus. I want to get the value of those 6 calculations.
from math import exp
import matplotlib.pyplot as plt
def d_pre(A0, alpha, h, t):
d = A0*((exp(-t/alpha))/(1+(t**h)))
return d
x = []
y = []
x2, y2 = [[], []]
x3, y3 = [[], []]
x4, y4 = [[], []]
x5, y5 = [[], []]
x6, y6 = [[], []]
x7, y7 = [[], []]
i = 0.01
while i <= 0.51:
# find values for different dpre
dpre = d_pre(0.88, 0.23, 0.38, i)
dpre_alpha_plus = d_pre(0.88, 0.23*1.1, 0.38, i)
dpre_alpha_minus = d_pre(0.88, 0.23*.09, 0.38, i) dpre_h_plus = d_pre(0.88, 0.23, 0.38*1.1, i) dpre_h_minus = d_pre(0.88, 0.23, 0.38*0.9, i) dpre_A0_plus = d_pre(0.88*1.1, 0.23, 0.38, i) dpre_A0_minus = d_pre(0.88*0.9, 0.23, 0.38, i)
# appedn the values to list
x.append(i)
y.append(dpre)
x2.append(i)
y2.append(dpre_alpha_plus)
x3.append(i)
y3.append(dpre_alpha_minus) x4.append(i)
y4.append(dpre_h_plus) x5.append(i)
y5.append(dpre_h_minus) x6.append(i)
y6.append(dpre_A0_plus) x7.append(i)
y7.append(dpre_A0_minus)
i += 0.01
plt.plot(x, y, label='dpre') plt.plot(x2, y2, label = 'dpre_alpha_plus') plt.plot(y3, y3, label = 'dpre_alpha_minus') plt.plot(y4, y4, label = 'dpre_h_plus') plt.plot(y5, y5, label = 'dpre_h_minus') plt.plot(y6, y6, label = 'dpre_A0_plus') plt.plot(y7, y7, label = 'dpre_A0_minus') plt.legend() plt.xlabel('time(s)') plt.ylabel('predicted response(unitless)')
plt.show()
t = [] x = 0.01 while x<=0.51: t.append(x) x += 0.01
def norm2(v1, v2): result = 0 for i in range(len(v1)): result += (v1[i]-v2[i])**2 result = result**0.5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
