help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fixed points piecewise-linear fitting


From: Ben Abbott
Subject: Re: fixed points piecewise-linear fitting
Date: Tue, 20 Mar 2012 18:33:45 -0400

On Mar 20, 2012, at 6:14 PM, Martin Helm wrote:

> Am 20.03.2012 22:31, schrieb Ben Abbott:
>> After more testing I concluded the problem isn't a linear one. Meaning
>> that your linear solution isn't working as I'd hoped. For my example
>> the RMSE was about 70 for your solution and about 10 for my fsolve()
>> approach. I did find that your linear approach provided a reasonable
>> initial guess, so I am using that. I'll clean things up and attach the
>> script later. Ben 
> Ben, not sure what you exactly tested, I rewrote my function slightly to
> match yours (giving back the pp structure) and compared
> 
> x = 0:39;
> y = [8.8500 32.0775 74.7375 107.6775 132.0975 156.6675 ...
>  169.0650 187.5375 202.2575 198.0750 225.9600 204.3550 ...
>  233.8125 204.5925 232.3625 204.7550 220.1925 199.5875 ...
>  197.3025 175.3050 218.6325 163.0775 170.6625 148.2850 ...
>  154.5950 135.4050 138.8600 125.6750 118.8450 99.2675 ...
>  129.1675 91.1925 89.7000 76.8825 83.6625 74.1950 ...
>    73.9125 55.8750 59.8675 48.1900];
> xi = linspace (min (x), max (x), ceil (numel (x) / 5));
> pp = ppolyfit (x, y, xi, "spline");
> yi = ppval (pp, xi);
> clf
> plot (x, y, "s", xi, yi, "o", x, ppval (pp, x));
> xlabel ("Dependent Variable")
> ylabel ("Fitted Function")
> legend ("data", "interval bounds", "fit")
> xlabel ("Dependent Variable")
> ylabel ("Fitted Function")
> legend ("data", "interval bounds", "fit")
> pp2 = ppfit2 (xi, x, y, "spline");
> hold on
> plot (x, ppval (pp2, x), "b--");
> disp (max(abs(ppval (pp2, x) - ppval (pp, x))))
> 
> which returns as max difference in the function values 6.7130e-08
> 
> attached the slightly modified ppfit2
> 
> <ppfit2.m>

Ok. Thanks for updated version.

I'll take another look.

Ben


reply via email to

[Prev in Thread] Current Thread [Next in Thread]