Thread Subject: Partial curve fitting

Subject: Partial curve fitting

From: Gy?rgy Kov?cs

Date: 24 May, 2009 23:29:02

Message: 1 of 5

Hi,

It might be a bit stupid question, but I've started to use curve fitting toolbox, and I wonder if there is a way to fit a specially formed curve to only a part of the data points, without knowing beforehand wich part to fit.
To make it a bit more clear, what I want to do:
I have a series of data points, say this graph:
 [URL=http://img162.imagevenue.com/img.php?image=06948_example_122_869lo.jpg][IMG]http://img162.imagevenue.com/loc869/th_06948_example_122_869lo.jpg[/IMG][/URL]
Now I want to decompose this, to specific curves, in these forms:
 [URL=http://img257.imagevenue.com/img.php?image=06953_effects_122_531lo.jpg][IMG]http://img257.imagevenue.com/loc531/th_06953_effects_122_531lo.jpg[/IMG][/URL]
But I don't want to specify the beginning and the end of the different curves, I want the program to find those automatically.
So I run curve fitting, and what I get is the following:
 [URL=http://img109.imagevenue.com/img.php?image=07229_example_2_122_1191lo.jpg][IMG]http://img109.imagevenue.com/loc1191/th_07229_example_2_122_1191lo.jpg[/IMG][/URL]
 And I get this, because it tries to fit the curve to the whole data set. But what I want is a function, that fits better on a part of it, where the function not equals 0.5 and I don't care how it fits, where the function is 0.5. I could easily do this, If I would just cut out that part, where I want to achieve a better fit. But then the decomposition would not be automatic.
I hope someone can help. Thanks for any advice.

Subject: Partial curve fitting

From: John D'Errico

Date: 25 May, 2009 03:32:01

Message: 2 of 5

"Gy?rgy Kov?cs" <wirth6@gmail.com> wrote in message <gvcl7u$p85$1@fred.mathworks.com>...
> Hi,
>
> It might be a bit stupid question, but I've started to use curve fitting toolbox, and I wonder if there is a way to fit a specially formed curve to only a part of the data points, without knowing beforehand wich part to fit.
> To make it a bit more clear, what I want to do:
> I have a series of data points, say this graph:
> [URL=http://img162.imagevenue.com/img.php?image=06948_example_122_869lo.jpg][IMG]http://img162.imagevenue.com/loc869/th_06948_example_122_869lo.jpg[/IMG][/URL]
> Now I want to decompose this, to specific curves, in these forms:
> [URL=http://img257.imagevenue.com/img.php?image=06953_effects_122_531lo.jpg][IMG]http://img257.imagevenue.com/loc531/th_06953_effects_122_531lo.jpg[/IMG][/URL]
> But I don't want to specify the beginning and the end of the different curves, I want the program to find those automatically.
> So I run curve fitting, and what I get is the following:
> [URL=http://img109.imagevenue.com/img.php?image=07229_example_2_122_1191lo.jpg][IMG]http://img109.imagevenue.com/loc1191/th_07229_example_2_122_1191lo.jpg[/IMG][/URL]
> And I get this, because it tries to fit the curve to the whole data set. But what I want is a function, that fits better on a part of it, where the function not equals 0.5 and I don't care how it fits, where the function is 0.5. I could easily do this, If I would just cut out that part, where I want to achieve a better fit. But then the decomposition would not be automatic.
> I hope someone can help. Thanks for any advice.

There are many things in this world that you may want.

Perhaps you have one of those computers that you see
in the movies, where all you need to do is talk to it.
Something simple like this:

"sequence alien DNA"

The computer immediately responds

"processing"

And, of course, in about 30 seconds, the computer is
done with this simple task.

Oh. You don't have one of those new CPUs? The ones
with 16 zettabytes of RAM for memory, and 21 exaflops
of processing power for each of its 1048576 cores? I
think it runs Vista as an OS.

Yeah, I know, I still have to write code myself too.

John

Subject: Partial curve fitting

From: Miroslav Balda

Date: 25 May, 2009 08:24:01

Message: 3 of 5

SNIP
> But I don't want to specify the beginning and the end of the different curves, I want the program to find those automatically.
SNIP

Hi,

It sounds like a joke. The program has to have some criterion to decide what points of your data to select. Say, you have to set a half-width of independent variable interval, which will be used for cutting off all data points outside the interval distributed round the point of your interst. And then you may use your data fit.

Mira

Subject: Partial curve fitting

From: Gy?rgy Kov?cs

Date: 25 May, 2009 09:36:01

Message: 4 of 5

"Miroslav Balda" <balda.remove.this@cdm.cas.cz> wrote in message <gvdkj1$gsv$1@fred.mathworks.com>...
> SNIP
> > But I don't want to specify the beginning and the end of the different curves, I want the program to find those automatically.
> SNIP
>
> Hi,
>
> It sounds like a joke. The program has to have some criterion to decide what points of your data to select. Say, you have to set a half-width of independent variable interval, which will be used for cutting off all data points outside the interval distributed round the point of your interst. And then you may use your data fit.
>
> Mira

First, I'm sorry, for not being completely clear. I couldn't make the needed distinction between the curve I want to fit, and the data points, I want to fit the curve to. At some point I called both 'curve'.
So what I was looking for is a way to judge how much a curve is fitting to the data points, based on only the part of the curve, where it is not taking a particular value. So this curve:
 [URL=http://img265.imagevenue.com/img.php?image=44446_example2_1_122_48lo.jpg][IMG]http://img265.imagevenue.com/loc48/th_44446_example2_1_122_48lo.jpg[/IMG][/URL]
is recognized to be a better fit, than this red curve:
[URL=http://img19.imagevenue.com/img.php?image=44448_example2_2_122_1124lo.jpg][IMG]http://img19.imagevenue.com/loc1124/th_44448_example2_2_122_1124lo.jpg[/IMG][/URL]

Subject: Partial curve fitting

From: Richard Willey

Date: 26 May, 2009 12:42:28

Message: 5 of 5

>It might be a bit stupid question, but I've started to use curve fitting
>toolbox, and
>I wonder if there is a way to fit a specially formed curve to only a part
>of the data points,
>without knowing beforehand wich part to fit.

Hi Grygory

From the sounds of things, you're interested in a change point detection
algorithm. (You need an algorithm that is able to detect the most likely
point in time at which your data set is flipping from model 1 to model 2).

Unfortunately, neither Curve Fitting Toolbox nor Statistics Toolbox have any
change point detection algorithms available by default. With this said and
done, MATLAB is a really great platform for implementing change point
detection algorithms.

Here's a few pointers that you might find useful:

If you google change point + MATLAB + Bayesian you can find a lot of useful
citations.

I personally found "Bayesian Econometric Methods" by Koop, Poirier, and
Tobias pretty easy to follow. The "Computational Statistics Handbook with
MATLAB" by Martinez and Martinez is another useful source with pretty
accessible source code.

The CUSUM algorithm is an oldie but goodie... Base MATLAB includes an
algorithm called CUMSUM which can be easily modified for this type of work.
However, you might find the follow example easier to understand

%% Random data



clear all

clc



% Create A



A = randn(100,1);

A = A+100;



B = randn(100,1);

B = B + 101;



data = [A;B];



% Calculate the Cumulate Sum



%Calculate the average

 mu = mean(data);



% Initialize the cumulative sum

CUSUM = zeros(length(data)+1,1);



CUSUM(1) = 0 + data(1) - mu;



%CUMSUM Loop



for i = 2:length(data)

    CUSUM(i) = CUSUM(i-1) + (data(i) - mu);

end



plot(CUSUM)



% Find the inflection point



X = linspace(1,length(CUSUM),length(CUSUM));

X = X';

Y = CUSUM;

cfun = fit(X,Y,'poly2');

upordown = differentiate(cfun,1);



if upordown < 0, index = find(CUSUM == min(CUSUM))

else

    index = find(CUSUM == max(CUSUM));

end;



index





Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com