I have two arrays with values x and y, "x" (value of random variable) are input values, and "y" are values calculated as a function of x (normal probability density function for x). How can I calculate the integral of "y" for a range of values in "x". I've seen how to do it, but they all involve writing the function in abstract form and that of the normal distribution is complicated.
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as st
# valores-puntos (x,y) de la función
x=np.linspace(-4,4,num=1000)
y=st.norm.pdf(x,0,1)
print(x,y)
I would like to calculate the integral between -1 and 0 for example. Maybe my only alternative is to write the function as f=lambda x: f(x)
and use integrate.quad(f,lb,ub)
?