File: FindCovLinMod.m

package info (click to toggle)
psychtoolbox-3 3.0.19.14.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 86,796 kB
  • sloc: ansic: 176,245; cpp: 20,103; objc: 5,393; sh: 2,753; python: 1,397; php: 384; makefile: 193; java: 113
file content (28 lines) | stat: -rw-r--r-- 621 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function [B,w0,Kw] = FindCovLinMod(Kx,nDim,x0)
% [B,w0,Kw] = FindCovLinMod(Kx,nDim,[x0])
% 
% Find the linear model for a set of vectors
% distributed Normally with covariance matrix K.
%
% The second two return values are only computed
% if x0 is passed.
%
% 8/22/94		dhb		Wrote it.

% Compute the SVD of the covariance matrix
[U,D,V] = svd(Kx);
if (MatMax(U-V) > 1e-10)
	error('Theory says U should equal V in svd of a covariance matrix');
end

% Extract the bases.  They are orthonormal.
B = U(:,1:nDim);

% Compute mean in new basis if raw mean was passed.
if (nargin == 3)
	w0 = B\x0;
	Kw = D(1:nDim,1:nDim);
end