deepanshs / mrsimulator

A fast solid-state NMR spectrum simulation and analysis library.
https://mrsimulator.readthedocs.io
BSD 3-Clause "New" or "Revised" License
33 stars 13 forks source link

Add a linear interpolation scheme for probability distribution approximation #212

Open deepanshs opened 2 years ago

deepanshs commented 2 years ago

Linear interpolation scheme for gridding Czjzek/Extended Czjzek/User-defined distributions.

The current implementation of the probability distribution uses np.histogram2d function to grid 400000 samples (default) over a two-dimensional grid. The histogram function generates a discrete non-continuous distribution which is okay for one-time calculation but is not optimal when used iteratively in a least-squares problem.

Proposed Solution Use linear interpolation approximation to generate a smooth and continuous probability distribution.

mgiammar commented 1 year ago

Prototyping for a 2d interpolation scheme has been completed and applied towards least-squares minimization of Czjzek and Extended Czjzek models. Although 2d linear interpolation for random sampling on a grid does make a smoother distribution, the nature of random sampling (even with linear interpolation) makes the chi-squared surface non-analytical and discontinuous.

Regardless, it may be useful to include functions for two- and three-dimensional linear interpolation. @deepanshs I have code written to perform these functions, although it still needs further testing to ensure coverage. Other simulation features should be prioritized over this issue.