File:Desommation gaussienne lorentzienne.svg
Original file (SVG file, nominally 610 × 460 pixels, file size: 59 KB)
Captions
Summary[edit]
DescriptionDesommation gaussienne lorentzienne.svg |
English: Non linear regression to fit the curve with the sum of a lorentzian function and a gaussian function. Français : Régression non linéaire pour ajuster la courbe avec la somme d'une fonction lorentzienne et d'une fonction gaussienne. |
Date | |
Source | Own work |
Author | Cdang |
Scilab source
This media was created with Scilab, a free open-source software. Here is a listing of the Scilab source used to create this file. |
File gaussian_lorentzian_functions.sci
: the function we are working with (library).
// *************
// * Fonctions *
// *************
// Gaussian function centered on 0
function [y] = gauss(A, x)
// A(1) : peak height
// A(2) : peak "width"
y = A(1)*exp(-x.*x/A(2));
endfunction
// Lorentzian function centered on 0
function [y] = lorentz(A, x)
// A(1) : peak height
// A(2) : peak "width"
foo = A(2)*A(2);
y = foo*A(1)./(foo + 4*x.*x);
endfunction
function [y] = profile(A, x)
// A(1) : lorentzian peak height
// A(2) : lorentzian peak "width"
// A(3) : gaussian peak height
// A(4) : gaussian peak "width"
L = A(1:2);
G = A(3:4);
y = lorentz(L, x) + gauss(G, x);
endfunction
File gaussian_lorentzian_peak_generator.sce
: creates a data set and saves it in the noisy_gaussian_lorentzian_peak.txt
file.
chdir("mypath\");
exec("gaussian_lorentzian_functions.sci")
// *************
// * Constants *
// *************
paramlorentz(1) = 5; // height of the lorentzian curve
paramlorentz(2) = 2; // "width" of the lorentzian curve
paramgauss(1) = 10; // height of the gaussian curve
paramgauss(2) = 3; // "width" of the gaussian curve
var=0.5; // variance of the noise normal law
nbpts = 100 // number of points
halfwidth = max(3*paramgauss(2), 3*paramlorentz(2)) // for x range
step = 2*halfwidth/nbpts;
// ******************
// * Initialisation *
// ******************
X = zeros(nbpts,1);
Y = zeros(nbpts,1);
// ****************
// * Main program *
// ****************
// Data generation
i=(1:nbpts)'
X = step*i - halfwidth;
Y = profile([paramlorentz;paramgauss], X) + var*rand(X, "normal");
end
// Saving
csvWrite([X, Y], "noisy_gaussian_lorentzian_peak.txt")
File gauss_lorentz_desummation.sce
: process the data to extract the lorentzian and the gaussian components.
// ******************
// * Initialisation *
// ******************
clf;
chdir("mypath\");
exec("gaussian_lorentzian_functions.sci")
// *************
// * Constants *
// *************
Ainit = [1;1;1;1]; // initial parameters of the model function
// *************
// * Functions *
// *************
// Residual function
function [e] = res(A, x, y)
e = profil(A, x) - y;
endfunction
// ****************
// * Main program *
// ****************
// Data reading
data = csvRead("noisy_gaussian_lorentzian_peak.txt")
X = data(:,1);
Y = data(:,2);
// Data processing
[S, Aopt] = leastsq(list(res, X, Y), Ainit)
Yopt = profil(Aopt, X);
YLopt = lorentz(Aopt(1:2),X);
YGopt = gauss(Aopt(3:4),X);
// Display
plot(X, Yopt, "-r")
plot(X, YLopt, "-c")
plot(X, YGopt, "-g")
plot(X, Y, "+b")
height = max(Y);
xmin = min(X)
xstring(xmin, height*0.95,...
"lorentzian: Al = "+string(0.01*round(100*Aopt(1)))...
+"; Hl = "+string(0.01*round(100*Aopt(2))))
xstring(xmin, 3*height/4,...
"gaussian: Ag = "+string(0.01*round(100*Aopt(3)))...
+"; Hg = "+string(0.01*round(100*Aopt(4))))
xstring(xmin, height/2,...
"variance: S = "+string(0.01*round(100*S)))
Licensing[edit]
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 21:11, 2 May 2019 | 610 × 460 (59 KB) | Cdang (talk | contribs) | half variance; rounded values | |
14:40, 8 November 2012 | 483 × 364 (57 KB) | Cdang (talk | contribs) | User created page with UploadWizard |
You cannot overwrite this file.
File usage on Commons
The following page uses this file:
File usage on other wikis
The following other wikis use this file:
- Usage on fr.wikipedia.org
- Usage on fr.wikibooks.org
Metadata
This file contains additional information such as Exif metadata which may have been added by the digital camera, scanner, or software program used to create or digitize it. If the file has been modified from its original state, some details such as the timestamp may not fully reflect those of the original file. The timestamp is only as accurate as the clock in the camera, and it may be completely wrong.
Width | 610 |
---|---|
Height | 460 |