assert Math.abs(userFeatures.getColumnVector(f).getL1Norm() - uvec.getL1Norm()) < 1.0e-4 : "user column sum matches"; itemFeatures.setColumnVector(f, ivec); assert Math.abs(itemFeatures.getColumnVector(f).getL1Norm() - ivec.getL1Norm()) < 1.0e-4 : "item column sum matches";
case 2: for(int j=0; j<A.getColumnDimension(); j++){ columnNormsList.add(A.getColumnVector(j).getL1Norm()); double normAInf = A.getNorm(); for(int j=0; j<A.getColumnDimension(); j++){ columnNormsList.add(A.getColumnVector(j).getLInfNorm());
@Override public double getNorm1(Matrix m) { ArgChecker.notNull(m, "m"); if (m instanceof DoubleArray) { RealVector temp = CommonsMathWrapper.wrap((DoubleArray) m); return temp.getL1Norm(); } else if (m instanceof DoubleMatrix) { RealMatrix temp = CommonsMathWrapper.wrap((DoubleMatrix) m); // TODO find if commons implements this anywhere, so we are not doing it // by hand double max = 0.0; for (int col = temp.getColumnDimension() - 1; col >= 0; col--) { max = Math.max(max, temp.getColumnVector(col).getL1Norm()); } return max; } throw new IllegalArgumentException("Can only find norm1 of DoubleMatrix; have " + m.getClass()); }
/** * Runs the regression model for the given dependent and independent variables * The Y and X variables must be transformed, if necessary, to meet Gauss Markov assumptions * @param y the dependent variable, which may be a transformed version of the raw data * @param x the independent variable(s), which may be a transformed version of the raw data */ protected void compute(RealVector y, RealMatrix x) { final int n = frame.rows().count(); final int p = regressors.size() + (hasIntercept() ? 1 : 0); final int dfModel = regressors.size(); final RealMatrix betaMatrix = computeBeta(y, x); final RealVector betaCoefficients = betaMatrix.getColumnVector(0); final RealVector betaVariance = betaMatrix.getColumnVector(1); this.tss = computeTSS(y); this.ess = tss - rss; this.fValue = (ess / dfModel) / (rss / (n - p)); this.fValueProbability = 1d - new FDistribution(dfModel, n-p).cumulativeProbability(fValue); this.rSquared = 1d - (rss / tss); this.rSquaredAdj = 1d - (rss * (n - (hasIntercept() ? 1 : 0))) / (tss * (n - p)); this.computeParameterStdErrors(betaVariance); this.computeParameterSignificance(betaCoefficients); }
double[] vars = new double[data.getColumnDimension()]; for (int j=0;j<data.getColumnDimension();j++){ RealVector column = data.getColumnVector(j); mins[j] = column.getMinValue(); maxs[j] = column.getMaxValue();
vectors[i] = realMatrix.getColumnVector(i).toArray();
private final void makeFunction() { int order = (int) orderGeo.evaluateDouble(); double[][] coeffs = new double[order + 1][order + 1]; // Log.debug("row/cols = "+V.getRowDimension() + " "+ // V.getColumnDimension()+" "+(order * (order + 3) / 2 -1)); // Log.debug(V.toString()); RealVector coeffsRV = V.getColumnVector(V.getColumnDimension() - 1); int c = 0; // create powers eg x^2y^0, x^1y^1, x^0*y^2, x, y, 1 for (int i = 0; i <= order; i++) { for (int j = 0; j <= i; j++) { coeffs[j][i - j] = coeffsRV.getEntry(c++); } } fitfunction.setCoeff(coeffs); fitfunction.setDefined(); }
double residual=equalityConstraintQRDecomposition.getQ().getColumnVector(i).dotProduct(new ArrayRealVector(linearEqualityConstraintsBVector)); if(Math.abs(residual)<1e-10)
double residual=equalityConstraintQRDecomposition.getQ().getColumnVector(i).dotProduct(new ArrayRealVector(linearEqualityConstraintsBVector)); if(Math.abs(residual)<1e-10)
assert Math.abs(userFeatures.getColumnVector(f).getL1Norm() - uvec.getL1Norm()) < 1.0e-4 : "user column sum matches"; itemFeatures.setColumnVector(f, ivec); assert Math.abs(itemFeatures.getColumnVector(f).getL1Norm() - ivec.getL1Norm()) < 1.0e-4 : "item column sum matches";
vectors[i] = realMatrix.getColumnVector(i).toArray();
double[] vars = new double[data.getColumnDimension()]; for (int j=0;j<data.getColumnDimension();j++){ RealVector column = data.getColumnVector(j); mins[j] = column.getMinValue(); maxs[j] = column.getMaxValue();
RealVector x = T.getSubMatrix(i, i + 1, i, i).getColumnVector(0); x = unitL2norm(x);
RealVector coeffsRV = V.getColumnVector(5);
RealVector zcol1 = z.getColumnVector(0); //has length length(ts) - 1 - k + 1 double[] xt1 = subsetArray(ts, k-1, n-1); //ts[k:(length(ts) - 1)], has length length(ts) - 1 - k + 1 double[] trend = sequence(k,n); //trend k:n, has length length(ts) - 1 - k + 1
RealVector zcol1 = z.getColumnVector(0); //has length length(ts) - 1 - k + 1 double[] xt1 = subsetArray(ts, k-1, n-1); //ts[k:(length(ts) - 1)], has length length(ts) - 1 - k + 1 double[] trend = sequence(k,n); //trend k:n, has length length(ts) - 1 - k + 1