regularizeNd

Create a gridded lookup table of scattered data in n dimensions.

1.2K Downloads

Updated 23 Feb 2021

View License

regularizeNd Fits a nD lookup table with smoothness to scattered data. Constraints are possible.
regularizeNd answers the question what is the best possible lookup table that the scattered data input x and output y in the least squares sense with smoothing? regularizeNd is meant to calculate a smooth lookup table given n-D scattered data. regularizeNd supports extrapolation from a scattered data set.
The calculated lookup table, yGrid, is meant to be used with griddedInterpolant class with the conservative memory form. Call griddedInterpolant like

xGrid = cell array of grid vectors
smoothness = smoothness value or vector
yGrid = regularizeNd(xData, yData, xGrid, smoothness);
F = griddedInterpolant(xGrid, yGrid).

Desirable properties of regularizeNd:
-Calculates a relationship between the input x and the output y without definition of the functional form of x to y.
-Often the fit is superior to polynomial type fitting without the wiggles.
-Extrapolation is possible from a scattered data set.
-After creating the lookup table yGrid and using it with griddedInterpolant, as the query point moves away from the scattered data, the relationship between the input x and output y becomes more linear because of the smoothness equations and no nearby fidelity equations. The linear relationship is a good choice when the relationship between x and y is unknown in extrapolation.
-regularizeNd can handle 1D, 2D, nD input data to 1D output data. RegularizeData3D and gridfit can only handle 2D input and 1D out (total 3D).
-regularizeNd can handle setting the smoothness to 0 in any/some axis/dimension. This means no smoothing is applied in a particular axis/dimension and the data is just a least squares fit of a lookup table in that axis/dimension. Note this is not recommended and often can lead to an ill-conditioned fitting problem. However, I have found it useful so I left this as an option.
- Constraints are possible with the function regularizeNdMatrices. See the example.

The source code is locate here:
https://github.com/jasonnicholson/regularizeNd

For an introduction on how regularization of a lookup table works, start here: https://mathformeremortals.wordpress.com/2013/01/29/introduction-to-regularizing-with-2d-data-part-1-of-3/

Acknowledgement
Special thanks to Peter Goldstein, author of RegularizeData3D, for his coaching and help through writing regularizeNd.

Cite As

Jason Nicholson (2023). regularizeNd (https://www.mathworks.com/matlabcentral/fileexchange/61436-regularizend), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2020a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired by: Surface Fitting using gridfit, RegularizeData3D

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
2.4.0

Added a function to auto-generate monotonic constraints, monotonicConstraint.m. It should help problem setup creating constraint matrices.

2.3.1

Added readme's for a simple explanation.
Added live script documentation so that it shows up on the file exchange.

2.3.0

Updated examples.
Removed histc and replaced it with histcount.

2.2.5

Added better documentation of lsqConstrainedAlternative. The documentation is integrated into the MATLAB help system.

2.2.2

Updated direct vs. iterative solver example.

2.2.1

Fixed a problem with one of the examples.

2.2.0

The documentation loads into MATLAB builtin documentation under Supplemental Software. Attached is a toolbox file.

2.1.2

Added a basic getting started file.

2.1.1

Fixed an issue with a missing graph in the documentation.

2.1

Had to convert all the documentation and examples to live scripts because File Exchange wasn't displaying the published m files. UGH!

2.0

- Added constraints and documentation. This is a major change. The new function is regularizeNdMatrices. See the examples for more information.
- Added the linear least squares constrained solver lsqConstrainedAlternative.

1.8.0.0

Just renaming the project dropping jasonhnicholson/
Added iterative solvers, corresponding documentation, and an iterative example.
updating description

1.7.0.0

Added a 1D example.
Just some formatting changes to the description.
Fixed a figure for example1D that didn't display well on the web.

1.6.0.0

Fixed a spelling mistake in the gridfit examples.
Added a 4D input and 1D output example.
For some reason the description was lost on the last update. I had to redo it. Ugh.
Some formatting was messed up on the gridfit example. I had to republish.

1.5.0.0

More updates to the examples.
more updates to examples.
Made some fixes to the formatted documentation.
More updates to examples.
More example updates.

1.4.0.0

-Added several examples.
-Added formatted documentation.

1.3.0.0

Added support for cubic interpolation. This is a major step. All of the interpolation methods that I intended to use are implemented.
Small update to the function description.

1.2.0.0

Updating the description.
-Fixed two issues with the internal documentation and example.
-Updated the description with a little more information.
Added a note about ndgrid format of yGrid. yGrid is in the ndgrid format at not the meshgrid format. There is no analogue of the meshgrid format for higher dimensions. In 2d, ndgrid is the transpose of the meshgrid format.
Description formatting.

1.1.0.0

Fixed a bug I introduced in the last week.

1.0.0.0

I just uploaded the single m file instead of attaching the repository like when it is connected to github.
Updated the description fixing some grammar errors.
Added a picture.
Grammar fix to description.
Minor update to the link in the description.