CUQI-DTU / CUQIpy

https://cuqi-dtu.github.io/CUQIpy/
Apache License 2.0
42 stars 9 forks source link

Update advanced user guide to have information about defining user defined distribution #490

Open amal-ghamdi opened 2 weeks ago

amal-ghamdi commented 2 weeks ago

Description:

The user might need to define a distribution themselves. The first recommended approach is to use UserDefinedDsitribution and the second approach, for more control, is to subclass the Distribution class. We would like to communicate this information with the users

DoD:

Notes:

First approach: using the class UserDefinedDistribution See for example section 4 in https://cuqi-dtu.github.io/CUQI-Book/chapter0A/B01_Distributions.html , note that besides passing the logpdf_func, One can also pass a gradient function (gradient_func) and a sampling function (sample_func). See the UserDefinedDistribution documentation
https://cuqi-dtu.github.io/CUQIpy/api/_autosummary/cuqi.distribution/cuqi.distribution.UserDefinedDistribution.html#cuqi.distribution.UserDefinedDistribution

Second approach: Subclassing the Distribution class:

In the user showcase: https://github.com/CUQI-DTU/CUQIpy-User-Showcase/blob/main/007_smoothed_Laplace/smoothed_laplace.ipynb We define a class LaplaceSmoothed which is a subclass of Distribution class

In the user showcase: https://github.com/CUQI-DTU/CUQIpy-User-Showcase/tree/main/011_fusion_plasma_tomography There is a file custom_distribution.py in which we define a class MyDistribution subclassed from UserDefinedDistribution (ideally it should be subclassed from Distribution).

amal-ghamdi commented 2 weeks ago

fyi, @jakobsj, to capture what we discussed today