List of usage examples for org.apache.commons.math3.linear RealMatrix power
RealMatrix power(final int p) throws NotPositiveException, NonSquareMatrixException;
From source file:com.opengamma.strata.math.impl.matrix.CommonsMatrixAlgebra.java
@Override public DoubleMatrix getPower(Matrix m, int p) { ArgChecker.notNull(m, "m"); RealMatrix temp; if (m instanceof DoubleMatrix) { temp = CommonsMathWrapper.wrap((DoubleMatrix) m); } else {/* w w w . j a va 2 s . c o m*/ throw new IllegalArgumentException("Can only find powers of DoubleMatrix; have " + m.getClass()); } return CommonsMathWrapper.unwrap(temp.power(p)); }
From source file:cz.cuni.mff.spl.evaluator.statistics.KolmogorovSmirnovTestFlag.java
/** * Calculates {@code P(D_n < d)} using method described in [1] and doubles (see above). * * @param d statistic//w w w.ja v a 2s . c o m * @param n sample size * @return \(P(D_n < d)\) */ private double roundedK(double d, int n) { final int k = (int) Math.ceil(n * d); final RealMatrix H = this.createRoundedH(d, n); final RealMatrix Hpower = H.power(n); double pFrac = Hpower.getEntry(k - 1, k - 1); for (int i = 1; i <= n; ++i) { pFrac *= (double) i / (double) n; } return pFrac; }