package hex;

/**
 * Distribution functions to be used by ML Algos
 * Note: Not using interface or inheritance for performance reasons - let the user call these directly
 */
public class Distributions {

  public static class Gaussian {
    public static double deviance(double w, double y, double f) { return w*(y-f)*(y-f); }
    public static double gradient(double y, double f) { return y-invLink(f); }
    public static double invLink(double f) { return f; }
  }

  public static class Bernoulli {
    public static double deviance(double w, double y, double f) { return w*(y*f - Math.log(1+Math.exp(f))); }
    public static double gradient(double y, double f) { return y-invLink(f); }
    public static double invLink(double f) { return 1./(1.+Math.exp(-f)); }
  }

  public static class Poisson {
    public static double deviance(double w, double y, double f) { return w*(y*f - invLink(f)); }
    public static double gradient(double y, double f) { return y-invLink(f); }
    public static double invLink(double f) { return Math.max(1e-19,Math.min(1e19,Math.exp(f))); }
  }
}

@@ -662,39 +662,39 @@
 e f) %7B return y-
-invLink
+linkInv
 (f); %7D%0A    publi
@@ -701,39 +701,39 @@
 c static double 
-invLink
+linkInv
 (double f) %7B ret
@@ -755,24 +755,32 @@
 .exp(-f)); %7D
+ //logit
 %0A  %7D%0A%0A  publ
@@ -973,32 +973,32 @@
 y-invLink(f); %7D%0A
-
     public stati
@@ -1082,11 +1082,286 @@
 ); %7D%0A  %7D
+%0A%0A  public static class Gamma %7B%0A    public static double deviance(double w, double y, double f) %7B return w*(y*Math.exp(-f)+f); %7D%0A    public static double gradient(double y, double f) %7B return y*Math.exp(-f)-1; %7D%0A    public static double linkInv(double f) %7B return -1/f; %7D%0A  %7D
 %0A%7D%0A

Add Gamma distribution definition.