• Stars
    star
    475
  • Rank 89,573 (Top 2 %)
  • Language
    Julia
  • License
    Other
  • Created almost 10 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Fast, continuous interpolation of discrete datasets in Julia

Interpolations.jl

version pkgeval Build Status deps Stable Latest

This package implements a variety of interpolation schemes for the Julia language. It has the goals of ease-of-use, broad algorithmic support, and exceptional performance.

Currently this package supports B-splines and also irregular grids. The API has been designed with intent to support more options. Initial support for Lanczos interpolation was recently added. Pull-requests are more than welcome! It should be noted that the API may continue to evolve over time.

At the bottom of this page, you can find a "performance shootout" among these methods (as well as SciPy's RegularGridInterpolator).

Installation

Interpolations.jl can be installed via the following invocation since it is a registered Julia package.

using Pkg
Pkg.add("Interpolations")

Example Usage

Create a grid xs and an array A of values to be interpolated

xs = 1:0.2:5
A = log.(xs)

Create linear interpolation object without extrapolation

interp_linear = linear_interpolation(xs, A)
interp_linear(3) # exactly log(3)
interp_linear(3.1) # approximately log(3.1)
interp_linear(0.9) # outside grid: error

Create linear interpolation object with extrapolation

interp_linear_extrap = linear_interpolation(xs, A,extrapolation_bc=Line()) 
interp_linear_extrap(0.9) # outside grid: linear extrapolation

Other Examples

More examples, such as plotting and cubic interpolation, can be found at the convenience constructions documentation.

interpolation plot example

Other Interpolation Packages

Other interpolation packages for Julia include:

  • ApproXD.jl implements B-spline and linear interpolation in Julia.
  • BarycentricInterpolation.jl implements the Barycentric formula for polynomial interpolation on equispaced points and Chebyshev points of the first and second kind.
  • BasicInterpolators.jl provides a collection of common interpolation recipes for basic applications.
  • BSplineKit.jl offers tools for B-spline based Galerkin and collocation methods, including for interpolation and approximation.
  • Curves.jl supports log-interpolation via immutable Curve objects.
  • DataInterpolations.jl is a library for performing interpolations of one-dimensional data.
  • Dierckx.jl is a wrapper for the dierckx Fortran library, which also underlies scipy.interpolate.
  • DIVAnd.jl for N-dimensional smoothing interpolation.
  • FastChebInterp.jl does fast multidimensional Chebyshev interpolation on a hypercube using separable grid of interpolation points.
  • FEMBasis.jl contains interpolation routines for standard finite element function spaces.
  • FineShift.jl does fast sub-sample shifting of multidimensional arrays.
  • FourierTools.jl includes sinc interpolation for up and down sampling.
  • GridInterpolations.jl performs multivariate interpolation on a rectilinear grid.
  • InterpolationKernels.jl provides a library of interpolation kernels.
  • KissSmoothing.jl implements denoising and a Radial Basis Function estimation procedure.
  • LinearInterpolations.jl allows for interpolation using weighted averages allowing probability distributions, rotations, and other Lie groups to be interpolated.
  • LinearInterpolators.jl provides linear interpolation methods for Julia based on InterpolationKernels.jl, above.
  • LocalFunctionApproximation.jl provides local function approximators that interpolates a scalar-valued function across a vector space.
  • PCHIPInterpolation.jl for monotonic interpolation.
  • PiecewiseLinearApprox.jl performs piecewise linear interpolation over an arbitrary number of dimensions.
  • ScatteredInterpolation.jl interpolates scattered data in arbitrary dimensions.

Some of these packages support methods that Interpolations does not, so if you can't find what you need here, check one of them or submit a pull request here.

If you would like to list a registered package that is related to interpolation, please create a Github issue.

Performance shootout

In the perf directory, you can find a script that tests interpolation with several different packages. We consider interpolation in 1, 2, 3, and 4 dimensions, with orders 0 (Constant), 1 (Linear), and 2 (Quadratic). Methods include Interpolations BSpline (IBSpline) and Gridded (IGridded), methods from the Grid.jl package, methods from the Dierckx.jl package, methods from the GridInterpolations.jl package (GI), methods from the ApproXD.jl package, and methods from SciPy's RegularGridInterpolator accessed via PyCall (Py). All methods are tested using an Array with approximately 10^6 elements, and the interpolation task is simply to visit each grid point.

First, let's look at the two B-spline algorithms, IBspline and Grid. Here's a plot of the "construction time," the amount of time it takes to initialize an interpolation object (smaller is better):

construction

The construction time is negligible until you get to second order (quadratic); that's because quadratic is the lowest order requiring the solution of tridiagonal systems upon construction. The solvers used by Interpolations are much faster than the approach taken in Grid.

Now let's examine the interpolation performance. Here we'll measure "throughput", the number of interpolations performed per second (larger is better):

throughput

Once again, Interpolations wins on every test, by a factor that ranges from 7 to 13.

Now let's look at the "gridded" methods that allow irregular spacing along each axis. For some of these, we compare interpolation performance in both "vectorized" form itp[xvector, yvector] and in "scalar" form for y in yvector, x in xvector; val = itp[x,y]; end.

First, construction time (smaller is better):

construction

Missing dots indicate cases that were not tested, or not supported by the package. (For construction, differences between "vec" and "scalar" are just noise, since no interpolation is performed during construction.) The only package that takes appreciable construction time is Dierckx.

And here's "throughput" (larger is better). To ensure we can see the wide range of scales, here we use "square-root" scaling of the y-axis:

throughput

For 1d, the "Dierckx scalar" and "GI" tests were interrupted because they ran more than 20 seconds (far longer than any other test). Both performed much better in 2d, interestingly. You can see that Interpolations wins in every case, sometimes by a very large margin.

Development Status

This package is being maintained but not actively developed. Maintenance is focused on fixing bugs and issues with the current code base. New features are welcome via pull requests and will be reviewed and released in a timely fashion.

If you would like to become involved in maintenance or active development of the package please feel free to get in touch via a Github issue.

This package follows semantic version in that documented features should not break without changing the minor version.

See the news for details on how to update between breaking releases, indicated by changes in minor versions.

Contributing

Work is very much in progress, but help is always welcome. If you want to help out but don't know where to start, take a look at issue #5 - our feature wishlist =) There is also some developer documentation that may help you understand how things work internally.

Contributions in any form are appreciated, but the best pull requests come with tests!

More Repositories

1

openlibm

High quality system independent, portable, open source libm implementation
C
468
star
2

MeasureTheory.jl

"Distributions" that might not add to one.
Julia
382
star
3

SpecialFunctions.jl

Special mathematical functions in Julia
Julia
317
star
4

Roots.jl

Root finding functions for Julia
Julia
299
star
5

Polynomials.jl

Polynomial manipulations in Julia
Julia
291
star
6

Calculus.jl

Calculus functions in Julia
Julia
270
star
7

FFTW.jl

Julia bindings to the FFTW library for fast Fourier transforms
Julia
258
star
8

QuadGK.jl

adaptive 1d numerical Gauss–Kronrod integration in Julia
Julia
246
star
9

Combinatorics.jl

A combinatorics library for Julia
Julia
205
star
10

HCubature.jl

pure-Julia multidimensional h-adaptive integration
Julia
143
star
11

NFFT.jl

Julia implementation of the Non-equidistant Fast Fourier Transform (NFFT)
Julia
136
star
12

DoubleFloats.jl

math with more good bits
Julia
130
star
13

Cubature.jl

One- and multi-dimensional adaptive integration routines for the Julia language
Julia
117
star
14

AbstractFFTs.jl

A Julia framework for implementing FFTs
Julia
116
star
15

GSL.jl

Julia interface to the GNU Scientific Library (GSL)
Julia
98
star
16

IntervalSets.jl

Interval Sets for Julia
Julia
93
star
17

Primes.jl

Prime numbers in Julia
Julia
87
star
18

RandomMatrices.jl

Random matrices package for Julia
Julia
77
star
19

Bessels.jl

Bessel functions for real arguments and orders
Julia
76
star
20

Sobol.jl

generation of Sobol low-discrepancy sequence (LDS) for the Julia language
Julia
74
star
21

FixedPointNumbers.jl

fixed point types for julia
Julia
73
star
22

IntelVectorMath.jl

Julia bindings for the Intel Vector Math Library
Julia
68
star
23

HypergeometricFunctions.jl

A Julia package for calculating hypergeometric functions
Julia
66
star
24

AccurateArithmetic.jl

Calculate with error-free, faithful, and compensated transforms and extended significands.
Julia
64
star
25

Richardson.jl

Richardson extrapolation in Julia
Julia
59
star
26

DecFP.jl

Julia IEEE decimal floating-point via the Intel decimal-float library
Julia
55
star
27

Yeppp.jl

Yeppp! bindings
Julia
54
star
28

FastChebInterp.jl

fast multidimensional Chebyshev interpolation and regression in Julia
Julia
53
star
29

NaNMath.jl

Julia math built-ins which return NaN and accumulator functions which ignore NaN
Julia
52
star
30

Decimals.jl

Pure Julia decimal arithmetic library.
Julia
52
star
31

BFloat16s.jl

Nobody needed all those bits anyway
Julia
41
star
32

FastPow.jl

optimal addition-chain exponentiation for Julia
Julia
41
star
33

Tau.jl

A Julia module providing the definition of the circle constant Tau (2Ï€)
Julia
36
star
34

Quadmath.jl

Float128 and libquadmath for the Julia language
Julia
35
star
35

Hadamard.jl

Fast Walsh-Hadamard transforms for the Julia language
Julia
35
star
36

openspecfun

A collection of special mathematical functions
Fortran
33
star
37

ChangePrecision.jl

macro to change the default floating-point precision in Julia code
Julia
33
star
38

FixedPointDecimals.jl

Julia fixed-point decimals built from integers
Julia
30
star
39

InverseLaplace.jl

Inverse Laplace transform
Julia
30
star
40

InverseFunctions.jl

Interface for function inversion in Julia
Julia
25
star
41

MeasureBase.jl

Julia
25
star
42

DoubleDouble.jl

Extended precision arithmetic for Julia (deprecated)
Julia
24
star
43

Libm.jl

A pure Julia math library
Julia
23
star
44

TensorCore.jl

Lightweight package for sharing tensor-algebra definitions
Julia
23
star
45

LambertW.jl

Lambert W mathematical function
Julia
21
star
46

KahanSummation.jl

Sum and cumulative sum using the Kahan-Babuska-Neumaier algorithm
Julia
19
star
47

Float8s.jl

A number format that you can count with your fingers.
Julia
17
star
48

Infinities.jl

A Julia package for representing infinity in all its forms
Julia
17
star
49

Xsum.jl

exactly rounded double-precision summation for Julia
Julia
15
star
50

IrrationalConstants.jl

defines additional irrationals
Julia
15
star
51

FunctionAccuracyTests.jl

ULP testing for Floating Point special functions.
Julia
13
star
52

DensityInterface.jl

Interface for mathematical/statistical densities in Julia
Julia
11
star
53

CheckedArithmetic.jl

Utilities for handling arithmetic overflow
Julia
10
star
54

RoundingIntegers.jl

Integer types that automatically round assigned values
Julia
10
star
55

ChangesOfVariables.jl

Interface for transformation functions in Julia
Julia
10
star
56

IntegerMathUtils.jl

Julia
6
star
57

MittagLeffler.jl

Mittag-Leffler function
Julia
6
star
58

ILog2.jl

integer valued base 2 logarithm
Julia
5
star
59

FunctionZeros.jl

Zeros of Bessel J and Y functions
Julia
4
star
60

RealDot.jl

Compute `real(dot(x, y))` efficiently.
Julia
4
star
61

FFTWBuilder

binary builder for FFTW.jl package
Julia
2
star
62

OpenlibmBuilder

Julia
2
star
63

Roadmap.jl

1
star
64

OpenspecfunBuilder

Julia
1
star
65

DSFMTBuilder

Julia
1
star
66

MPFRBuilder

Julia
1
star
67

GMPBuilder

Julia
1
star