# gpr

committed 3a94b6b

Renamed variables

# doc/gpr.tex

 \newcommand{\vecr}{\myvec{r}}
 \newcommand{\vecs}{\myvec{s}}
 \newcommand{\vect}{\myvec{t}}
+\newcommand{\vecv}{\myvec{v}}
 \newcommand{\vecu}{\myvec{u}}
-\newcommand{\vecv}{\myvec{v}}
 \newcommand{\vecw}{\myvec{w}}
 \newcommand{\vecy}{\myvec{y}}
 \newcommand{\uuvecy}{\myu{\myu{\vecy}}}

 \newcommand{\Lam}{\mat{\Lambda}}
 \newcommand{\Lamss}{\mat{\Lambda}_{\sigma^2}}
-\newcommand{\Lamssi}{\imat{\Lambda}_{\sigma^2}}
+\newcommand{\Lamssi}{\imat{\Lambda_{\sigma^2}}}

 \begin{document}

 \vecs & = & \diagv{\Lamss} \\
 \vecis & = & \diagv{\Lamssi} \\
 \vecsdh & = & \onehalf\diagv{\dkn} + \transm{W}(\onehalf\dKm W - \dKmn) \\
-\vecu & = & \matU \vecy \\
-\vecv & = & (\Knm \vecu - \vecy) \otimes \vecis \\
-\mu_* & = & \mat{K_{*M}} \vecu \\
+\vect & = & \matU \vecy \\
+\vecu & = & (\Knm \vect - \vecy) \otimes \vecis \\
+\mu_* & = & \mat{K_{*M}} \vect \\
 \sigma^2_* & = & K_* - \mat{K_{*M}}\matS\mat{K_{M*}} + \sigma^2 \matI \\
 l_1 & = & \onehalf (\log|\Km| - \log|\matB| - \log|\Lamss| - N \log 2\pi \red{\, - \, \vecis \cdot \vecr}) \\
-l_2 & = & \onehalf \vecv\cdot\vecy \\
+l_2 & = & \onehalf \vecu\cdot\vecy \\
 l & = & l_1 + l_2 \\
-\vect & = & \diagv{\transm{T}\matT} - \red{2} \vecis \red{\, + \, \vecis\otimes(\vecis \otimes \vecr)} \\
-\vecw & = & \vecv \otimes \vecv \\
-\dl_1 & = & \vecsdh\cdot\vect + \onehalf\trace{\matS\dKm} - \trace{\transm{U}\dKmn} \\
-\tfrac{\dif l_1}{\sigma^2} & = & \onehalf \mathrm{sum} (\vect \red {\, + \, \vecis}) \\
-\dl_2 & = & \vecsdh\cdot\vecw - \vecu\cdot(\dKm \onehalf \vecu + \dKmn \vecv) \\
+\vecv & = & \diagv{\transm{T}\matT} - \red{2} \vecis \red{\, + \, \vecis\otimes(\vecis \otimes \vecr)} \\
+\vecw & = & \vecu \otimes \vecu \\
+\dl_1 & = & \vecsdh\cdot\vecv + \onehalf\trace{\matS\dKm} - \trace{\transm{U}\dKmn} \\
+\tfrac{\dif l_1}{\sigma^2} & = & \onehalf \mathrm{sum} (\vecv \red {\, + \, \vecis}) \\
+\dl_2 & = & \vecsdh\cdot\vecw - \vect\cdot(\dKm \onehalf \vect + \dKmn \vecu) \\
 \tfrac{\dif l_2}{\sigma^2} & = & \onehalf \mathrm{sum}(\vecw) \\
 \dl & = & \dl_1 + \dl_2 \\
 \end{eqnarray*}

# test/oct.m

   r2 = repmat(sum(x' .* x', 2), 1, n2) - 2 * x' * y + repmat(sum(y' .* y', 2)', n1, 1);
   res = eval_rbf2(r2, a, b);
   [dim, N] = size(res);
-  jitter = 0;
   if (dim == N)
+    jitter = 1e-6;
     res = res + jitter*eye(N);
   endif
 end

 y = targets;

-V = chol(Km)' \ Kmn;  % with Qn
+cholKm = chol(Km);
+V = cholKm' \ Kmn;  % with Qn
 Qn = V' * V;

 lam = diag(diag(Kn - Qn));
 S = inv(Km) - inv(B);
 T = cholB' \ Kmn__;
 U = cholB \ T;
-W = chol(Km) \ V;  % with Qn
+W = cholKm \ V;  % with Qn

+r = diag(lam);
 s = diag(lam_sigma2);
 is = diag(inv_lam_sigma2);
 dsh = 0.5 * diag(dKn) + diag(W'*(0.5 * dKm*W - dKmn));

-t = diag(T' * T) - is;
-u = U*y;
-v = (Kmn' * u - y) .* is;
-w = v .* v;

 %%%%%% Log evidence

-le1 = 0.5*(log(det(Km)) - log(det(B)) - sum(log(diag(lam_sigma2))) - N * log(2*pi));
-le2 = 0.5*(v'*y)
-le = le1 + le2
+t = U*y;
+u = (Kmn' * t - y) .* is;
+
+l1 = 0.5*(log(det(Km)) - log(det(B)) - sum(log(s)) - N * log(2*pi))
+l2 = 0.5*(u'*y)
+le = l1 + l2


 %%%%%% Evidence derivative

-dle1 = t' * dsh + 0.5*trace(S'*dKm) - trace(U'*dKmn)
-dle2 = w' * dsh - u'*(dKm*0.5*u + dKmn*v)
-dle = dle1 + dle2
+v = diag(T' * T) - is;
+w = u .* u;
+
+dl1 = v' * dsh + 0.5*trace(S'*dKm) - trace(U'*dKmn)
+dl2 = w' * dsh - t'*(dKm*0.5*t + dKmn*u)
+dl = dl1 + dl2


 %%%%%% Ed's stuff
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.