Gaussian function |
In mathematics, a Gaussian function, often simply referred to as a Gaussian, is a function of the base form:
for arbitrary real constants a, b and non-zero c. It is named after the mathematician Carl Friedrich Gauss. The graph of a Gaussian is a characteristic symmetric "bell curve" shape. The parameter a is the height of the curve's peak, b is the position of the center of the peak, and c (the Half Width at Half Maximun (HWHM) controls the width of the "bell". ‘d’ is the background constant value. ( y-shift) Gaussian functions are often used to represent the probability density function of a normally distributed random variable. |
|
The following script is an example of gaussian interpolation. It generates some noisy data and interpolates them with a gaussian curve. It is used in this web-site here for various climatological dataset interpolation. |
SCRIPT : (www.octave.org) clc;clear all; global x10 y10 function delta = effe(p); % MINIMIZING FUNCTION global x10 y10 y = gauss(x10,p); delta = sumsq(y - y10); endfunction function y = gauss(x10,p); % INTERPOLATING FUNCTION w = log(2)/p(3)^2; y = p(1)*exp(-w*(x10-p(2)).^2) + p(4); endfunction % Start Guess is defined (4 parameters) p0(1) = 95 %100 Maximum intensity p0(2) = 0.56 %0.5 Maximum position (x axis) p0(3) = 0.15 %0.1 HWHM p0(4) = 17 %20; Baseline (constant value) % Some noisy data are generated x10 = linspace (0,1,100)'; y10 = gauss(x10,[100 0.5 0.1 20]) + 20*(rand(100,1)-0.5); % fMinSearch on the sum of squares of delta [p1,fer1] = fminsearch('effe',p0); % final plot figure (1,'position',[200 100 700 500]); plot(x10,y10,'r','marker','+','linestyle','none'); % points axis([0,1,0,140]);grid on;grid minor on;hold on; y11 = gauss(x10,p1); plot(x10,y11,'b','linewidth',2); % curve title(["Max : ",num2str(p1(1))," MaxPos : ",num2str(p1(2))," HWHM : ",num2str(p1(3));" BaseLine: ",num2str(p1(4))," Correlation : ",num2str(corr(y10,y11))],'fontname','verdana','fontsize',12); disp(['correlation = ',num2str(corr(y10,y11))]); disp(['spearman = ',num2str(spearman(y10,y11))]); disp(['kendall = ',num2str(kendall(y10,y11))]);
|