I am implementing some preprocessing of variables in the context of a paper called A Neural Bayesian Estimator for Conditional Probability Densities.
It states: 1.) Given a non-linear, a monotonous variable transformation F:t->s such that s is distributed uniformly is applied. This can be achieved as mentioned in the paper by:
>>> sorting the target vector in ascending order
>>> fitting the spline to data, e.g. using interpolate from scipy
2.) Afterwards s is scaled to lie between -1 and 1. This can be achieved with interp
:
>>> from numpy import interp
>>> interp(256,[1,512],[5,10])
3.) Finally, the flat distributions need to be converted into Gaussian distributions, centered at zero with std 1.
While the first two steps are clear on how to implement, I am struggling with the third one.
Regarding 3.), the author further states that the inverse of the integrated X^2 (X...chi) function may be used. Are there any libraries, preferably Python, suitable for this job?
Update 1:
After reading the paper again, it seems that X^2 doesn't directly relate to chi, but is rather calculated as follows:
X^2 = P*(1-o)^2+(1-P)*((-1)-o)^2
with P
as the purity (can be computed easily given some variable) and o
the variable itself.
For a given s scaled to lie between -1 and 1, I may just calculated the integral with lower bound=-1 and upper bound=s and then getting the inverse of it.
Question: How to do this numerically?