本文整理匯總了Java中org.apache.commons.math3.linear.RealVector.toArray方法的典型用法代碼示例。如果您正苦於以下問題:Java RealVector.toArray方法的具體用法?Java RealVector.toArray怎麽用?Java RealVector.toArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.math3.linear.RealVector
的用法示例。
在下文中一共展示了RealVector.toArray方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: score
import org.apache.commons.math3.linear.RealVector; //導入方法依賴的package包/類
private NoveltyScores score(final RealMatrix kernelMatrix) {
// projected test samples:
final RealMatrix projectionVectors =
kernelMatrix.transpose().multiply(m_projection);
// differences to the target value:
final RealMatrix diff = projectionVectors.subtract(
MatrixFunctions.ones(kernelMatrix.getColumnDimension(), 1)
.scalarMultiply(m_targetPoints.getEntry(0, 0)));
// distances to the target value:
final RealVector scoresVector = MatrixFunctions.sqrt(MatrixFunctions
.rowSums(MatrixFunctions.multiplyElementWise(diff, diff)));
return new NoveltyScores(scoresVector.toArray(), projectionVectors);
}
示例2: estimateCoefficients
import org.apache.commons.math3.linear.RealVector; //導入方法依賴的package包/類
@Override
public SlopeCoefficients estimateCoefficients(final DerivationEquation eq)
throws EstimationException {
final double[][] sourceTriangleMatrix = eq.getCovarianceLowerTriangularMatrix();
// Copy matrix and enhance it to a full matrix as expected by CholeskyDecomposition
// FIXME: Avoid copy job to speed-up the solving process e.g. by extending the CholeskyDecomposition constructor
final int length = sourceTriangleMatrix.length;
final double[][] matrix = new double[length][];
for (int i = 0; i < length; i++) {
matrix[i] = new double[length];
final double[] s = sourceTriangleMatrix[i];
final double[] t = matrix[i];
for (int j = 0; j <= i; j++) {
t[j] = s[j];
}
for (int j = i + 1; j < length; j++) {
t[j] = sourceTriangleMatrix[j][i];
}
}
final RealMatrix coefficients =
new Array2DRowRealMatrix(matrix, false);
try {
final DecompositionSolver solver = new CholeskyDecomposition(coefficients).getSolver();
final RealVector constants = new ArrayRealVector(eq.getConstraints(), true);
final RealVector solution = solver.solve(constants);
return new DefaultSlopeCoefficients(solution.toArray());
} catch (final NonPositiveDefiniteMatrixException e) {
throw new EstimationException("Matrix inversion error due to data is linearly dependent", e);
}
}
示例3: score
import org.apache.commons.math3.linear.RealVector; //導入方法依賴的package包/類
private NoveltyScores score(final RealMatrix kernelMatrix) {
final RealMatrix projectionVectors =
kernelMatrix.transpose().multiply(m_projection);
// squared euclidean distances to target points:
final RealMatrix squared_distances =
squared_euclidean_distances(projectionVectors, m_targetPoints);
// novelty scores as minimum distance to one of the target points
final RealVector scoreVector = MatrixFunctions
.sqrt(MatrixFunctions.rowMins(squared_distances));
return new NoveltyScores(scoreVector.toArray(), projectionVectors);
}
示例4: simpleNewtonIteration
import org.apache.commons.math3.linear.RealVector; //導入方法依賴的package包/類
public static RealVector simpleNewtonIteration(RealVector currentApprox) {
NewtonMethod method = new NewtonMethod();
double[] temp = currentApprox.toArray();
method.setJacobiMatrix(temp);
method.setEquationSystem(temp);
RealVector vector = method.solveOfEquation();
return vector.add(currentApprox);
}
示例5: getAccuracy
import org.apache.commons.math3.linear.RealVector; //導入方法依賴的package包/類
public static float getAccuracy(LeastSquaresOptimizer.Optimum optimum) {
RealVector standardDeviation = optimum.getSigma(0);
float maximumDeviation = 0;
for (double deviation : standardDeviation.toArray()) {
maximumDeviation = (float) Math.max(maximumDeviation, deviation);
}
return maximumDeviation;
}
示例6: computeTSS
import org.apache.commons.math3.linear.RealVector; //導入方法依賴的package包/類
/**
* Computes the Total Sum of Squares for regressand
* @param y the vector with dependent variable observations
* @return the Total Sum of Squares for regressand
*/
protected double computeTSS(RealVector y) {
if (!hasIntercept()) {
return y.dotProduct(y);
} else {
final double[] values = y.toArray();
final double mean = DoubleStream.of(values).average().orElse(Double.NaN);
final double[] demeaned = DoubleStream.of(values).map(v -> v - mean).toArray();
final RealVector demeanedVector = new ArrayRealVector(demeaned);
return demeanedVector.dotProduct(demeanedVector);
}
}
示例7: HomogeneousVector
import org.apache.commons.math3.linear.RealVector; //導入方法依賴的package包/類
/**
* Creates a new homogeneous vector from Cartesian
* coordinates.
* @param c Cartesian coordinates.
*/
public HomogeneousVector(RealVector c) {
this(c.toArray());
}