所以我想通了,这是完整的代码,这将生成卷积的三个高斯曲线以及开始的激励。
import math
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
# Import curve fitting package from scipy
from scipy.optimize import curve_fit
def GammP(lnc, g):
return lnc/g
def Gamm(alpha):
return 0.773389
def GammLNC(x):
return -np.exp(-pow(x,2)/2)*x
def three_exp_Gaussian(t, y, alpha, beta, gamma, pw, a, b, c):
return y + (alpha/a)*exp_Gaussian(t, a, pw) + (beta/b)*exp_Gaussian(t, b, pw) + (gamma/c)*exp_Gaussian(t, c, pw)
# Function to calculate the exp_Gaussian with constants t, r, and s
def exp_Gaussian(t, r, s):
return r*np.exp( -1*r*t + pow(s, 2)*pow(r,2)/2 )
# Generate dummy dataset
x_neg_dummy = np.linspace(start=-5, stop=-0.9, num=60)
x_dummy = np.linspace(start=0.1, stop=25, num=100)
# Calculate y-values based on dummy x-values
alpha = GammLNC(x_neg_dummy)
beta = Gamm(x_neg_dummy)
y_neg_dummy = -GammP(alpha, beta)
y_neg_dummy = y_neg_dummy/0.78425044
y_dummy = -three_exp_Gaussian(x_dummy, 0.0, 0.4, 0.3, 0.3, 0.075, 0.6, 0.3, 0.1)
# Add noise from a Gaussian distribution
noise_neg = 0.02*np.random.normal(size=y_neg_dummy.size)
y_neg_dummy = y_neg_dummy + noise_neg
noise = 0.02*np.random.normal(size=y_dummy.size)
y_dummy = y_dummy + noise
# Fit the dummy Gaussian data
pars, cov = curve_fit(f=three_exp_Gaussian, xdata=x_dummy, ydata=y_dummy, p0=[0, 0.2, 0.3, 0.4, 0.075, 0.7, 0.2, 0.1], bounds=(0.0, 1000))
y_curve_fit = three_exp_Gaussian(x_dummy, *pars)
# Plot the noisy exponential data
fig = plt.figure()
ax = plt.axes()
ax.scatter(x_neg_dummy+0.9, y_neg_dummy, s=20, color='black', label='Data')
ax.scatter(x_dummy, y_dummy, s=20, color='black', label='Data')
for axis in ['top','bottom','left','right']:
ax.spines[axis].set_linewidth(2)
plt.show()
所以:
# Function to calculate the exp_Gaussian with constants t, r, and s
def exp_Gaussian(t, r, s):
return r*np.exp( -1*r*t + pow(s, 2)*pow(r,2)/2 )
是igor pro的指数高斯函数公式写成:
decay rate * exp(-(decay rate)*time + (width^2*(decay rate)^2)/2)
所以卷积的三高斯曲线是三个指数高斯的总和,每个高斯的幅度和衰减率之比。
def three_exp_Gaussian(t, y, alpha, beta, gamma, pw, a, b, c):
return y + (alpha/a)*exp_Gaussian(t, a, pw) + (beta/b)*exp_Gaussian(t, b, pw) + (gamma/c)*exp_Gaussian(t, c, pw)
所以它的公式是:
base-line + (amplitude1/(decay rate1))exp(-(decay rate1)*time + (width^2*(decay rate1)^2)/2)+(amplitude2/(decay rate2))exp(-(decay rate2)*time + (width^2*(decay rate2)^2)/2) + (amplitude3/(decay rate3))exp(-(decay rate3)*time + (width^2*(decay rate3)^2)/2)
所以衰减从负 1 开始,然后进行第一次衰减,然后是第二次,最后是第三次产生衰减曲线。
伽玛:
def GammP(lnc, g):
return lnc/g
def Gamm(alpha):
return 0.773389
def GammLNC(x):
return -np.exp(-pow(x,2)/2)*x
是 igor pro 如何绘制从时间轴(x 轴)到衰减开始的函数:在我的研究中,它是激发。这产生了我的动态图。看起来像这样:
