<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Graph Forums — Cubic Spline Interpolation Bug]]></title>
		<link>https://forum.padowan.dk/viewtopic.php?id=221</link>
		<atom:link href="https://forum.padowan.dk/extern.php?action=feed&amp;tid=221&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Cubic Spline Interpolation Bug.]]></description>
		<lastBuildDate>Mon, 04 Apr 2011 00:38:31 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Cubic Spline Interpolation Bug]]></title>
			<link>https://forum.padowan.dk/viewtopic.php?pid=905#p905</link>
			<description><![CDATA[<p>1D cubic spline interpolation seems to work fine, Ivan. Thanks for adding it.</p><p>I redid all of my graphs, over 100 curves total. Either 1D or 2D worked well in most cases. I defaulted to 1D because some curves had odd artifacts in 2D. I did find one curve where the data wasn&#039;t inherently smooth and 2D worked best. Linear interpolation was best for very dense curves (hundreds of points) and for connecting a few plotted data points with straight lines to emphasize the sparse sampling. It&#039;s nice to have a choice of interpolation method.</p><p>Brian</p>]]></description>
			<author><![CDATA[null@example.com (k6sti)]]></author>
			<pubDate>Mon, 04 Apr 2011 00:38:31 +0000</pubDate>
			<guid>https://forum.padowan.dk/viewtopic.php?pid=905#p905</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cubic Spline Interpolation Bug]]></title>
			<link>https://forum.padowan.dk/viewtopic.php?pid=899#p899</link>
			<description><![CDATA[<p>I have now added the 1D cubic splines as an interpolation option in the latest beta version.</p>]]></description>
			<author><![CDATA[null@example.com (Ivan Johansen)]]></author>
			<pubDate>Sun, 03 Apr 2011 08:44:19 +0000</pubDate>
			<guid>https://forum.padowan.dk/viewtopic.php?pid=899#p899</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cubic Spline Interpolation Bug]]></title>
			<link>https://forum.padowan.dk/viewtopic.php?pid=847#p847</link>
			<description><![CDATA[<p>The picture in my last message should explain it. It creates a more smooth line between the points than just connecting them with a straight line. But I will try to implement 1-dimensional cubic spline to make you and Brian happy. <img src="https://forum.padowan.dk/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[null@example.com (Ivan Johansen)]]></author>
			<pubDate>Sat, 12 Mar 2011 16:10:17 +0000</pubDate>
			<guid>https://forum.padowan.dk/viewtopic.php?pid=847#p847</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cubic Spline Interpolation Bug]]></title>
			<link>https://forum.padowan.dk/viewtopic.php?pid=844#p844</link>
			<description><![CDATA[<p>Hi Ivan,</p><p>maybe we (at least me and Brian) just don&#039;t know what is the 2-D cubic spline suitable for. But one thing is sure: if you add one, (or better several) cubic splines of the 1-dimensional types (including the so called &quot;natural&quot; one - described for instance in the above wikipedia link) -- then everybody will be happy, and no more questions will arise.</p>]]></description>
			<author><![CDATA[null@example.com (victor)]]></author>
			<pubDate>Sat, 12 Mar 2011 01:54:19 +0000</pubDate>
			<guid>https://forum.padowan.dk/viewtopic.php?pid=844#p844</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cubic Spline Interpolation Bug]]></title>
			<link>https://forum.padowan.dk/viewtopic.php?pid=842#p842</link>
			<description><![CDATA[<p>It was never a goal to make an interpolation function where every x-coordinate has exactly one y-coordinate. The goal was to make a line between the points that was more smooth than a linear interpolation, and I think that goal has been reached. </p><p>The normal 1-dimensional cubic spline does not work for my goal in all cases so I used the 2-dimensional variation instead. It is basically a parametric function where both x(t) and y(t) is interpolated as cubic splines. </p><p>I think I first saw it at MathWorld:<br /><a href="http://mathworld.wolfram.com/CubicSpline.html">http://mathworld.wolfram.com/CubicSpline.html</a></p><p>There is also an interactive Java applet here:<br /><a href="http://www.cse.unsw.edu.au/~lambert/splines/natcubic.html">http://www.cse.unsw.edu.au/~lambert/spl … cubic.html</a></p><p>But I understand that other people have other goals. It was always my intention to add more interpolation algorithms, but no matter how many I add there will always be some complaining that I have not implemented their favorite variation. However I will consider adding 1-dimensional cubic splines.</p>]]></description>
			<author><![CDATA[null@example.com (Ivan Johansen)]]></author>
			<pubDate>Fri, 11 Mar 2011 00:22:22 +0000</pubDate>
			<guid>https://forum.padowan.dk/viewtopic.php?pid=842#p842</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cubic Spline Interpolation Bug]]></title>
			<link>https://forum.padowan.dk/viewtopic.php?pid=824#p824</link>
			<description><![CDATA[<p>Brian,<br />I just informed myself a bit more about cubic spline interpolation. You see, there are indeed very many variations of cubic splines.<br />&nbsp; But I agree with you that the one provided by Ivan does not behave in the most expected way. For instance, I repeated the interpolation provided at <a href="http://en.wikipedia.org/wiki/Interpolation">http://en.wikipedia.org/wiki/Interpolation</a> , at the end of the article (the 3 points interp. ) and &quot;Graph&quot; give &quot;strange&quot; results in comparison with the Natural type (see wiki) of cubic spline.</p><p>Thanks for pointing out; I will also write to Ivan.</p>]]></description>
			<author><![CDATA[null@example.com (victor)]]></author>
			<pubDate>Tue, 08 Mar 2011 06:32:05 +0000</pubDate>
			<guid>https://forum.padowan.dk/viewtopic.php?pid=824#p824</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cubic Spline Interpolation Bug]]></title>
			<link>https://forum.padowan.dk/viewtopic.php?pid=823#p823</link>
			<description><![CDATA[<div class="quotebox"><cite>Ivan Johansen wrote:</cite><blockquote><p>I have now been looking into this and there doesn&#039;t seem to be any bugs in the implementation of cubic splines in Graph. The difference in the image shown is because Graph uses 2-dimension cubic splines as opposed to 1-dimension cubic splines. The 2-dimension splines seem to work much better than 1-dimension and will therefore be kept as it is for now. More types of interpolation may be added in the future.</p></blockquote></div><p>Ivan, I just made some little research about cubic spline interpolation. So, what do you mean by 1-dimensional and 2-dimensional cubic splines? Did you actually intend to interpolate a third variable, like z=f(x,y)? That could be the issue then.<br />Please see <a href="http://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html">http://docs.scipy.org/doc/scipy/referen … olate.html</a> , or other.<br />Also, some other simple cubic spline (called &#039;natural&#039;) do interpolate, indeed, in a more expected way. <a href="http://en.wikipedia.org/wiki/Spline_interpolation">http://en.wikipedia.org/wiki/Spline_interpolation</a> (I tried the example there in the end with 3 points); also read the 3rd external link in the same wiki page.</p>]]></description>
			<author><![CDATA[null@example.com (victor)]]></author>
			<pubDate>Tue, 08 Mar 2011 06:22:35 +0000</pubDate>
			<guid>https://forum.padowan.dk/viewtopic.php?pid=823#p823</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cubic Spline Interpolation Bug]]></title>
			<link>https://forum.padowan.dk/viewtopic.php?pid=811#p811</link>
			<description><![CDATA[<p>Here are two more examples. One plots samples from a second-order process and the other plots samples from a third-order process. The red curve is Graph&#039;s internal interpolation, while the blue curve is from an external cubic spline interpolator. In both cases the red curve does not well represent the underlying process. If I had taken more data samples, they would lie exactly on the blue curves, not on the red.</p><p>Another way to state my objection is that most commonly encountered processes are low-order. They are inherently smooth. Attempting to model them as high-order processes will yield invalid and misleading results unless you have a lot of data samples. Graph&#039;s interpolation acts as if its model order were much higher than that of ordinary cubic spline interpolation. It yields curves that are less smooth, change more abruptly, and are more like connecting the dots with linear interpolation. Commonly encountered data isn&#039;t like that.</p><p>Before I wrote my own cubic spline interpolator, whenever I encountered problems with Graph&#039;s cubic spline I would simply plot the data points as dots and use Graph&#039;s linear interpolation to connect them. The resulting curve wasn&#039;t at all smooth, but the obvious straight-line segments and the visible dots provided immediate visual clues about the nature of the model. Anyone looking at the plot could immediately grasp what had been done without obtaining a false impression. They realized that the data wasn&#039;t really piecewise linear. But when I simply used Graph&#039;s cubic spline to plot a curve without marking the data points, the unavoidable impression was that the data followed the curve as shown. In fact, in some places it wasn&#039;t near the curve at all, but the user had no way to know this.</p><p>Ivan could keep his program from plotting misleading curves by simply offering ordinary cubic spline interpolation as an option.</p><p>Brian</p>]]></description>
			<author><![CDATA[null@example.com (k6sti)]]></author>
			<pubDate>Sun, 06 Mar 2011 13:13:34 +0000</pubDate>
			<guid>https://forum.padowan.dk/viewtopic.php?pid=811#p811</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cubic Spline Interpolation Bug]]></title>
			<link>https://forum.padowan.dk/viewtopic.php?pid=809#p809</link>
			<description><![CDATA[<p>Victor, you can draw any curve you want through a set of given points. That doesn&#039;t mean that all curves are equally valid or useful. The problem with Graph&#039;s interpolation method is that it can generate curves that are not representative of commonly encountered data, or that are not smooth, or that are impossible. When I say not representative, I mean that if you take more data samples, they will not lie on or anywhere near the curve Graph generated for the original samples. The curve has mislead you and given a false impression. When I say not smooth, I mean that Graph can insert kinks, abrupt changes of slope that are not warranted by the data, and it can generate straight line segments where a smoothly curved line is appropriate. When I say impossible, I am referring to the fact that Graph can generate curves that have multiple Y values for one X value. The curve is not just in error, it is nonsensical.</p><p>Brian</p>]]></description>
			<author><![CDATA[null@example.com (k6sti)]]></author>
			<pubDate>Sun, 06 Mar 2011 12:04:59 +0000</pubDate>
			<guid>https://forum.padowan.dk/viewtopic.php?pid=809#p809</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cubic Spline Interpolation Bug]]></title>
			<link>https://forum.padowan.dk/viewtopic.php?pid=808#p808</link>
			<description><![CDATA[<div class="quotebox"><cite>Ivan Johansen wrote:</cite><blockquote><p>The red curve seems to be a much better interpolation of the four points than the blue. The blue curve overshoots heavily.</p></blockquote></div><p><img src="https://forum.padowan.dk/img/smilies/smile.png" width="15" height="15" alt="smile" />))</p><p>Good reply, Ivan.</p>]]></description>
			<author><![CDATA[null@example.com (victor)]]></author>
			<pubDate>Sun, 06 Mar 2011 11:45:13 +0000</pubDate>
			<guid>https://forum.padowan.dk/viewtopic.php?pid=808#p808</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cubic Spline Interpolation Bug]]></title>
			<link>https://forum.padowan.dk/viewtopic.php?pid=807#p807</link>
			<description><![CDATA[<div class="quotebox"><cite>k6sti wrote:</cite><blockquote><p>Ivan, I just used a sine wave as an example. I am not creating a function. I am sampling a known function so that it is easy to tell whether the interpolation is reasonable. The defects I&#039;ve highlighted apply to any function or curve. They are not unique to sine waves. They apply also to measured data, as shown in my first example.</p><p>The interpolation method you are using does not yield curves that make sense, curves that are useful for obtaining accurate values between the points supplied, or curves that are mathematically correct. The method as implemented is entirely bogus. It is bizarre. It does not always yield single-valued functions. It bears no relation to a proper interpolation, whether you choose to use the name cubic spline or call it something else. No one who uses cubic spline interpolation in Graph can trust the outcome. It can give such crazy results that it is impossible to predict what it might do. That&#039;s why I offered my external interpolation utility. You must export data to it and then import the interpolated points, but at least it gives valid results. It would be so much easier if Graph would simply do it all internally. What would be so hard about that?</p><p>All you need to create a useful cubic spline interpolation is to use the code I sent you. It is standard code. I have used it for years in several different programs without any problems or weird results whatsoever. Call it spline1 and call the method you now use spline2. At least give users a choice.</p><p>I have no idea why you are unable to understand this issue. Just look at the examples I&#039;ve provided and use common sense.</p><p>Brian</p></blockquote></div><p>Brian, those exactly same 3 or&nbsp; points&nbsp; could have been from a different function, not sine function. Then what, would you expect that an interpolation method in one case will resemble to sine function, in other case--to another function??? Think about it! Interpolation methods are not intended to give the original function, but, as Ivan pointed, just to give a function that satisfies some smoothness conditions. That&#039;s all! Only in case you provide more and more points, the method will begin to give a graph close to the original particular function. <br />Read more about interp. on wiki...</p>]]></description>
			<author><![CDATA[null@example.com (victor)]]></author>
			<pubDate>Sun, 06 Mar 2011 11:34:49 +0000</pubDate>
			<guid>https://forum.padowan.dk/viewtopic.php?pid=807#p807</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cubic Spline Interpolation Bug]]></title>
			<link>https://forum.padowan.dk/viewtopic.php?pid=805#p805</link>
			<description><![CDATA[<p>I decided to simply implement clipping. The program lets you set lower and upper clipping thresholds. Interpolated points that fall beyond a threshold are set to the threshold value. This is simple, versatile, and easily understood.</p><p>I&#039;ve updated the program at the URL given earlier.</p><p>Adding normal cubic spline interpolation to Graph would allow users to plot coarsely or unevenly sampled data without generating funny curves. Adding optional clipping thresholds for all interpolation methods would permit it to generate realistic curves for data with natural saturation.</p><p>Brian</p>]]></description>
			<author><![CDATA[null@example.com (k6sti)]]></author>
			<pubDate>Sat, 05 Mar 2011 17:15:27 +0000</pubDate>
			<guid>https://forum.padowan.dk/viewtopic.php?pid=805#p805</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cubic Spline Interpolation Bug]]></title>
			<link>https://forum.padowan.dk/viewtopic.php?pid=803#p803</link>
			<description><![CDATA[<p>Ivan, I spent several hours yesterday going through my collection of dozens and dozens of Graph plots. I compared Graph&#039;s interpolation with a standard cubic spline. Graph&#039;s interpolation works more or less OK when there are lots of samples and when the spacing isn&#039;t too nonuniform. But when there are one or more samples with significantly different spacing, it can yield funny plots that are not representative of the underlying process being sampled. This behaviour is insidious, allowing bad data to pass for good.</p><p>I use Graph to draw plots of measured data from my electronics hobby. I take manual readings from lab instruments, both analog and digital, and then use Graph to plot the points. Due to time constraints, I can&#039;t always collect as many samples as I&#039;d like. Sometimes I sample outlier points just to complete a curve. I rely on smooth interpolation to fill in the missing data. The problem with Graph&#039;s interpolation is that you can&#039;t trust it to do a reasonable job of filling in missing points. It can generate funny curves that are nothing like the underlying process you&#039;ve measured. But ordinary cubic spline interpolation works in these cases.</p><p>If you want to keep the current Graph interpolation, I strongly recommend that you add standard cubic spline interpolation that a user can invoke when necessary. Users will have to determine for themselves when to use one interpolation or another, but at least they will have the option of plotting correct, valid curves.</p><p>Cubic spline interpolation smooths a curve by making certain assumptions about the first and second derivatives of the underlying function that the data represents. Sometimes real data does not conform to those assumptions. For example, some of the electrical signals I measure may saturate. The plotted curve suddenly becomes a constant value. The circuits are operating correctly but they exhibit discontinuous or nonsmooth derivatives. Any cubic spline interpolation may generate nonconstant interpolated values over a region of constant data due to the influence of adjacent regions. Usually the error is small, but the deviation of a nonflat curve can obscure the underlying saturation, which may be entirely normal. The user is left to explain the unexpected behavior exhibited by the plot. I have added an option to my cubic spline interpolator that enables it to preserve saturated data values. See the next message. If you implement a standard cubic spline interpolation, you might consider adding such a feature. It is not often needed, but it can make the interpolation model more realistic for some data.</p><p>Brian</p>]]></description>
			<author><![CDATA[null@example.com (k6sti)]]></author>
			<pubDate>Sat, 05 Mar 2011 12:32:12 +0000</pubDate>
			<guid>https://forum.padowan.dk/viewtopic.php?pid=803#p803</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cubic Spline Interpolation Bug]]></title>
			<link>https://forum.padowan.dk/viewtopic.php?pid=799#p799</link>
			<description><![CDATA[<p>Ivan, I just used a sine wave as an example. I am not creating a function. I am sampling a known function so that it is easy to tell whether the interpolation is reasonable. The defects I&#039;ve highlighted apply to any function or curve. They are not unique to sine waves. They apply also to measured data, as shown in my first example.</p><p>The interpolation method you are using does not yield curves that make sense, curves that are useful for obtaining accurate values between the points supplied, or curves that are mathematically correct. The method as implemented is entirely bogus. It is bizarre. It does not always yield single-valued functions. It bears no relation to a proper interpolation, whether you choose to use the name cubic spline or call it something else. No one who uses cubic spline interpolation in Graph can trust the outcome. It can give such crazy results that it is impossible to predict what it might do. That&#039;s why I offered my external interpolation utility. You must export data to it and then import the interpolated points, but at least it gives valid results. It would be so much easier if Graph would simply do it all internally. What would be so hard about that?</p><p>All you need to create a useful cubic spline interpolation is to use the code I sent you. It is standard code. I have used it for years in several different programs without any problems or weird results whatsoever. Call it spline1 and call the method you now use spline2. At least give users a choice.</p><p>I have no idea why you are unable to understand this issue. Just look at the examples I&#039;ve provided and use common sense.</p><p>Brian</p>]]></description>
			<author><![CDATA[null@example.com (k6sti)]]></author>
			<pubDate>Thu, 03 Mar 2011 21:41:42 +0000</pubDate>
			<guid>https://forum.padowan.dk/viewtopic.php?pid=799#p799</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cubic Spline Interpolation Bug]]></title>
			<link>https://forum.padowan.dk/viewtopic.php?pid=798#p798</link>
			<description><![CDATA[<p>It was never the intention to use point series to create sine waves. If you want a sine wave you should create it as a function. The cubic splines was intentioned to create a smooth line between the points as an alternative to linear interpolation. Maybe instead of calling it Linear, Cubic splines and Half cosine I should have called them Algorithm 1, Algorithm 2 and Algorithm 3, but that seemed a little silly.</p>]]></description>
			<author><![CDATA[null@example.com (Ivan Johansen)]]></author>
			<pubDate>Thu, 03 Mar 2011 20:40:52 +0000</pubDate>
			<guid>https://forum.padowan.dk/viewtopic.php?pid=798#p798</guid>
		</item>
	</channel>
</rss>
