How to implement the Gaussian radial basis function in MATLAB ?

9 Ansichten (letzte 30 Tage)
charu shree
charu shree am 20 Mär. 2023
Bearbeitet: Torsten am 21 Mär. 2023
Hello all, I am dealing with the following optimization problem
where is a column vector of dimension , is also a column vector of dimension , is matrix of dimension , is row vector of and is the Gaussian radial basis function, where is the variance.
My query is how to code this Gaussian radial basis function (RBF) ?
Any help in this regard will be highly appreciated.

Akzeptierte Antwort

Torsten
Torsten am 21 Mär. 2023
Bearbeitet: Torsten am 21 Mär. 2023
Before you start the optimization, check whether K in your case is positive-definite.
Lt = 10;
p = rand(Lt,4);
sigma = 1.0;
for l = 1:Lt
for j = 1:Lt
K(l,j) = exp((norm(p(l,:)-p(j,:)))^2/(2*sigma^2));
end
end
K
K = 10×10
1.0000 1.0558 1.2332 1.1752 1.1144 1.7121 1.4345 1.4970 1.3174 1.4356 1.0558 1.0000 1.1059 1.1852 1.0453 1.4602 1.3978 1.2603 1.1884 1.3441 1.2332 1.1059 1.0000 1.4993 1.1769 1.7198 1.2359 1.2245 1.2960 1.8679 1.1752 1.1852 1.4993 1.0000 1.3279 1.1864 1.5427 1.3336 1.2247 1.0896 1.1144 1.0453 1.1769 1.3279 1.0000 1.6242 1.4504 1.5273 1.1608 1.4210 1.7121 1.4602 1.7198 1.1864 1.6242 1.0000 1.7290 1.2760 1.2118 1.1176 1.4345 1.3978 1.2359 1.5427 1.4504 1.7290 1.0000 1.5769 1.2315 1.9993 1.4970 1.2603 1.2245 1.3336 1.5273 1.2760 1.5769 1.0000 1.4254 1.5342 1.3174 1.1884 1.2960 1.2247 1.1608 1.2118 1.2315 1.4254 1.0000 1.2412 1.4356 1.3441 1.8679 1.0896 1.4210 1.1176 1.9993 1.5342 1.2412 1.0000
eig(K)
ans = 10×1
-1.7051 -0.8915 -0.6203 -0.3001 0.0081 0.0171 0.0346 0.0637 0.1039 13.2897
  6 Kommentare
Torsten
Torsten am 21 Mär. 2023
Bearbeitet: Torsten am 21 Mär. 2023
Thank you for the correction.
Is it somehow obvious that the matrix will be positive-definite ?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Matt J
Matt J am 21 Mär. 2023
Bearbeitet: Matt J am 21 Mär. 2023
If you have the Statistics Toolbox, you can avoid a loop by using pdist2
Lt = 10;
p = rand(Lt,4);
sigma = 1.0;
K=exp(-pdist2(p,p).^2 / 2/sigma^2);

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by