clear
window 0
defaults
!
a=2
b=0.3
c=4
generate x 0,,10 50
generate\random r 1 1.2 50
y=a*exp(-b*(x-c)^2)+r
set
 plotsymbol -1
 %xnumbersheight 3
 %ynumbersheight 3
 
graph x y
scalar\fit a b c d
fit\chisq y=a*exp(-b*(x-c)^2)+d
fit\update yf
set
 plotsymbol 0
 curvecolor red

graph\overlay x yf
get
 %xloweraxis xlx
 %xupperaxis xux
 %yupperaxis yux

set
 %textheight 3
 textfont 'Arial'
 %xtextlocation 0.5*(xlx+xux)
 %ytextlocation yux+1
 textalign 2
 textinteractive 0

yux = yux-2
text 'Fit: y=a*e<^>-b*(x-c)<^>2<_><_> + d'
set
 textfont 'Courier New'
 textalign 1
 %textheight 2
 %xtextlocation 55
 %ytextlocation yux-5

text 'a = '//rchar(a)
set %ytextlocation yux-10
text 'b = '//rchar(b)
set %ytextlocation yux-15
text 'c = '//rchar(c)
set %ytextlocation yux-20
text 'd = '//rchar(d)
set %ytextlocation yux-25
text 'Total <V1%><chi><V-1%><^>2<_> = '//rchar(fit$chisq)
