Skip to content Skip to sidebar Skip to footer

Double Integration Of X*np.log(x) In Python Using Scipy.integrate.dblquad

The code below uses double integration with scipy.integrate.dblquad to calculate the differential entropy, c*np.log(c), of a copula density function c, which has one dependence par

Solution 1:

The first argument must be a callable, so just wrap it in a lambda itself:

import numpy as np
from scipy import integrate 

defcopula_entropy(theta):
    c = lambda v, u: ((1+theta)*(u*v)**(-1-theta)) * (u**(-theta)+v**(-theta)-1)**(-1/theta-2)
    return -integrate.dblquad(lambda u,v: c(v,u)*np.log(c(v,u)), 0, 1, lambda u: 0, lambda u: 1)[0] 

(Please note that I also changed the expression for c according to the formula you gave).

Post a Comment for "Double Integration Of X*np.log(x) In Python Using Scipy.integrate.dblquad"