MCPcopy Create free account
hub / github.com/EdwardRaff/JSAT / gammaP

Method gammaP

JSAT/src/jsat/math/SpecialMath.java:684–697  ·  view source on GitHub ↗

Returns the regularized gamma function P(a,z) = γ(a,z)/Γ(a). This method is more numerically stable and accurate than computing it via the direct method, and is always in the range [0,1]. Note: The this method returns Double#NaN for a<0, though real values of P(a,z) do exist

(double a, double z)

Source from the content-addressed store, hash-verified

682 * @return P(a,z)
683 */
684 public static double gammaP(double a, double z)
685 {
686 if(z<= 0 || a < 0)
687 return Double.NaN;
688
689 if(z < a+1)
690 return gammaPSeries(a, z);
691
692 /*
693 * This method is currently usntable for values of z that grow larger, so it is not currently in use
694 * return exp(a*log(z)-z-lnGamma(a))/gammaP.lentz(a,z);
695 */
696 return 1 - gammaQ(a, z);
697 }
698
699 /**
700 * Finds the value <tt>x</tt> such that {@link #gammaP(double,double) P(a,x)} = <tt>p</tt>.

Callers 3

invGammaPMethod · 0.95
cdfMethod · 0.80
cdfMethod · 0.80

Calls 2

gammaPSeriesMethod · 0.95
gammaQMethod · 0.95

Tested by

no test coverage detected