#NEWLINE# def integrate_gaussian( self , mean , cov ) : #NEWLINE# #INDENT# "\n        Multiply estimated density by a multivariate Gaussian and integrate\n        over the whole space.\n\n        Parameters\n        ----------\n        mean : aray_like\n            A 1-D array, specifying the mean of the Gaussian.\n        cov : array_like\n            A 2-D array, specifying the covariance matrix of the Gaussian.\n\n        Returns\n        -------\n        result : scalar\n            The value of the integral.\n\n        Raises\n        ------\n        ValueError :\n            If the mean or covariance of the input Gaussian differs from\n            the KDE's dimensionality.\n\n        " #NEWLINE# mean = atleast_1d ( squeeze ( mean ) ) #NEWLINE# cov = atleast_2d ( cov ) #NEWLINE# if ( mean . shape != ( self . d , ) ) : #NEWLINE# #INDENT# raise ValueError ( ( 'mean does not have dimension %s' % self . d ) ) #NEWLINE# #UNINDENT# if ( cov . shape != ( self . d , self . d ) ) : #NEWLINE# #INDENT# raise ValueError ( ( 'covariance does not have dimension %s' % self . d ) ) #NEWLINE# #UNINDENT# mean = mean [ : , newaxis ] #NEWLINE# sum_cov = ( self . covariance + cov ) #NEWLINE# sum_cov_chol = linalg . cho_factor ( sum_cov ) #NEWLINE# diff = ( self . dataset - mean ) #NEWLINE# tdiff = linalg . cho_solve ( sum_cov_chol , diff ) #NEWLINE# sqrt_det = np . prod ( np . diagonal ( sum_cov_chol [ 0 ] ) ) #NEWLINE# norm_const = ( power ( ( 2 * pi ) , ( sum_cov . shape [ 0 ] / 2.0 ) ) * sqrt_det ) #NEWLINE# energies = ( sum ( ( diff * tdiff ) , axis = 0 ) / 2.0 ) #NEWLINE# result = ( ( sum ( exp ( ( - energies ) ) , axis = 0 ) / norm_const ) / self . n ) #NEWLINE# return result