xinormal.c 763 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include <stdio.h>
  2. #include <math.h>
  3. double Cdhc_xinormal(double pee)
  4. {
  5. double f0, pind, pw, px;
  6. static double p[5] = { -0.322232431088, -1., -0.342242088547,
  7. -0.0204231210245, -4.53642210148e-5
  8. };
  9. static double q[5] = { 0.099348462606, 0.588581570495, 0.531103462366,
  10. 0.10353775285, 0.0038560700634
  11. };
  12. pind = pee;
  13. if (pee < 1e-10)
  14. return (double)-10.0;
  15. else if (pee >= 1.0)
  16. return (double)10.0;
  17. else if (pee == 0.5)
  18. return (double)0.5;
  19. /* else */
  20. if (pee > .5)
  21. pee--;
  22. pw = sqrt(log(1 / (pee * pee)));
  23. f0 = (((pw * q[4] + q[3]) * pw + q[2]) * pw + q[1]) * pw + q[0];
  24. px = pw + ((((pw * p[4] + p[3]) * pw + p[2])
  25. * pw + p[1]) * pw + p[0]) / f0;
  26. if (pind < .5)
  27. px = -px;
  28. return px;
  29. }