Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!feeder.news-service.com!newsfeed.kamp.net!newsfeed.kamp.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Ingo Thies Newsgroups: comp.graphics.apps.gnuplot Subject: Re: Fitting: How does gnuplot calculate the covariance matrix? Date: Thu, 14 Apr 2011 15:07:19 +0200 Lines: 42 Message-ID: <90o9s9F5aiU1@mid.individual.net> References: <9088euFi3iU1@mid.individual.net> <908n9pF2jaU1@mid.individual.net> <90e7s7F9faU1@mid.dfncis.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: individual.net GL3wHgHTDApMm3yHky//FQH836yoi6DUG4tWz4XhCskmgh+Efk Cancel-Lock: sha1:uBeaaNkEkQmPi6Krr/COu9S13Os= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 In-Reply-To: <90e7s7F9faU1@mid.dfncis.de> Xref: x330-a1.tempe.blueboxinc.net comp.graphics.apps.gnuplot:256 On 10.04.2011 19:31, Hans-Bernhard Bröker wrote: > gnuplot> p 'fit.dat' u 1:2:3 w err, a*x+b w l > gnuplot> rep (a+a_err)*x+b+b_err, (a-a_err)*x+b-b_err > gnuplot> a_thies=0.195 > gnuplot> b_thies=.083 > gnuplot> rep (a+a_thies)*x+b+b_thies, (a-a_thies)*x+b-b_thies I have modified the model function to minimize the correlation of a and b. This has been done by substituting x by x-x0, where x0 is the mean of all x (2 in this case). Here is the full script, to be applied to the same data table ('fit.tab'). To enhance visibility, I have given different colors for the different error types (blue for gnuplot's, red for mine). Please look again at the errors. Are they still _way_ too large? Or aren't gnuplot's errors now _way_ too small? set fit errorvar #x0=0.; a_thies=0.195; b_thies=0.083 # old fit x0=2.; a_thies=0.101; b_thies=0.083 # new fit f(x)=a+b*(x-x0) set xrange [0:4] set yrange [0.5:3] fit [0:4] f(x) xfile u 1:2:3 via a,b set key left p a+b*(x-x0) w l lc rgb '#0000ff',\ a-a_err+(b-b_err)*(x-x0) lc rgb '#007fff',\ a+a_err+(b+b_err)*(x-x0) lc rgb '#007fff',\ a-a_thies+(b-b_thies)*(x-x0) lc rgb '#ff0000',\ a+a_thies+(b+b_thies)*(x-x0) lc rgb '#ff0000',\ 'fit.dat' u 1:2:3 w err lc rgb '#000000' I would find it highly confusing if the error corridors depend on a simple substitution. If one plotts the a,b error contours, and uses them for the error estimate (i.e. walks around the 1-sigma contour in the a-b space and creates the enveloping curve for all possible resulting functions), then the "way-too-large" error for the slope b remains constant. Only the error for the offset a changes, as expected. -- Gruß, Ingo