我有三个变量(nodes1,nodes2,nodes3)和一个函数f(nodes1,nodes2,nodes3) 如何在每个对变量之间以及具有函数f(nodes1,nodes2,nodes3)的每个变量之间进行计算。
以下是我的代码。
a= -1.24
b=0.011
c=0.005
d=-0.0004
e=0.16
f=-0.00013
g=-2.01e-6
k=-0.002
m=-4.03e-5
l=0.0165
basic_model = pm.Model()
with basic_model:
nodes1 = pm.Normal('nodes1', 0.06, 0.006)
nodes2 = pm.Normal('nodes2', 1, 0.06)
nodes3 = pm.Normal('nodes3', 50.06, 2.88)
# likehood function
mu=a*nodes1**2+b*nodes1*nodes2+c*nodes2**2+d*nodes1*nodes3+e*nodes1+f*nodes2*nodes3+g*nodes3**2+k*nodes2+m*nodes3+l
# posterior distribution
y=pm.Normal('y', mu, 1, observed=evals)
trace = pm.sample(10000, cores =1)
pm.traceplot(trace,varnames= ['nodes1','nodes2','nodes3'])
k = pm.summary(trace).round(2)
pm.plot_posterior (trace, varnames= ['nodes1','nodes2','nodes3'])
tracedf1 = pm.trace_to_dataframe (trace, varnames = ['nodes1','nodes2','nodes3'])
sns.pairplot(tracedf1 )
print (k)
plt.show()
谢谢