scikit-cuda icon indicating copy to clipboard operation
scikit-cuda copied to clipboard

Integrate modied gaussian defined integral

Open jaimecoj opened this issue 3 years ago • 1 comments

The integral is like this:

formula

I was thinking of using quad but is not supported. However, non-accelerated quad is very slow and I'm in need of optimice my script.

Do you know if this can be done by another scipy.integrate method by collection samples? If so, in which points would I need to collect samples?

I can accept a small error of 0.001 or less

jaimecoj avatar Jul 12 '20 10:07 jaimecoj

Are t1, d1, t2, d2 fixed parameters? If so, scipy.integrate.quad() seems to run pretty rapidly for the following example:

import functools

import numpy as np
import scipy.integrate as integrate
import scipy.special as sp

def modified_gaussian(x, t1, d1, t2, d2):
    sqrt2 = np.sqrt(2)
    return (np.exp(-x**2/2)*(0.5*sp.erf((t1-x)/(sqrt2*np.sqrt(d1**2+5.12)))*+0.5)*\
        (0.5*sp.erf((t2-x)/(sqrt2*np.sqrt(d2**2+5.12)))+0.5))/(sqrt2*np.pi)

t1 = 1
d1 = 1
t2 = 1
d2 = 1
f = functools.partial(modified_gaussian, t1=t1, d1=d1, t2=t2, d2=d2)
print(integrate.quad(f, -np.inf, np.inf))

lebedov avatar Jul 13 '20 12:07 lebedov