-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcorrgauss.m
32 lines (30 loc) · 958 Bytes
/
corrgauss.m
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
29
30
31
32
function [r, dr] = corrgauss(theta, d)
%CORRGAUSS Gaussian correlation function,
%
% n
% r_i = prod exp(-theta_j * d_ij^2) , i = 1,...,m
% j=1
%
% If length(theta) = 1, then the model is isotropic:
% all theta_j = theta .
%
% Call: r = corrgauss(theta, d)
% [r, dr] = corrgauss(theta, d)
%
% theta : parameters in the correlation function
% d : m*n matrix with differences between given data points
% r : correlation
% dr : m*n matrix with the Jacobian of r at x. It is
% assumed that x is given implicitly by d(i,:) = x - S(i,:),
% where S(i,:) is the i'th design site.
% hbn@imm.dtu.dk
% Last update June 2, 2002
%
% make the code faster for MATLAB2016b
% zhandawei@hust.edu.cn
[m, n] = size(d); % number of differences and dimension of data
td = d.^2 .* (repmat(-theta(:)',m,1));
r = exp(sum(td, 2));
if nargout > 1
dr = (ones(m,1)*(-2*theta(:).')) .* d .* (r*ones(1,n));
end