来自 Igor Pro 的卷积指数高斯概率函数

计算科学 计算物理学 软件
2021-12-08 14:02:57

我试图从我的研究中从软件 Igor Pro 中找出三卷积指数高斯概率函数的确切公式。不幸的是,我与该软件最接近的方程式是它的编码,如下所示:

w[0]+(w[3]/w[4])*ExpGauss(t-w[2],w[4],w[1])+(w[5]/w[6])*ExpGauss(t-w[2],w[6],w[1])+(w[7]/w[8])*ExpGauss(t-w[2],w[8],w[1])

在哪里:

w[0] = y0, w[1] = pw, w[2] = t0, w[3] = amp1, w[4] = G1, w[5] = amp2, w[6] = G2, w[7] = amp3, w[8] = G3

制作上面的公式:

y0 + (amp1/G1)*ExpGauss(t-t0,G1,pw) + (amp2/G2)*ExpGauss(t-t0,G2,pw) + (amp3/G3)*ExpGauss(t-t0,G3,pw)

如您所见,我了解其中的大部分内容,但是我不确定 ExpGauss 代码的工作原理如何,在查看了 Igor pro 之后,我认为它是这样的:

fExpGauss(t,r,s) = r*exp( -r*t + s^2*r^2/2 )

这在理论上意味着:

w[0]+(w[3]/w[4])*w[4]*exp( -w[4]*t-w[2] + w[1]^2*w[4]^2/2 )+(w[5]/w[6])*w[6]*exp( -w[6]*t-w[2] + w[1]^2*w[6]^2/2 )+(w[7]/w[8])*w[8]*exp( -w[8]*t-w[2] + w[1]^2*w[8]^2/2 )

这是正确的,我将不胜感激。

1个回答

所以我想通了,这是完整的代码,这将生成卷积的三个高斯曲线以及开始的激励。

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 轴)到衰减开始的函数:在我的研究中,它是激发。这产生了我的动态图。看起来像这样:

在此处输入图像描述