question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[feature request] fast interpolation in uniformly-spaced data

See original GitHub issue

When working with uniformly-spaced data, it is possible to skip the initial search operation that an interpolation algorithm would ordinarily have to perform. This tends to speed things up significantly. It would be nice to have some specialized interpolators in SciPy that do linear interpolation and spline interpolation on uniformly-spaced data. The following sample code does linear interpolation without search:

   # Interpolate linearly, taking advantage of the fact that
   # the values in `f` are uniformly spaced.

   quo, rem= np.divmod(x, step)
   fraction= rem / step

   # Although the quotient values returned by `numpy.divmod` are integers, the
   # array dtype is 'f4'.  ==> We must force the dtype to 'i4' so that the
   # quotient values can be used for indexing:
   quo= quo.astype('i4')

   result= fraction * r[quo+1] + (1-fraction) * r[quo]

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:16 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
Phillip-M-Feldmancommented, Jun 4, 2019

In all of my use cases, I define the interpolating function and then apply it exactly once, so it would be helpful if there were a way to pass a flag that says, “The caller promises that the independent variable is uniformly spaced.”

On Mon, Jun 3, 2019 at 9:38 PM Huize Wang notifications@github.com wrote:

@MatthewFlamm https://github.com/MatthewFlamm Thanks! I agree that comprehensive timing is needed.

In terms of time complexity analysis, searchsorted should be O(logn) while search in uniform grid should be O(1), for 1-D case. A “uniformity check” is O(n) and I believe it should be run only once, during the interpolation class object initialization.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/scipy/scipy/issues/10180?email_source=notifications&email_token=AAIEDRHKEEJI446XTIIBRLLPYXWTJA5CNFSM4HM5PRZ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODW3MPPI#issuecomment-498517949, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIEDRDESXD6NA22NLB5RQDPYXWTJANCNFSM4HM5PRZQ .

1reaction
Phillip-M-Feldmancommented, May 15, 2019

Over the last 40 years, most of the data with which I’ve worked has been uniformly spaced in the independent variables. So, I’m inclined to think that this case is not that specialized.

On Wed, May 15, 2019 at 12:33 AM Evgeni Burovski notifications@github.com wrote:

This feels best suited for specialized user code IMO.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/scipy/scipy/issues/10180?email_source=notifications&email_token=AAIEDRDQBHEZ7A4Q2BIC2VLPVO4DXA5CNFSM4HM5PRZ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVNY3KI#issuecomment-492539305, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIEDRBSKPOESTTELSGTFUTPVO4DXANCNFSM4HM5PRZQ .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fast Linear Interpolation - ACM Digital Library
We present fast implementations of linear interpolation operators for piecewise linear functions and multi-dimensional look-up tables.
Read more >
Interpolation and Smoothing - Maple Help - Maplesoft
The x-data points are taken uniformly in the range, as the integers from 1 to 15. But they could just as well be...
Read more >
What is interpolate and pre-averaging | Igor Pro by WaveMetrics
When you have this evenly spaced data set, you can continue with only the yi wave and set its scaling to start at...
Read more >
A Fast Global Interpolation Method for Digital Terrain Model ...
One promising feature of LiDAR point clouds is the high-density with a large amount of data points. However, this imposes a great challenge...
Read more >
FAST LINEAR INTERPOLATION FOR PIECEWISE-LINEAR ...
We present fast implementations of linear interpolation operators for piecewise ... uniformly-spaced LUTs to better cover irregular keypoints.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found