Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate modied gaussian defined integral #304

Open
jaimecoj opened this issue Jul 12, 2020 · 1 comment
Open

Integrate modied gaussian defined integral #304

jaimecoj opened this issue Jul 12, 2020 · 1 comment

Comments

@jaimecoj
Copy link

jaimecoj commented Jul 12, 2020

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

@lebedov
Copy link
Owner

lebedov commented Jul 13, 2020

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))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants