资源简介
高斯过程回归及分类的代码,内容全,有实例,注释清晰。包括分类系列和预测回归系列,值得感兴趣的同学学习借鉴。里面有对应的数据和demo程序,程序可运行,MATLAB2014a下测试通过,其他版本没有测试。(网页版的0
![](http://www.nz998.com/pic/44097.jpg)
代码片段和文件信息
% Calculates for xstar x-coordinates the bestEstimate and the 95%
% confidence interval (bounds) for a Gaussian process regression.
% Mark Ebden July 2008
%
% Inputs:
% k - a handle to the covariance function
% Xy - the training data x- and y-coordinates
% theta - the GP parameters to be passed to the covariance function
% (e.g. length scale periodicity etc.
% sigma_n - the noise (optional -- default 0)
% NOTE: sigma_n should be left as zero if k *already* includes the noise term as I usually do.
% xstar - specify the x-coordinates to solve for (optional -- default is
% to let the algorithm choose them)
% graphing - produce a plot of results (optional)
% Default is to plot the results unless the function outputs were asked for
%
% Outputs:
% xstar - x-coordinates (default 100 are chosen)
% K - covariance matrix among training data
% V - variance at each xstar
function [xstar bestEstimate bounds K V] = calcGP (k X y theta sigma_n xstar graphing)
if nargin < 7
if nargout == 0
graphing = 1;
else
graphing = 0;
end
end
if nargin < 6 || ~any(xstar)
r2 =(max(X)-min(X));
N = 1e3; % How many points to use
z = .5; % How much to extend the time series on either side (e.g. .5 is 50% extension on left and on right)
xstar = (0:N)/N * (z*2+1)*r2 + min(X)-r2*z;
end
if nargin < 5
sigma_n = 0;
end
if nargin < 4
theta = [1 0 1 0];
end
% a) Initializations
meany = mean(y); y = y - meany;
n = size(X1); lx = length(xstar);
K = zeros(n); kstar = zeros(n1);
for i = 1:n
for j = 1:n
K(ij) = k (X(i)X(j)theta);
end
end
fstarbar = zeros(lx1); V = zeros(lx1);
% b) One-off calculations
diags = max(1e3*eps sigma_n^2); % beef up the diagonal if sigma_n = 0
L = chol (K + diags*eye(n)‘lower‘);
alpha = L‘\(L\y);
logpyX = -y‘*alpha/2 - sum(log(diag(L))) - n*log(2*pi)/2; % Log marginal likelihood
% c) xstar loop
for q = 1:lx
for i = 1:n
kstar(i) = k (X(i)xstar(q)theta);
end
kstar
% Mean of prediction
fstarbar(q) = kstar‘ * alpha;
% Variance of prediction
v = L\kstar;
ystar_noise = sigma_n^2; % recall f* has no noise itself (Algorithm 2.1 on p 19 of H152)
V(q) = k (xstar(q)xstar(q)theta) - v‘*v + ystar_noise;
end
bounds = [fstarbar+1.96*sqrt(V) fstarbar-1.96*sqrt(V)]+meany;
bestEstimate = fstarbar+meany;
% d) Output
if graphing == 1
figure hold on
stdRegion (xstarbounds)
plot (xstarbestEstimate‘k‘)
plot (Xy+meany‘b+‘)
end
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 31996 2006-03-07 20:29 gpml\doc\alg21.gif
文件 43172 2006-03-07 20:08 gpml\doc\alg31.gif
文件 34064 2006-03-07 20:08 gpml\doc\alg32.gif
文件 66673 2006-03-07 20:08 gpml\doc\alg35.gif
文件 32226 2006-03-07 20:08 gpml\doc\alg36.gif
文件 60084 2006-03-07 20:08 gpml\doc\alg51.gif
文件 41085 2006-03-07 20:08 gpml\doc\alg52.gif
文件 34439 2006-03-26 03:00 gpml\doc\classification.html
文件 36772 2006-03-15 00:12 gpml\doc\fig2d.gif
文件 35364 2006-03-15 00:12 gpml\doc\fig2de1.gif
文件 42683 2006-03-15 00:12 gpml\doc\fig2de2.gif
文件 38483 2006-03-15 00:12 gpml\doc\fig2de3.gif
文件 34059 2006-03-15 00:12 gpml\doc\fig2dl1.gif
文件 40431 2006-03-15 00:12 gpml\doc\fig2dl2.gif
文件 38375 2006-03-15 00:12 gpml\doc\fig2dl3.gif
文件 17875 2006-03-10 22:56 gpml\doc\figepp.gif
文件 23299 2006-03-10 22:56 gpml\doc\figepp2.gif
文件 6109 2006-03-27 15:58 gpml\doc\figl.gif
文件 21386 2006-03-07 20:29 gpml\doc\figl1.gif
文件 17854 2006-03-09 23:57 gpml\doc\figlapp.gif
文件 25557 2006-03-09 23:57 gpml\doc\figlapp2.gif
文件 16078 2006-03-27 16:35 gpml\doc\figlf.gif
文件 16712 2006-03-27 22:10 gpml\doc\figlm.gif
文件 3461 2007-06-26 18:30 gpml\doc\index.html
文件 16598 2006-03-29 01:45 gpml\doc\regression.html
文件 7738 2006-03-29 18:39 gpml\doc\sparse-approx.html
文件 77 2006-03-07 20:08 gpml\doc\st
文件 5097 2007-07-24 23:34 gpml\gpml\approxEP.m
文件 1936 2007-06-27 19:45 gpml\gpml\approximations.m
文件 3094 2007-06-26 18:12 gpml\gpml\approxLA.m
............此处省略60个文件信息
- 上一篇:系统聚类法及Matlab软件对系统聚类法的实现
- 下一篇:Matlab求解数独
相关资源
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
- k近邻算法matlab实现
- matlab识别系统
评论
共有 条评论