Refine search
public double[][] getDataProjected(Matrix data, boolean debug) { // Project the original data set Matrix dataProjected; dataProjected = PC.transpose().times(data); if (debug) { System.out.println("Data projected:"); dataProjected.print(dataProjected.getRowDimension(), 3); } return dataProjected.getArray(); }
public double[][] getDataProjected(Matrix data, boolean debug) { // Project the original data set Matrix dataProjected; dataProjected = PC.transpose().times(data); if (debug) { System.out.println("Data projected:"); dataProjected.print(dataProjected.getRowDimension(), 3); } return dataProjected.getArray(); }
Matrix x_r = new Matrix(xxchol.getL()).transpose(); x_r = x_r.times(Math.sqrt(nobs)); Matrix rrmul = x_r.times(yt_r.transpose()); SingularValueDecomposition rrsvd = new SingularValueDecomposition(rrmul); // RS' = U \Sigma V' double[] sval = rrsvd.getSingularValues(); // get singular values as double array Matrix eigvec = yt_qr.getQ().times(rrsvd.getV());
/** * @param pt point * @return the square of the Mahalanobis distance of the point from center of gravity */ public double distancesqu(double[] pt) { double[] df = new double[pt.length]; for (int k = 0; k < pt.length; k++){ df[k] = pt[k] - this.cog[k]; } Matrix dfm = new Matrix(df, pt.length); return Math.abs(dfm.transpose().times(this.covinv.times(dfm)).getArray()[0][0]); }
@Override public double[] predict(double[] data) { final double[][] corrected = new double[][] { new double[data.length + 1] }; corrected[0][0] = 1; System.arraycopy(data, 0, corrected[0], 1, data.length); final Matrix x = new Matrix(corrected); return x.times(this.weights).transpose().getArray()[0]; }
/** * De-normalise a fundamental estimate. Use when {@link #estimate(List)} was * called with pre-normalised data. * * @param norms * the normalisation transforms */ public void denormaliseFundamental(Pair<Matrix> norms) { this.fundamental = norms.secondObject().transpose().times(fundamental).times(norms.firstObject()); }
/** * Compute the covariance matrix of the given samples (assumed each sample is a * row). * * @param m * the samples matrix * @return the covariance matrix */ public static Matrix covariance(Matrix m) { final int N = m.getRowDimension(); return times(m.transpose().times(m), 1.0 / (N > 1 ? N - 1 : N)); }
@Override public double estimateLogProbability(double[] sample) { final Matrix xm = new Matrix(1, N); for (int i = 0; i < N; i++) xm.set(0, i, sample[i] - mean.get(0, i)); final Matrix xmt = xm.transpose(); final double v = xm.times(inv_covar.times(xmt)).get(0, 0); return Math.log(pdf_const_factor) + (-0.5 * v); }