1

I am trying to implement this function in theano. This is not about solving the integral (which is immediate) but rather how to implement it. So far I have gotten this

import theano
from theano import tensor as T
import numpy as np
import scipy.integrate as integrate

x = T.vector('x')
h = T.vector('h')
t = T.scalar('t')

A = np.asarray([[0,1],[1,0]])       
A = theano.shared(name='A', value=A)  

B = np.asarray([[-1,0],[0,-1]])       
B = theano.shared(name='B', value=B)

xn = A.dot(x)
hn = B.dot(h)

res = (t + xn.dot(hn))**(-2)
g = theano.function([t,x,h],res) # this computes the integrand

f = theano.function([x,h], integrate.quad(lambda t: g(t,x,h), 10, np.inf))

Unfortunately, this doesn't work. I am getting the error missing 2 required positional arguments: 'x' and 'h'. Maybe the integrate.quad function cannot "see" the inputs x,h.

Thanks a lot for the help!

tenticon
  • 2,639
  • 4
  • 32
  • 76

0 Answers0