07-11-2012 06:21 AM
Hi,
I am writing a tool that allows me to calculate a segmental curve fit for discontinuous data, comparable to example 1 or 3 here or to this picture. It is supposed to consist of a linear, followed by an exponential curve fit, which meet at a breakpoint. Just splitting the data array into part does not do the job, because the fits won't meet at the optimal point (see example 2 in the link given above). Is there any way to do this with readily existing LabVIEW VIs, or do I have to go into the mathematics? There are indeed closed mathematical formulations for lin-lin segmented curve fits that could be more or less easily implemented, however, I did not succeed to find any for the given problem.
Thank you,
Frank
Solved! Go to Solution.
07-11-2012 06:38 AM - edited 07-11-2012 06:38 AM
Hi Frank,
the interpolation VIs offer several ways of limiting the results: ExponentialFit offers "weight" for each sample and "parameter bounds" to limit offset...
Did you play with those inputs?
Can you attach a VI containing a sample waveform with your data?
07-11-2012 10:31 AM
I found an iterative solution by setting a large weight to an approximate breakpoint and then evaluating the sum of regressions for both fit curves. It's not what I'd consider a "nice" solution, but at least I get something that looks right. Unfortunately I don't have a way of checking whether the output is correct or not.
07-11-2012 12:33 PM
To fit a segmented curve is absolutely no problem and I've done it many times. The switch point is simply another fitting parameter to be used in the evaluation of the model. Use "nonlinear fit" and implement the model accordingly. The initial amplitude will be more accurate, because more points contribute to it.
07-11-2012 01:05 PM - edited 07-11-2012 01:06 PM
Your data is quite noisy and you don't have many points. This gives some uncertainty and also some sensitivity to initial parameter guesses. Do you know more about the system under study? For example is the switchover point known exactly? In that case you don't need to fit for it.
Here's a quick draft how you could do it. Modify as needed.
07-12-2012 03:11 AM
Thanks a lot altenbach. I actually did try to use the nonlinear fit, but obviously without fully understanding its concept. By the way, the data shows the development of yearly averages of sulfur dioxide immissions in Germany (data from the Federal Environmental Agency). So the switchover point is not "exactly" known - I was rather surprised to find something the like. Whether the proposed segmented curve is appropriate to fit the data may be at question.
07-12-2012 03:09 PM
Christian beat me to it, but here is a similar implementation. I borrowed some of Christian's notation. There are two differences:
1. The first segment is a line with slope, not a simple level.
2. The only initial guess required is the offset.
This also shows the use of constrained nonlinear fitting.
-Jim
07-13-2012 12:59 AM
Looks like you're using a LabVIEW Version > 2011; I can't open the VIs. Would you mind posting them again, saved in another version? Thanks.
07-13-2012 02:27 AM
Apologies. Here is the 2011 version.