@Override
    protected float getAlpha(PredictionResult margin) {
      float m = margin.getScore();
      float var = margin.getVariance();

      float squared_phi = phi * phi;

      float n = var + c / 2.f;
      float v_phi_phi = var * squared_phi;
      float v_phi_phi_m = v_phi_phi * m;
      float term = v_phi_phi_m * m * var + 4.f * n * var * (n + v_phi_phi);
      float gamma = phi * (float) Math.sqrt(term);

      float alpha_numer = -(2.f * m * n + v_phi_phi_m) + gamma;
      if (alpha_numer <= 0.f) {
        return 0.f;
      }
      float alpha_denom = 2.f * (n * n + n * v_phi_phi);
      if (alpha_denom == 0.f) {
        return 0.f;
      }
      float alpha = alpha_numer / alpha_denom;

      return Math.max(0.f, alpha);
    }
    @Override
    protected float getAlpha(PredictionResult margin) {
      float m = margin.getScore();
      float var = margin.getVariance();

      float alpha_numer =
          -m * psi
              + (float)
                  Math.sqrt((m * m * squared_phi * squared_phi / 4.f) + (var * squared_phi * zeta));
      float alpha_denom = var * zeta;
      if (alpha_denom == 0.f) {
        return 0.f;
      }
      float alpha = alpha_numer / alpha_denom;

      if (alpha <= 0.f) {
        return 0.f;
      }

      return Math.max(c, alpha);
    }
    @Override
    protected float getBeta(PredictionResult margin, float alpha) {
      if (alpha == 0.f) {
        return 0.f;
      }
      float var = margin.getVariance();

      float beta_numer = alpha * phi;
      float var_alpha_phi = var * beta_numer;
      float u = -var_alpha_phi + (float) Math.sqrt(var_alpha_phi * var_alpha_phi + 4.f * var);
      float beta_den = u / 2.f + var_alpha_phi;
      if (beta_den == 0.f) {
        return 0.f;
      }

      float beta = beta_numer / beta_den;
      return beta;
    }
 protected float loss(PredictionResult margin, float y) {
   float var = margin.getVariance();
   float mean = margin.getScore();
   float loss = phi * (float) Math.sqrt(var) - (y * mean);
   return Math.max(loss, 0.f);
 }