ism3d.maths.stats.custom_ppf¶
-
ism3d.maths.stats.
custom_ppf
(func, q, sersic_n=1)[source]¶ * we also wrap the random generator into rv_continous class * *** but this inline function may have better performance without the error checking overhead in rv_continous class
To build a fast persodu-random genenrator for an analytical function, the key is calculate the inverse cumlutative diftributon function or Percent Point Function (PPF) in high precisiom: This is the parameter reliazation values as a function of CDF (Percent point function):
Sometimes this function will have an analytical form, which will be good in terms of performance and precision.
should support vector Although this is 1D, any fancy function can be further manupilated
https://reference.wolfram.com/language/ref/InverseCDF.html
calculate ppf from percent cutoff for common (regularized/normalized) PDF this can be used for inverse transform sampling
If “u” is an uniform random number from (0,1), then the output would be a sample following the desired distribution *
see also the appendix Xue+2020
see also: inverseCDF.nb in MM12
If “-ss” is in the function name, we will use scipy.stats build-in RV class
typicall using scipy.special will be faster
to use this function as inverse survive function (ISF) try:
sp=1-q x=custom_ppf(func,sp)
sersic_n only works for func=”sersic2d”
- The interpolation sample should stay in:
x <-> SF or x <->log(SF) space
As it’s difficult to keep the numerical accuracy and x <-> CDF for large x + close to one CDF table : when you set up a x grid, for large x, the corrspoding CDF will one due to numerical precision