#NEWLINE# def predict( self , Z_new , full_output = True , full_cov = False ) : #NEWLINE# #INDENT# '\n        Predict the multinomial probability vector at a grid of points, Z\n        :param Z_new:\n        :return:\n        ' #NEWLINE# assert ( len ( self . data_list ) == 1 ) , 'Must have one data list in order to predict.' #NEWLINE# data = self . data_list [ 0 ] #NEWLINE# M = data [ 'M' ] #NEWLINE# Z = data [ 'Z' ] #NEWLINE# assert ( ( Z_new is not None ) and ( Z_new . ndim == 2 ) and ( Z_new . shape [ 1 ] == self . D ) ) #NEWLINE# M_new = Z_new . shape [ 0 ] #NEWLINE# C = self . kernel . K ( Z , Z ) #NEWLINE# Cvv = ( C + np . diag ( ( 1e-06 * np . ones ( M ) ) ) ) #NEWLINE# Lvv = np . linalg . cholesky ( Cvv ) #NEWLINE# Cnn = self . kernel . K ( Z_new , Z_new ) #NEWLINE# Cnv = self . kernel . K ( Z_new , Z ) #NEWLINE# mu_psis_new = np . zeros ( ( self . K , M_new ) ) #NEWLINE# Sig_psis_new = np . zeros ( ( self . K , M_new , M_new ) ) #NEWLINE# for k in xrange ( self . K ) : #NEWLINE# #INDENT# sys . stdout . write ( '.' ) #NEWLINE# sys . stdout . flush ( ) #NEWLINE# psik = data [ 'psi' ] [ : , k ] #NEWLINE# y = solve_triangular ( Lvv , psik , lower = True ) #NEWLINE# x = solve_triangular ( Lvv . T , y , lower = False ) #NEWLINE# psik_pred = Cnv . dot ( x ) #NEWLINE# mu_psis_new [ k ] = ( psik_pred + self . mu [ k ] ) #NEWLINE# if full_cov : #NEWLINE# #INDENT# Sig_psis_new [ k ] = ( Cnn - Cnv . dot ( dpotrs ( Lvv , Cnv . T , lower = True ) [ 0 ] ) ) #NEWLINE# #UNINDENT# #UNINDENT# sys . stdout . write ( '\n' ) #NEWLINE# sys . stdout . flush ( ) #NEWLINE# pis_new = np . array ( [ ln_psi_to_pi ( psi ) for psi in mu_psis_new ] ) #NEWLINE# if full_output : #NEWLINE# #INDENT# return ( pis_new , mu_psis_new , Sig_psis_new ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return pis_new