I am receiving a ValueError
when integrating using scipy.integrate.quad
. Here is my simplified code:
import numpy as np
import scipy.integrate as integrate
p = np.arange(0,1,1/1000)
h = lambda p: p**2/2+p*(1-p)
Kl = lambda p: h(p) + 0.02
K = Kl(p)
R = 0.5*h(p) + 0.5*h(1)
Vl = lambda p: np.minimum.reduce([p, K, R])
integrate.quad(Vl, 0, 1)[0]
The last line gives the exception:
ValueError: setting an array element with a sequence.
Can someone please propose how to do this integration properly? Thanks