#NEWLINE# def conditional( self , indices , values ) : #NEWLINE# #INDENT# 'return conditional distribution\n\n        indices are the variables to keep, the complement is the conditioning\n        set\n        values are the values of the conditioning variables\n\n        \x08ar{\\mu} = \\mu_1 + \\Sigma_{12} \\Sigma_{22}^{-1} \\left( a - \\mu_2 \right)\n\n        and covariance matrix\n\n        \\overline{\\Sigma} = \\Sigma_{11} - \\Sigma_{12} \\Sigma_{22}^{-1} \\Sigma_{21}.T\n\n        Parameters\n        ----------\n        indices : array_like, int\n            list of indices of variables in the marginal distribution\n        given : array_like\n            values of the conditioning variables\n\n        Returns\n        -------\n        mvn : instance of MVNormal\n            new instance of the MVNormal class that contains the conditional\n            distribution of the variables given in indices for given\n             values of the excluded variables.\n\n\n        ' #NEWLINE# keep = np . asarray ( indices ) #NEWLINE# given = np . asarray ( [ i for i in range ( self . nvars ) if ( not ( i in keep ) ) ] ) #NEWLINE# sigmakk = self . sigma [ ( keep [ : , None ] , keep ) ] #NEWLINE# sigmagg = self . sigma [ ( given [ : , None ] , given ) ] #NEWLINE# sigmakg = self . sigma [ ( keep [ : , None ] , given ) ] #NEWLINE# sigmagk = self . sigma [ ( given [ : , None ] , keep ) ] #NEWLINE# sigma_new = ( sigmakk - np . dot ( sigmakg , np . linalg . solve ( sigmagg , sigmagk ) ) ) #NEWLINE# mean_new = ( self . mean [ keep ] + np . dot ( sigmakg , np . linalg . solve ( sigmagg , ( values - self . mean [ given ] ) ) ) ) #NEWLINE# return MVNormal ( mean_new , sigma_new )