[SciPy-User] vectorized cumulative integration?
Skipper Seabold
jsseabold at gmail.com
Thu May 12 12:30:59 EDT 2011
I have a pdf that I want to integrate from -np.inf to each point in
the support to get the cdf. Right now, I can use list comprehension to
do something like
cdf = [integrate.quad(pdf, -np.inf, end, args=(some_data_array,) for
end in support]
But this takes a few seconds. Alternatively, I can do
cdf = integrate.cumtrapz(pdf_estimate, support)
lower_tail = integrate.quad(pdf, -np.inf, support[0], args=(some_data_array,))
cdf = np.r_[lower_tail, cdf+lower_tail]
The latter seems like it might be a crude approximation, though I'm
not sure. The former is too slow. Any other ideas? I tried to
vectorize the former approach like the generic cdf in
stats.distributions, but since my pdf takes an array argument I had
some trouble and it would take some ugly workarounds I think.
Cheers,
Skipper
More information about the SciPy-User
mailing list