This is a README file for the data used in the publication "Minterpy: Multivariate interpolation in Python" submitted to the Journal of Open Source Software (JOSS). The paper contains one figure (two subplots) of convergence comparison between Minterpy and several selected packages.
The organization of the archive directory is as follows:
./
├── README.md <- This file
├── linf-errors <- Directory with convergence data of interpolating
| polynomials from different packages
├── plot <- Directory with script to create the convergence plot
| that appears in the paper; the same plot is also
| stored here
├── requirements <- Directory with package requirements for pip
└── scripts <- Directory with scripts to reproduce the results stored
in "linf-errors"
The numerical experiment is based on the
We consider two dimensions,
The experiment measures the difference between the function and its polynomial approximation
To evaluate this difference, we sample
For each approximation, we evaluate two key performance metrics:
- Computational cost: The number of function evaluations required to construct the approximation.
- Accuracy: The error between the original function and its approximation, measured using the infinity norm.
We compare the performance of five packages that construct polynomial-based function approximations:
Each package has a distinct setup, which is described below.
This section provides a detailed description of the experimental setup for each package, explains the available convergence results in the archive, and offers notes on reproducing these results.
The available results are stored in the directory linf-errors:
./linf-errors/
├── chaospy <- Convergence results from the Chaospy
├── equadratures <- Convergence results from equadratures
├── interpn <- Convergence results from interpn (SciPy)
├── minterpy <- Convergence results from Minterpy
└── ndsplines <- Convergence results from ndsplines
Each of these directories contains CSV files with two entries per row:
- Number of function evaluations: The number of function evaluations required to construct the approximation.
-
Infinity norm error: The accuracy of the approximation, measured in terms of the infinity norm, evaluated at
$1,000,000$ random points.
The scripts used to generate and reproduce these results can be found in the scripts/ directory.
Minterpy interpolating polynomials of increasing degrees
| No. | Dimension | p | n | Max. # Coeffs. |
|---|---|---|---|---|
| 1. | 3 | 1.0 | 0 - 100 | 176'851 |
| 2. | 3 | 2.0 | 0 - 70 | 185'366 |
| 3. | 3 | 0 - 55 | 175'616 | |
| 4. | 4 | 1.0 | 0 - 70 | 1'150'626 |
| 5. | 4 | 2.0 | 0 - 40 | 858'463 |
| 6. | 4 | 0 - 35 | 1'679'616 |
Note that for Minterpy, the size of the multi-index set corresponds directly to the number of coefficients and the number of function evaluations.
The convergence results for Minterpy are stored in the linf-errors/minterpy/ directory, relative to the archive source directory. This directory contains the following files, listed in the order corresponding to the setups in the table above:
errors-minterpy-dim_3-lp_1_0-nmin_0-nmax_100-runge_param_1_0.csverrors-minterpy-dim_3-lp_2_0-nmin_0-nmax_70-runge_param_1_0.csverrors-minterpy-dim_3-lp_inf-nmin_0-nmax_55-runge_param_1_0.csverrors-minterpy-dim_4-lp_1_0-nmin_0-nmax_75-runge_param_1_0.csverrors-minterpy-dim_4-lp_2_0-nmin_0-nmax_45-runge_param_1_0.csverrors-minterpy-dim_4-lp_inf-nmin_0-nmax_40-runge_param_1_0.csv
These files can be reproduced using the run_minterpy.py script stored in the scripts/ directory. The script can be used as follows:
$ python run_minterpy.py --help
Usage: run_minterpy.py [OPTIONS]
Run the interpolation experiment on the Runge function with Minterpy.
Options:
-m, --spatial-dimension INTEGER
The dimension of the function [required]
-nmin, --min-poly-degree INTEGER
Minimum polynomial degree [required]
-nmax, --max-poly-degree INTEGER
Maximum polynomial degree [required]
-p, --lp-degree FLOAT lp-degree of the polynomial [required]
-rp, --runge-parameter FLOAT Parameter of the Runge function [required]
-nb, --num-batches INTEGER Number of batches in the evaluation
[required]
--help Show this message and exit.
The commands used to produce each of the CSV files are:
python run_minterpy.py -m 3 -nmin 0 -nmax 100 -p 1.0 -rp 1.0 -nb 1000python run_minterpy.py -m 3 -nmin 0 -nmax 70 -p 2.0 -rp 1.0 -nb 1000python run_minterpy.py -m 3 -nmin 0 -nmax 55 -p inf -rp 1.0 -nb 1000python run_minterpy.py -m 4 -nmin 0 -nmax 75 -p 1.0 -rp 1.0 -nb 1000python run_minterpy.py -m 4 -nmin 0 -nmax 45 -p 2.0 -rp 1.0 -nb 1000python run_minterpy.py -m 4 -nmin 0 -nmax 40 -p inf -rp 1.0 -nb 1000
Function approximations via Legendre polynomial expansions in tensorial grid with increasing degree
| No. | Dimension | n | Max. # Coeffs. |
|---|---|---|---|
| 1. | 3 | 0 - 20 | 9'261 |
| 2. | 4 | 0 - 15 | 65'536 |
Note that for Chaospy, the number of coefficients corresponds directly to the number of function evaluations. However, it's worth noting that evaluating Chaospy polynomials can become unstable, particularly high degree as shown in the convergence plot.
The convergence results for equadratures are stored in the linf-errors/chaospy directory, relative to the archive source directory. This directory contains the following files, listed in the order corresponding to the setups in the table above:
errors-chaospy-dim_3-nmin_0-nmax_20-runge_param_1_0.csverrors-chaospy-dim_4-nmin_0-nmax_15-runge_param_1_0.csv
These files can be reproduced using the run_interpn.py script stored in the scripts/ directory. The script can be used as follows:
$ python run_chaospy.py --help
Usage: run_chaospy.py [OPTIONS]
Run the interpolation experiment on the Runge function with ChaosPy.
Options:
-m, --spatial-dimension INTEGER
The dimension of the function [required]
-nmin, --min-poly-degree INTEGER
Minimum polynomial degree [required]
-nmax, --max-poly-degree INTEGER
Maximum polynomial degree [required]
-rp, --runge-parameter FLOAT Parameter of the Runge function [required]
-nb, --num-batches INTEGER Number of batches in the evaluation
[required]
--help Show this message and exit.The commands used to produce each of the CSV files are:
python run_chaospy.py -m 3 -nmin 0 -nmax 20 -rp 1 -nb 1000python run_chaospy.py -m 4 -nmin 0 -nmax 15 -rp 1 -nb 1000
Function approximations via Legendre polynomial expansions in tensorial grid with increasing degree
| No. | Dimension | n | Max. # Coeffs. |
|---|---|---|---|
| 1. | 3 | 0 - 20 | 9'261 |
| 2. | 4 | 0 - 10 | 14'641 |
Note that for equadratures, the number of coefficients corresponds directly to the number of function evaluations. However, it's worth noting that equadratures can become computationally expensive, particularly in terms of memory consumption, for degrees beyond those specified above.
The convergence results for equadratures are stored in the linf-errors/equadratures directory, relative to the archive source directory. This directory contains the following files, listed in the order corresponding to the setups in the table above:
errors-equadratures-dim_3-nmin_0-nmax_20-runge_param_1_0.csverrors-equadratures-dim_4-nmin_0-nmax_10-runge_param_1_0.csv
These files can be reproduced in two steps using the scripts stored in the scripts/ directory:
- Constructing the equadrature approximation for the given dimension and degree using the
run_equadratures_fit.pyscript. - Computing the error in infinity norm given the approximation using the
run_equadratures_err.pyscript.
The run_equadratures_fit.py script can be used as follows:
$ python run_equadratures_fit.py --help
Usage: run_equadratures_fit.py [OPTIONS]
Construct a function approximation with equadratures.
Options:
-m, --spatial-dimension INTEGER
The dimension of the function [required]
-nmin, --min-poly-degree INTEGER
Minimum polynomial degree [required]
-nmax, --max-poly-degree INTEGER
Maximum polynomial degree [required]
-rp, --runge-parameter FLOAT Parameter of the Runge function [required]
--help Show this message and exit.To produce all the approximations from equadratures stored in pickled files (.pkl), run the script with the following parameters:
python run_equadratures_fit.py -m 3 -nmin 0 -nmax 20 -rp 1.0python run_equadratures_fit.py -m 4 -nmin 0 -nmax 10 -rp 1.0
The run_equadratures_err.py script can be used as follows:
$ python run_equadratures_err.py --help
Usage: run_equadratures_err.py [OPTIONS]
Compute the l-inf error given a polynomial from EQ.
Options:
-m, --spatial-dimension INTEGER
The dimension of the function [required]
-nmin, --min-poly-degree INTEGER
Minimum polynomial degree [required]
-nmax, --max-poly-degree INTEGER
Maximum polynomial degree [required]
-rp, --runge-parameter FLOAT Parameter of the Runge function [required]
-t, --target-directory TEXT Target directory where pkl files are located
[default: .]
--help Show this message and exit.Assuming that all pickled files are in the current working directory, run the script with the following parameters to produce the CSV files:
python run_equadratures_err.py -m 3 -nmin 0 -nmax 20 -rp 1.0python run_equadratures_err.py -m 4 -nmin 0 -nmax 10 -rp 1.0
Three different interpolation methods from the interpn module of SciPy are considered:
- Linear interpolation
- PCHIP (Piecewise cubic Hermite interpolating polynomial)
- Nearest interpolation
Note that other interpolation methods, such as splines, are also available in SciPy, but they are mostly identical to the more performant implementations in ndsplines.
The interpolation methods from interpn require data given in a rectangular grid. To construct this data, a tensor product of Chebyshev-Lobatto points is used in one dimension, with an increasing number of points
| No. | Dimension | Method | Max 1D points | Max. # Points. |
|---|---|---|---|---|
| 1. | 3 | linear | 100 | 1'000'000 |
| 2. | 3 | nearest | 100 | 1'000'000 |
| 3. | 3 | pchip | 100 | 1'000'000 |
| 4. | 4 | linear | 50 | 6'250'000 |
| 5. | 4 | nearest | 50 | 6'250'000 |
| 6. | 4 | pchip | 50 | 6'250'000 |
In contrast to Minterpy, Chaospy, or equadratures, the complexity of the interpolation method remains fixed, but the number of available interpolation points is increased.
The convergence results for Minterpy are stored in the linf-errors/interpn/ directory, relative to the archive source directory. This directory contains the following files, listed in the order corresponding to the setups in the table above:
errors-interpn-dim_3-linear-max_1d_100-runge_param_1_0.csverrors-interpn-dim_3-nearest-max_1d_100-runge_param_1_0.csverrors-interpn-dim_3-pchip-max_1d_100-runge_param_1_0.csverrors-interpn-dim_4-linear-max_1d_50-runge_param_1_0.csverrors-interpn-dim_4-nearest-max_1d_50-runge_param_1_0.csverrors-interpn-dim_4-pchip-max_1d_50-runge_param_1_0.csv
These files can be reproduced using the run_interpn.py script stored in the scripts/ directory. The script can be used as follows:
$ python run_interpn.py --help
Usage: run_interpn.py [OPTIONS]
Run the interpolation experiment on the Runge function w/ interpn.
Options:
-m, --spatial-dimension INTEGER
The dimension of the function [required]
-mt, --method [linear|slinear|cubic|quintic|pchip|nearest]
Interpolation method [required]
-p, --max-1d-points INTEGER Maximum number of one-dimensional points
[required]
-rp, --runge-parameter FLOAT Parameter of the Runge function [required]
--help Show this message and exit.The commands used to produce each of the CSV files are:
python run_interpn.py -m 3 -mt linear -p 100 -rp 1.0python run_interpn.py -m 3 -mt nearest -p 100 -rp 1.0python run_interpn.py -m 3 -mt pchip -p 100 -rp 1.0python run_interpn.py -m 4 -mt linear -p 50 -rp 1.0python run_interpn.py -m 4 -mt nearest -p 50 -rp 1.0python run_interpn.py -m 4 -mt pchip -p 50 -rp 1.0
The script plot/create_plot.py generates the convergence plot presented in the paper. It assumes that all result files are located in the linf-errors/ directory, as described above.
The generated plot, convergence.png, which appears in the paper, is also stored in the same directory.
The numerical experiments were conducted on a machine running Debian 12 Linux, equipped with a 32-core AMD EPYC processor and 256 GB of RAM. The experiments used Python v3.9.19 and relied on the following Python libraries and packages:
numpy==2.0.2scipy==1.13.1matplotlib==3.9.2minterpy==0.3.0numba==0.6.0chaospy==4.3.18numpoly==1.3.6equadratures==10(incompatible with NumPyv2.x; revert tov1.26.4)ndsplines==0.2.0post0click==8.1.7tqdm==4.66.5
The corresponding requirement files are located in the requirements/ directory, relative to the root of the archive. Due to the incompatibility between equadratures v10 (latest) and NumPy v2.x, alternative requirements are specified in requirements-equadratures.txt for experiments involving equadratures.