title: How to implement the inverse of the integrated Chi^2 function?
body: <p>I am implementing some preprocessing of variables in the context of a paper called <a href="https://arxiv.org/abs/physics/0402093" rel="nofollow">A Neural Bayesian Estimator for Conditional Probability Densities</a>.</p>
  
  <p>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:</p>
  
  <pre><code>&gt;&gt;&gt; sorting the target vector in ascending order
  &gt;&gt;&gt; fitting the spline to data, e.g. using interpolate from scipy
  </code></pre>
  
  <p>2.) Afterwards s is scaled to lie between -1 and 1. This can be achieved with <code>interp</code>:</p>
  
  <pre><code>&gt;&gt;&gt; from numpy import interp
  &gt;&gt;&gt; interp(256,[1,512],[5,10])
  </code></pre>
  
  <p>3.) Finally, the flat distributions need to be converted into Gaussian distributions, centered at zero with std 1. </p>
  
  <p>While the first two steps are clear on how to implement, I am struggling with the third one.</p>
  
  <p>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?</p>
  
  <p><strong>Update 1:</strong></p>
  
  <p>After reading the paper again, it seems that X^2 doesn't directly relate to chi, but is rather calculated as follows:</p>
  
  <p>X^2 = P*(1-o)^2+(1-P)*((-1)-o)^2</p>
  
  <p>with <code>P</code> as the purity (can be computed easily given some variable) and <code>o</code> the variable itself.</p>
  
  <p>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.</p>
  
  <p>Question: How to do this numerically?</p>