From help-octave-request at bevo dot che dot wisc dot edu Tue Feb 11 02:40:42 2003 Subject: Re: polyfit weirdness From: Etienne Grossmann To: Scott Lamb Cc: help-octave at bevo dot che dot wisc dot edu, Etienne Grossmann Date: Tue, 11 Feb 2003 08:46:35 +0000 On Tue, Feb 11, 2003 at 02:08:37AM -0600, Scott Lamb wrote: # I'm trying to use Octave (2.1.36, 2.1.44) for the first time. I want to # put some data in, make a trendline, and make a graph with the raw data, # trendline, trendline's formula, and correlation displayed, and attach # them to a LaTeX document when I'm done. (The sort of thing I could do # easily in Excel, but I want to learn a new open-source tool.) # # So first I'm calling polyfit to get the trendline: # # l1 = 1e-9 * [ 578.45 545.88 435.87 404.71 365.26 ] # v1 = [ 0.66 0.79 1.40 1.58 1.92 ] # f1 = 299792458 ./ l1 f1 = 5.1827e+14 5.4919e+14 6.8780e+14 7.4076e+14 8.2076e+14 A problem with order of magnitude of f1 and floating-point limitations? octave:63> f1 /= 1e14; octave:64> [p1,cv1] = polyfit(f1,v1,1)' p1 = 0.41679 -1.49481 cv1 = 0.66528 0.79417 1.37189 1.59260 1.92606 Is that more like what you expected? Hth, Etienne # [p1,cv1] = polyfit(f1,v1,1) # # ...and it doesn't return what I'd expect at all: # # p1 = # # 1.9796e-15 # 2.8980e-30 # # cv1 = # # 1.0260 1.0872 1.3616 1.4664 1.6248 # # cv1 should hold its computed (near-identical to v1) values, right? But # they're not even close. Doing this in Excel gives a slope of 4.17e-15 # and R^2 = .999. So these definitely aren't right. What am I doing # incorrectly? # # Thanks, # Scott Lamb # # # # ------------------------------------------------------------- # Octave is freely available under the terms of the GNU GPL. # # Octave's home on the web: http://www.octave.org # How to fund new projects: http://www.octave.org/funding.html # Subscription information: http://www.octave.org/archive.html # ------------------------------------------------------------- # # # -- Etienne Grossmann ------ http://www.isr.ist.utl.pt/~etienne ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------