|
From: Thomas S. <t.s...@fz...> - 2011-03-04 10:16:35
|
your data look like an energy loss spectrum of a particle detector. in order to fit a gaussian you first need to do a background subtraction. we assume an exponential function here. background(x)=b0*exp(-x/bc) we use only the two points at x=100 and x=700, resp. to determine the background. fit background(x) 'ts.dat' using ($1==100||$1==700?$1:0/0):2 via b0, b and then we fit the gaussian fit [90:800] gauss(x) 'ts.dat' using 1:($2-background($1)) via position, amplitude, sigma the complete script: datafile = 'ts.dat' set samples 1000 set yrange [0:*] gauss(x)=amplitude/(sigma*sqrt(2.*pi))*exp(-(x-position)**2/(2.*sigma**2)) background(x)=b0*exp(-x/bc) b0=30 bc=200 fit background(x) datafile using ($1==100||$1==700?$1:0/0):2 \ via b0, b amplitude=10000 sigma=100 position=350 fit [90:800] gauss(x) datafile using 1:($2-background($1)) \ via position, amplitude, sigma plot datafile using 1:2 with histeps title 'data', \ '' using 1:($2-background($1)) with histeps title 'data-background', \ gauss(x), background(x), gauss(x)+background(x) baouche wrote: > > This is my best data: > > 50 0.6 > 100 22 > 150 20 > 200 20.4 > 250 37 > 300 34.4 > 350 39.2 > 400 39.2 > 450 32.2 > 500 27 > 550 10.8 > 600 5.4 > 650 3.4 > 700 0.4 > 750 0 > > Regards > -- View this message in context: http://old.nabble.com/how-to-draw-Gaussian-shape-with-histogram-tp31029938p31066345.html Sent from the Gnuplot - User mailing list archive at Nabble.com. |