/** {@inheritDoc} */ @Deprecated public RealMatrix inverse() throws InvalidMatrixException { if (lu == null) { lu = new LUDecompositionImpl(this, MathUtils.SAFE_MIN).getSolver(); } return lu.getInverse(); }
/** * Calculates the regression coefficients using OLS. * * @return beta */ @Override protected RealVector calculateBeta() { return qr.getSolver().solve(Y); }
/** {@inheritDoc} */ @Deprecated public boolean isSingular() { if (lu == null) { lu = new LUDecompositionImpl(this, MathUtils.SAFE_MIN).getSolver(); } return !lu.isNonSingular(); }
/** {@inheritDoc} */ @Deprecated public RealMatrix inverse() throws InvalidMatrixException { if (lu == null) { lu = new LUDecompositionImpl(this, MathUtils.SAFE_MIN).getSolver(); } return lu.getInverse(); }
/** * Calculates regression coefficients using OLS. * * @return beta */ @Override protected RealVector calculateBeta() { return qr.getSolver().solve(Y); }
/** {@inheritDoc} */ @Deprecated public boolean isSingular() { if (lu == null) { lu = new LUDecompositionImpl(this, MathUtils.SAFE_MIN).getSolver(); } return !lu.isNonSingular(); }
/** * Get the inverse of the covariance. * <p>The inverse of the covariance matrix is lazily evaluated and cached.</p> * @return inverse of the covariance */ protected RealMatrix getOmegaInverse() { if (OmegaInverse == null) { OmegaInverse = new LUDecompositionImpl(Omega).getSolver().getInverse(); } return OmegaInverse; }
/** {@inheritDoc} */ @Deprecated public double[] solve(final double[] b) throws IllegalArgumentException, InvalidMatrixException { if (lu == null) { lu = new LUDecompositionImpl(this, MathUtils.SAFE_MIN).getSolver(); } return lu.solve(b); }
/** * Get the inverse of the covariance. * <p>The inverse of the covariance matrix is lazily evaluated and cached.</p> * @return inverse of the covariance */ protected RealMatrix getOmegaInverse() { if (OmegaInverse == null) { OmegaInverse = new LUDecompositionImpl(Omega).getSolver().getInverse(); } return OmegaInverse; }
/** {@inheritDoc} */ @Deprecated public RealMatrix solve(final RealMatrix b) throws IllegalArgumentException, InvalidMatrixException { if (lu == null) { lu = new LUDecompositionImpl(this, MathUtils.SAFE_MIN).getSolver(); } return lu.solve(b); }
RealMatrix H_inv; try { H_inv = new LUDecompositionImpl(H).getSolver().getInverse(); } catch (RuntimeException e) { continue X;
/** {@inheritDoc} */ @Deprecated public double[] solve(final double[] b) throws IllegalArgumentException, InvalidMatrixException { if (lu == null) { lu = new LUDecompositionImpl(this, MathUtils.SAFE_MIN).getSolver(); } return lu.solve(b); }
/** * Calculates the variance on the beta. * <pre> * Var(b)=(X' Omega^-1 X)^-1 * </pre> * @return The beta variance matrix */ @Override protected RealMatrix calculateBetaVariance() { RealMatrix OI = getOmegaInverse(); RealMatrix XTOIX = X.transpose().multiply(OI).multiply(X); return new LUDecompositionImpl(XTOIX).getSolver().getInverse(); }
/** {@inheritDoc} */ @Deprecated public RealMatrix solve(final RealMatrix b) throws IllegalArgumentException, InvalidMatrixException { if (lu == null) { lu = new LUDecompositionImpl(this, MathUtils.SAFE_MIN).getSolver(); } return lu.solve(b); }
final double[][] invHess = new LUDecompositionImpl(new Array2DRowRealMatrix(hess)).getSolver().getInverse().getData(); for (int i = 0; i < d; i++) { for (int j = 0; j < d; j++) {
public static double [] solveMatrix(double [][] coefficientMatrix,double [] rhsVector) { RealVector x = null; try { RealMatrix a = new Array2DRowRealMatrix(coefficientMatrix); RealVector b = new ArrayRealVector(rhsVector); DecompositionSolver solver = new LUDecompositionImpl(a).getSolver(); x = solver.solve(b); } catch(Exception e) { e.printStackTrace(); } double [] result; result=x.toArray(); return result; } }
/** * Calculates the variance on the beta by GLS. * <pre> * Var(b)=(X' Omega^-1 X)^-1 * </pre> * @return The beta variance matrix */ @Override protected RealMatrix calculateBetaVariance() { RealMatrix OI = getOmegaInverse(); RealMatrix XTOIX = X.transpose().multiply(OI).multiply(X); return new LUDecompositionImpl(XTOIX).getSolver().getInverse(); }
private double[] solveLinearEquation( double[][] matrixA, double[] vectorb ) { RealMatrix coefficients = new Array2DRowRealMatrix( matrixA, false ); // LU-decomposition DecompositionSolver solver = new LUDecompositionImpl( coefficients ).getSolver(); RealVector constants = new ArrayRealVector( vectorb, false ); RealVector solution = null; try { solution = solver.solve( constants ); } catch ( SingularMatrixException e ) { LOG.error( e.getLocalizedMessage() ); e.printStackTrace(); } return solution.getData(); }
/** * <p>Calculates the variance-covariance matrix of the regression parameters. * </p> * <p>Var(b) = (X<sup>T</sup>X)<sup>-1</sup> * </p> * <p>Uses QR decomposition to reduce (X<sup>T</sup>X)<sup>-1</sup> * to (R<sup>T</sup>R)<sup>-1</sup>, with only the top p rows of * R included, where p = the length of the beta vector.</p> * * @return The beta variance-covariance matrix */ @Override protected RealMatrix calculateBetaVariance() { int p = X.getColumnDimension(); RealMatrix Raug = qr.getR().getSubMatrix(0, p - 1 , 0, p - 1); RealMatrix Rinv = new LUDecompositionImpl(Raug).getSolver().getInverse(); return Rinv.multiply(Rinv.transpose()); }
new LUDecompositionImpl(mA).getSolver() : new QRDecompositionImpl(mA).getSolver(); final double[] dX = solver.solve(b);