Computes the second derivative of the logistic loss

@param pred the predicted value
@param y the true value
@return the second derivative of the logistic loss
769009
public static double deriv2(double pred, double y)
    {
        final double x = y * pred;
        if (x >= 30)
            return 0;
        else if (x <= -30)
            return 0;

        final double p = 1 / (1 + exp(y * pred));

        return p * (1 - p);
    }
190790
@Pure
	public double doc2fxY(double y) {
		return this.centeringTransform.toCenterY(y) * this.scale.get() + this.canvasHeight.get() / 2.;
	}
532680
public double Function2D(double x, double y) {
        return Math.exp(-(x * x + y * y) / (2 * sqrSigma)) / (2 * Math.PI * sqrSigma);
    }
654827
public static double QuasiEuclidean(double x1, double y1, double x2, double y2) {

        if (Math.abs(x1 - x2) > Math.abs(y1 - y2)) {
            return Math.abs(x1 - x2) + (Constants.Sqrt2 - 1) * Math.abs(y1 - y2);
        }
        return (Constants.Sqrt2 - 1) * Math.abs(x1 - x2) + Math.abs(y1 - y2);

    }
726052
public double gradient(double[] expected)
    {
        if (x_.isEmpty())
        {
            return 0.0;
        }
        buildLattice();
        forwardbackward();
        double s = 0.0;

        for (int i = 0; i < x_.size(); i++)
        {
            for (int j = 0; j < ysize_; j++)
            {
                node_.get(i).get(j).calcExpectation(expected, Z_, ysize_);
            }
        }
        for (int i = 0; i < x_.size(); i++)
        {
            List<Integer> fvector = node_.get(i).get(answer_.get(i)).fVector;
            for (int j = 0; fvector.get(j) != -1; j++)
            {
                int idx = fvector.get(j) + answer_.get(i);
                expected[idx]--;
            }
            s += node_.get(i).get(answer_.get(i)).cost; //UNIGRAM COST
            List<Path> lpath = node_.get(i).get(answer_.get(i)).lpath;
            for (Path p : lpath)
            {
                if (p.lnode.y == answer_.get(p.lnode.x))
                {
                    for (int k = 0; p.fvector.get(k) != -1; k++)
                    {
                        int idx = p.fvector.get(k) + p.lnode.y * ysize_ + p.rnode.y;
                        expected[idx]--;
                    }
                    s += p.cost;  // BIGRAM COST
                    break;
                }
            }
        }

        viterbi();
        return Z_ - s;
    }
90662
public static BigDecimal yuan2fen(BigDecimal y) {
		if (y != null) {
			return yuan2fen(y.toString());
		} else {
			return new BigDecimal(0);
		}
	}
590178
public static org.mariadb.jdbc.internal.com.send.authentication.ed25519.math.GroupElement precomp(
      final Curve curve,
      final FieldElement ypx,
      final FieldElement ymx,
      final FieldElement xy2d) {
    return new org.mariadb.jdbc.internal.com.send.authentication.ed25519.math.GroupElement(curve,
        Representation.PRECOMP, ypx, ymx, xy2d, null);
  }
1267614
def _preprocess_Y(self, Y, k):
        """"""
        Y = Y.clone()

        # If preds, convert to probs
        if Y.dim() == 1 or Y.shape[1] == 1:
            Y = pred_to_prob(Y.long(), k=k)
        return Y
432145
def _compute_prediction(self,X):
        
        A_pred = np.dot(X,self._Bhat)
        Y_pred = self._basis_object.inverse_transform(A_pred)
        return Y_pred
644648
def r2_score_vec(y_true,y_pred):
    

    numerator = (y_true - y_pred) ** 2
    denominator = (y_true - np.average(y_true)) ** 2

    nonzero_denominator = denominator != 0
    nonzero_numerator = numerator != 0
    valid_score = nonzero_denominator & nonzero_numerator
    output_scores = np.ones([y_true.shape[0]])
    output_scores[valid_score] = 1 - (numerator[valid_score] /
                                      denominator[valid_score])
    # arbitrary set to zero to avoid -inf scores, having a constant
    # y_true is not interesting for scoring a regression anyway
    output_scores[nonzero_numerator & ~nonzero_denominator] = 0.

    return output_scores
470949
public static double subtract(double minuend, double reduction) {
        BigDecimal minuendBd = new BigDecimal(Double.toString(minuend));
        BigDecimal reductionBd = new BigDecimal(Double.toString(reduction));
        return minuendBd.subtract(reductionBd).doubleValue();
    }
530149
public double dot(IntDoubleVector y) {
        if (y instanceof IntDoubleSortedVector) {
            IntDoubleSortedVector other = ((IntDoubleSortedVector) y);
            double dot = 0;
            int oc = 0;
            for (int c = 0; c < used; c++) {
                while (oc < other.used) {
                    if (other.indices[oc] < indices[c]) {
                        oc++;
                    } else if (indices[c] == other.indices[oc]) {
                        dot += values[c] * other.values[oc];
                        break;
                    } else {
                        break;
                    }
                }
            }
            return dot;
        } else {
            double dot = 0;
            for (int c = 0; c < used; c++) {
                dot += this.values[c] * y.get(indices[c]);
            }
            return dot;
        }
    }
1051285
@Pure
	public IntegerProperty y2Property() {
		if (this.p2.y == null) {
			this.p2.y = new SimpleIntegerProperty(this, MathFXAttributeNames.Y2);
		}
		return this.p2.y;
	}
696039
public function subtract(self $y): self
    {
        $value = \gmp_sub($this->value, $y->value);

        return self::createFromGMPResource($value);
    }
1312404
def _log_prior_gradients(self):
        """"""
        if self.priors.size == 0:
            return 0.
        x = self.param_array
        ret = np.zeros(x.size)
        #compute derivate of prior density
        [np.put(ret, ind, p.lnpdf_grad(x[ind])) for p, ind in self.priors.items()]
        #add in jacobian derivatives if transformed
        priored_indexes = np.hstack([i for p, i in self.priors.items()])
        for c,j in self.constraints.items():
            if not isinstance(c, Transformation):continue
            for jj in j:
                if jj in priored_indexes:
                    ret[jj] += c.log_jacobian_grad(x[jj])
        return ret
281119
public static double logSubtractExact(double x, double y) {
        if (x < y) {
            throw new IllegalStateException("x must be >= y. x=" + x + " y=" + y);
        }
        
        // p = 0 or q = 0, where x = log(p), y = log(q)
        if (Double.NEGATIVE_INFINITY == y) {
            return x;
        } else if (Double.NEGATIVE_INFINITY == x) {
            return y;
        } else if (x == y) {
            return Double.NEGATIVE_INFINITY;
        }
        
        // p != 0 && q != 0
        //return x + Math.log1p(-FastMath.exp(y - x));
        // 
        // The method below is more numerically stable for small differences in x and y.
        // See paper: http://cran.r-project.org/web/packages/Rmpfr/vignettes/log1mexp-note.pdf
        return x + log1mexp(x - y);
    }
915716
def get_latent_pred_loss(latents_pred, latents_discrete_hot, hparams):
  """"""
  latents_logits = tf.layers.dense(
      latents_pred, 2**hparams.bottleneck_bits, name="extra_logits")
  loss = tf.nn.softmax_cross_entropy_with_logits_v2(
      labels=tf.stop_gradient(latents_discrete_hot), logits=latents_logits)
  return loss