/** * Negative log-likelihood */ @Override public double valueAt(double[] x) { if (x.length != dimension) throw new IllegalArgumentException( "x is invalid, its dimension is not equal to domain dimension."); // Compute partial value of negative log-likelihood in each thread computeInParallel(x, NegLLComputeTask.class); double negLogLikelihood = 0; for (int t = 0; t < threads; t++) { negLogLikelihood += negLogLikelihoodThread[t]; } return negLogLikelihood; }
/** * Compute gradient */ @Override public double[] gradientAt(double[] x) { if (x.length != dimension) throw new IllegalArgumentException( "x is invalid, its dimension is not equal to the function."); // Compute partial gradient in each thread computeInParallel(x, GradientComputeTask.class); // Accumulate gradient for (int i = 0; i < dimension; i++) { gradient[i] = 0; for (int t = 0; t < threads; t++) { gradient[i] += gradientThread[t][i]; } } return gradient; }
/** * Negative log-likelihood */ @Override public double valueAt(double[] x) { if (x.length != dimension) throw new IllegalArgumentException( "x is invalid, its dimension is not equal to domain dimension."); // Compute partial value of negative log-likelihood in each thread computeInParallel(x, NegLLComputeTask.class); double negLogLikelihood = 0; for (int t = 0; t < threads; t++) { negLogLikelihood += negLogLikelihoodThread[t]; } return negLogLikelihood; }
/** * Negative log-likelihood */ @Override public double valueAt(double[] x) { if (x.length != dimension) throw new IllegalArgumentException( "x is invalid, its dimension is not equal to domain dimension."); // Compute partial value of negative log-likelihood in each thread computeInParallel(x, NegLLComputeTask.class); double negLogLikelihood = 0; for (int t = 0; t < threads; t++) { negLogLikelihood += negLogLikelihoodThread[t]; } return negLogLikelihood; }
/** * Compute gradient */ @Override public double[] gradientAt(double[] x) { if (x.length != dimension) throw new IllegalArgumentException( "x is invalid, its dimension is not equal to the function."); // Compute partial gradient in each thread computeInParallel(x, GradientComputeTask.class); // Accumulate gradient for (int i = 0; i < dimension; i++) { gradient[i] = 0; for (int t = 0; t < threads; t++) { gradient[i] += gradientThread[t][i]; } } return gradient; }
/** * Compute gradient */ @Override public double[] gradientAt(double[] x) { if (x.length != dimension) throw new IllegalArgumentException( "x is invalid, its dimension is not equal to the function."); // Compute partial gradient in each thread computeInParallel(x, GradientComputeTask.class); // Accumulate gradient for (int i = 0; i < dimension; i++) { gradient[i] = 0; for (int t = 0; t < threads; t++) { gradient[i] += gradientThread[t][i]; } } return gradient; }