#NEWLINE# def sample_conditional( self , index ) : #NEWLINE# #INDENT# if ( ( index < 0 ) or ( index >= self . dimension ) ) : #NEWLINE# #INDENT# raise ValueError ( 'Conditional index out of bounds' ) #NEWLINE# #UNINDENT# cond_inds = hstack ( ( arange ( 0 , index ) , arange ( ( index + 1 ) , self . dimension ) ) ) #NEWLINE# mu_x = self . full_target . mu [ index ] #NEWLINE# Sigma_xx = self . full_Sigma [ ( index , index ) ] #NEWLINE# mu_y = self . full_target . mu [ cond_inds ] #NEWLINE# Sigma_yy = self . full_Sigma [ ( cond_inds , cond_inds ) ] . reshape ( len ( cond_inds ) , len ( cond_inds ) ) #NEWLINE# L_yy = cholesky ( Sigma_yy ) #NEWLINE# Sigma_xy = self . full_Sigma [ ( index , cond_inds ) ] #NEWLINE# Sigma_yx = self . full_Sigma [ ( cond_inds , index ) ] #NEWLINE# y = self . current_state [ cond_inds ] #NEWLINE# mu = ( mu_x + Sigma_xy . dot ( MatrixTools . cholesky_solve ( L_yy , ( y - mu_y ) ) ) ) #NEWLINE# Sigma = ( Sigma_xx - Sigma_xy . dot ( MatrixTools . cholesky_solve ( L_yy , Sigma_yx ) ) ) #NEWLINE# conditional_sample = ( ( randn ( ) * sqrt ( Sigma ) ) + mu ) #NEWLINE# return conditional_sample