<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/252101</link>
    <title>MATLAB Central Newsreader - Partial curve fitting</title>
    <description>Feed for thread: Partial curve fitting</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Sun, 24 May 2009 23:29:02 -0400</pubDate>
      <title>Partial curve fitting</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/252101#652108</link>
      <author>Gy?rgy Kov?cs</author>
      <description>Hi,&lt;br&gt;
&lt;br&gt;
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.&lt;br&gt;
To make it a bit more clear, what I want to do:&lt;br&gt;
I have a series of data points, say this graph:&lt;br&gt;
&amp;nbsp;[URL=&lt;a href=&quot;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]&quot;&gt;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]&lt;/a&gt;&lt;br&gt;
Now I want to decompose this, to specific curves, in these forms:&lt;br&gt;
&amp;nbsp;[URL=&lt;a href=&quot;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]&quot;&gt;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]&lt;/a&gt;&lt;br&gt;
But I don't want to specify the beginning and the end of the different curves, I want the program to find those automatically.&lt;br&gt;
So I run curve fitting, and what I get is the following:&lt;br&gt;
&amp;nbsp;[URL=&lt;a href=&quot;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]&quot;&gt;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]&lt;/a&gt;&lt;br&gt;
&amp;nbsp;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. &lt;br&gt;
I hope someone can help. Thanks for any advice.</description>
    </item>
    <item>
      <pubDate>Mon, 25 May 2009 03:32:01 -0400</pubDate>
      <title>Re: Partial curve fitting</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/252101#652124</link>
      <author>John D'Errico</author>
      <description>&quot;Gy?rgy Kov?cs&quot; &amp;lt;wirth6@gmail.com&amp;gt; wrote in message &amp;lt;gvcl7u$p85$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; 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.&lt;br&gt;
&amp;gt; To make it a bit more clear, what I want to do:&lt;br&gt;
&amp;gt; I have a series of data points, say this graph:&lt;br&gt;
&amp;gt;  [URL=&lt;a href=&quot;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]&quot;&gt;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]&lt;/a&gt;&lt;br&gt;
&amp;gt; Now I want to decompose this, to specific curves, in these forms:&lt;br&gt;
&amp;gt;  [URL=&lt;a href=&quot;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]&quot;&gt;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]&lt;/a&gt;&lt;br&gt;
&amp;gt; But I don't want to specify the beginning and the end of the different curves, I want the program to find those automatically.&lt;br&gt;
&amp;gt; So I run curve fitting, and what I get is the following:&lt;br&gt;
&amp;gt;  [URL=&lt;a href=&quot;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]&quot;&gt;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]&lt;/a&gt;&lt;br&gt;
&amp;gt;  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. &lt;br&gt;
&amp;gt; I hope someone can help. Thanks for any advice.&lt;br&gt;
&lt;br&gt;
There are many things in this world that you may want.&lt;br&gt;
&lt;br&gt;
Perhaps you have one of those computers that you see&lt;br&gt;
in the movies, where all you need to do is talk to it.&lt;br&gt;
Something simple like this:&lt;br&gt;
&lt;br&gt;
&quot;sequence alien DNA&quot;&lt;br&gt;
&lt;br&gt;
The computer immediately responds&lt;br&gt;
&lt;br&gt;
&quot;processing&quot;&lt;br&gt;
&lt;br&gt;
And, of course, in about 30 seconds, the computer is&lt;br&gt;
done with this simple task.&lt;br&gt;
&lt;br&gt;
Oh. You don't have one of those new CPUs? The ones&lt;br&gt;
with 16 zettabytes of RAM for memory, and 21 exaflops&lt;br&gt;
of processing power for each of its 1048576 cores? I&lt;br&gt;
think it runs Vista as an OS.&lt;br&gt;
&lt;br&gt;
Yeah, I know, I still have to write code myself too.&lt;br&gt;
&lt;br&gt;
John</description>
    </item>
    <item>
      <pubDate>Mon, 25 May 2009 08:24:01 -0400</pubDate>
      <title>Re: Partial curve fitting</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/252101#652159</link>
      <author>Miroslav Balda</author>
      <description>SNIP&lt;br&gt;
&amp;gt; But I don't want to specify the beginning and the end of the different curves, I want the program to find those automatically.&lt;br&gt;
SNIP&lt;br&gt;
&lt;br&gt;
Hi,&lt;br&gt;
&lt;br&gt;
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.&lt;br&gt;
&lt;br&gt;
Mira</description>
    </item>
    <item>
      <pubDate>Mon, 25 May 2009 09:36:01 -0400</pubDate>
      <title>Re: Partial curve fitting</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/252101#652178</link>
      <author>Gy?rgy Kov?cs</author>
      <description>&quot;Miroslav Balda&quot; &amp;lt;balda.remove.this@cdm.cas.cz&amp;gt; wrote in message &amp;lt;gvdkj1$gsv$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; SNIP&lt;br&gt;
&amp;gt; &amp;gt; But I don't want to specify the beginning and the end of the different curves, I want the program to find those automatically.&lt;br&gt;
&amp;gt; SNIP&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; 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.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Mira&lt;br&gt;
&lt;br&gt;
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'.&lt;br&gt;
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:&lt;br&gt;
&amp;nbsp;[URL=&lt;a href=&quot;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]&quot;&gt;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]&lt;/a&gt;&lt;br&gt;
is recognized to be a better fit, than this red curve:&lt;br&gt;
[URL=&lt;a href=&quot;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]&quot;&gt;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]&lt;/a&gt;</description>
    </item>
    <item>
      <pubDate>Tue, 26 May 2009 12:42:28 -0400</pubDate>
      <title>Re: Partial curve fitting</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/252101#652440</link>
      <author>Richard Willey</author>
      <description>&amp;gt;It might be a bit stupid question, but I've started to use curve fitting &lt;br&gt;
&amp;gt;toolbox, and&lt;br&gt;
&amp;gt;I wonder if there is a way to fit a specially formed curve to only a part &lt;br&gt;
&amp;gt;of the data points,&lt;br&gt;
&amp;gt;without knowing beforehand wich part to fit.&lt;br&gt;
&lt;br&gt;
Hi Grygory&lt;br&gt;
&lt;br&gt;
From the sounds of things, you're interested in a change point detection &lt;br&gt;
algorithm.  (You need an algorithm that is able to detect the most likely &lt;br&gt;
point in time at which your data set is flipping from model 1 to model 2).&lt;br&gt;
&lt;br&gt;
Unfortunately, neither Curve Fitting Toolbox nor Statistics Toolbox have any &lt;br&gt;
change point detection algorithms available by default.  With this said and &lt;br&gt;
done, MATLAB is a really great platform for implementing change point &lt;br&gt;
detection algorithms.&lt;br&gt;
&lt;br&gt;
Here's a few pointers that you might find useful:&lt;br&gt;
&lt;br&gt;
If you google change point + MATLAB + Bayesian you can find a lot of useful &lt;br&gt;
citations.&lt;br&gt;
&lt;br&gt;
I personally found &quot;Bayesian Econometric Methods&quot; by Koop, Poirier, and &lt;br&gt;
Tobias pretty easy to follow.  The &quot;Computational Statistics Handbook with &lt;br&gt;
MATLAB&quot; by Martinez and Martinez is another useful source with pretty &lt;br&gt;
accessible source code.&lt;br&gt;
&lt;br&gt;
The CUSUM algorithm is an oldie but goodie...  Base MATLAB includes an &lt;br&gt;
algorithm called CUMSUM which can be easily modified for this type of work. &lt;br&gt;
However, you might find the follow example easier to understand&lt;br&gt;
&lt;br&gt;
%% Random data&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
clear all&lt;br&gt;
&lt;br&gt;
clc&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
% Create A&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
A = randn(100,1);&lt;br&gt;
&lt;br&gt;
A = A+100;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
B = randn(100,1);&lt;br&gt;
&lt;br&gt;
B = B + 101;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
data = [A;B];&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
% Calculate the Cumulate Sum&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
%Calculate the average&lt;br&gt;
&lt;br&gt;
&amp;nbsp;mu = mean(data);&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
% Initialize the cumulative sum&lt;br&gt;
&lt;br&gt;
CUSUM = zeros(length(data)+1,1);&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
CUSUM(1) = 0 + data(1) - mu;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
%CUMSUM Loop&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
for i = 2:length(data)&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CUSUM(i) = CUSUM(i-1) + (data(i) - mu);&lt;br&gt;
&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
plot(CUSUM)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
%  Find the inflection point&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
X = linspace(1,length(CUSUM),length(CUSUM));&lt;br&gt;
&lt;br&gt;
X = X';&lt;br&gt;
&lt;br&gt;
Y = CUSUM;&lt;br&gt;
&lt;br&gt;
cfun = fit(X,Y,'poly2');&lt;br&gt;
&lt;br&gt;
upordown = differentiate(cfun,1);&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
if upordown &amp;lt; 0, index = find(CUSUM == min(CUSUM))&lt;br&gt;
&lt;br&gt;
else&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;index = find(CUSUM == max(CUSUM));&lt;br&gt;
&lt;br&gt;
end;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
index</description>
    </item>
  </channel>
</rss>

