[optimal, result] = ccl_learna_nhat (Un) Learn state independent null space projection P Input: Un Observations of null space component Output: optimal Returned optimal model result Returned results
0001 function [optimal, result] = ccl_learna_nhat (Un) 0002 % [optimal, result] = ccl_learna_nhat (Un) 0003 % 0004 % Learn state independent null space projection P 0005 % 0006 % Input: 0007 % 0008 % Un Observations of null space component 0009 % 0010 % Output: 0011 % 0012 % optimal Returned optimal model 0013 % result Returned results 0014 0015 0016 0017 0018 % CCL: A MATLAB library for Constraint Consistent Learning 0019 % Copyright (C) 2007 Matthew Howard 0020 % Contact: matthew.j.howard@kcl.ac.uk 0021 % 0022 % This library is free software; you can redistribute it and/or 0023 % modify it under the terms of the GNU Lesser General Public 0024 % License as published by the Free Software Foundation; either 0025 % version 2.1 of the License, or (at your option) any later version. 0026 % 0027 % This library is distributed in the hope that it will be useful, 0028 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0029 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0030 % Lesser General Public License for more details. 0031 % 0032 % You should have received a copy of the GNU Library General Public 0033 % License along with this library; if not, write to the Free 0034 % Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 0035 0036 % setup parameters for search 0037 search.dim_u = size(Un,1) ; % dimensionality of the action space 0038 search.dim_n = size(Un,2) ; % number of data points 0039 search.num_theta= 20 ; % number of candidate constraints (from 0 to pi) 0040 search.dim_t = search.dim_u - 1 ; % number of parameters needed to represent an unit vector 0041 search.epsilon = search.dim_u * 0.001 ; 0042 search = ccl_math_ss (search) ; 0043 0044 % vectorises the matrix 0045 Vn = zeros(search.dim_n, search.dim_u^2) ; 0046 for n = 1:search.dim_n 0047 UnUn = Un(:,n)*Un(:,n)' ; 0048 Vn(n,:) = UnUn(:)' ; 0049 end 0050 0051 % search the first constraint 0052 result.model{1} = ccl_learna_sfa (Vn, Un, [], search) ; 0053 optimal = result.model{1} ; 0054 0055 % search the next constraint until the new constraint does not fit 0056 for alpha_id = 2:search.dim_t 0057 result.model{alpha_id} = ccl_learna_sa_nhat (Vn, Un, result.model{alpha_id-1}, search) ; 0058 if result.model{alpha_id}.nmse_j < .1 0059 optimal = result.model{alpha_id} ; 0060 else 0061 return ; 0062 end 0063 end 0064 end