in reply to operate on an array created in a while loop

It would probably be a good idea to plot your results and then consider whether you are feeding the right data in and whether you've got that data in the right format, and whether you're using the right kind of interpolation for your task. The interpolation itself is almost certainly correct, and tweaking the values afterwards is never the right thing to do.

If the interpolation is quadratic or higher, then you will likely see some points in the interpolation that are higher than your maximum sample value.

Scaling the values down would make all the values (except zeroes) wrong in that case.

Consider this interpolation, where data points are the stars: __ __/ \__ _/ *_ _* \_ / \ / \ * *

Many of the interpolated points are much higher than the highest sample. As they should be.

If your data is noisy, then the interpolation may not actually pass through any of the points. But that's also OK.

* * * * * ---------------------- * * * * *

Replies are listed 'Best First'.
Re^2: operate on an array created in a subroutine
by captainentropy (Initiate) on Oct 15, 2013 at 23:04 UTC

    I must have posted the update while you were replying. In my OP I put a link to the output. The output curve is right, there's nothing like you're suggesting. I only need to the shape of the curve to be approximate (since I have no idea what it really should look like), and although the X-value at Y-max isn't exact in my output, it's close enough for what I need, but its height has to be exact.

      The Excel curve is based on three control points, the Math::Interpolate one is based on five controls.

      I presume that means the excel plot is using a quadratic interpolation (3 pts).

      If that's true, then you need to set M:I to use a quadratic interpolation as well if you want the results to match closely. Even then, using a different set of data (5 pts instead of 3) will ensure that your interpolation is slightly different.

      If you want it to be exact, you need to use the exact same input.

        Based on what I've read (and this isn't official from Microsoft) Excel uses Bezier interpolation to create smooth curves from three or more points. I played around with polynomials and it never looked right. Increasing the number of controls points generated larger polynomial equations and the curves didn't look like what I want. That's how I learned about Beziers and subsequently splines. I tried both of those modules, and now the Interpolate one. Here is an example of Spline vs. Interpolate. Also in this graph is the Interpolate with three control points. As you can see the three points makes just a parabola (p<0). https://www.dropbox.com/s/9cnl1jp9zzzhh19/Interpolate_example1.1.pdf

        So far only Math::Interpolate has given me a shape that is close enough to what I need with 5 points (three real points and two that are guesses). The problem is the height of each point. That has to be right. Hence the need to scale.

        Does this website ever post replies? I've replied to this a long time ago and it still isn't showing up.
Re^2: operate on an array created in a subroutine
by marinersk (Priest) on Oct 15, 2013 at 22:17 UTC
    <awestruck></awestruck>

    Dude, you are so getting one of my ++s tomorrow.

Re^2: operate on an array created in a subroutine
by captainentropy (Initiate) on Oct 15, 2013 at 23:08 UTC
    at least so far I haven't seen any weird output. I'll be on the lookout for sure.