Makima

 Mathworks have developed a variation of Akima's Method, called Makima, which addresses the issues with the original Akima Method that were explained in the previous post 'Understanding Akima'.  The method is described in a blogpost on the Mathworks website, written by Cosmin Ionita.  See:

https://blogs.mathworks.com/cleve/2019/04/29/makima-piecewise-cubic-interpolation/

The modification adds stabilising terms to the weights in the original Akima Method.  It is not explained how these terms were chosen, but they certainly seem to work - so let's explore them.  For simplicity of notation, we shall again just look at a set of five points, x1 to x5, and consider the estimation of the slope at x3 - using the notation of the previous post 'Understanding Akima'.  The terms a1 and a2 are revised as follows:

a1 = abs(m4 - m3) + 0.5*abs(m4 + m3)

a2 = abs(m2 - m1) + 0.5*abs(m2 + m1)

Then as before, b = a1 + a2, and w1 = a1/b and w2 = a2/b.  This gives the weighted average estimate: 

s3 = w1 * m2 + w2 * m3        (1)

Notice that b is only zero now if all of m1, m2, m3, m4 are zero. In that case, the averaging formula is chosen.

If we run Makima on the dataset of the previous post, we get the following (adding a legend so we can keep track!).  Notice the slope estimate at x=5 is now zero, eliminating the overshoot from the Akima averaging formula.


Suppose we now add a perturbation at x=6, as we did when investigating the instability of Akima in the previous post.  As expected, the Makima method is stable.

Moreover, empirically, other perturbations produce the same stable result.

To understand this better, we can do the same five-point analysis that we did for Akima in the previous post.  Assume as before for simplicity all slopes are positive, and let m4 = m3 = p, and m2 = m1 = q.   Then

- a1 = p, a2 = q

- b = p + q

- w1 = p/(p+q), w2 = q/(p+q)

Thus: s3 = pq / (p+q) + qp / (p+q) = 2pq / (p+q)

which is none other than the harmonic mean of p and q!   This contrasts with Akima which uses the arithmetic mean of p and q!  We can also see immediately that if either p or q is zero, then s3 is zero - which explains the behaviour in the plot above.

Now the question is whether the slope calculation is stable if a perturbation is made.  As before, suppose we add eps to y4.  Then, 

- m4 = p - eps; m3 = p + eps

- a1 = abs(m4 - m3) + 0.5 * abs (m4 + m3) = 2*eps + p

- a2 = q

- b = p + q + 2*eps

- w1 = a1 / b = (2*eps + p) / (p + q + 2*eps)

- w2 = q / (p + q + 2*eps)

- s3 = w1 * q + w2 * p = ((2*eps + p) * q + q*p)) / (p + q + 2*eps) = (2 * (p*q + eps))/(p + q + 2*eps)

So, for small eps, s3 is approximately equal to 2*p*q / (p+q) - ie a small change to y4 results in a small change to s3.


Note that for these plots we save the PDF as 5.36x5.89 portrait style, and edit the width and height of the inserted iframe to be 536x589.


Notes for future study. Should we take relative spacing of data points into consideration?  Also, why does the new formula come from?

{Bica (Optimizing at the end points the Akima's interpolation method for smooth curve fitting, CAGD, Vol 31, 2014) suggests a more careful treatment of the end-point conditions.  Again, needs a separate post.}


x3 y3 m2 s3 w2 a2

Comments

Popular posts from this blog

Piecewise Linear Interpolation of Cubic Polynomial

Wiggins Methods

Curve Drawing Over the Years