當前位置: 首頁>>代碼示例>>Java>>正文


Java RealVector.toArray方法代碼示例

本文整理匯總了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);
}
 
開發者ID:knime,項目名稱:knime-activelearning,代碼行數:17,代碼來源:OneClassKNFST.java

示例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);
  }
}
 
開發者ID:scaleborn,項目名稱:elasticsearch-linear-regression,代碼行數:31,代碼來源:CommonsMathSolver.java

示例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);
}
 
開發者ID:knime,項目名稱:knime-activelearning,代碼行數:14,代碼來源:MultiClassKNFST.java

示例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);
}
 
開發者ID:vahriin,項目名稱:University,代碼行數:9,代碼來源:Main.java

示例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;
}
 
開發者ID:neXenio,項目名稱:BLE-Indoor-Positioning,代碼行數:9,代碼來源:Multilateration.java

示例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);
    }
}
 
開發者ID:zavtech,項目名稱:morpheus-core,代碼行數:17,代碼來源:XDataFrameLeastSquares.java

示例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());
}
 
開發者ID:imagingbook,項目名稱:imagingbook-common,代碼行數:9,代碼來源:HomogeneousVector.java


注:本文中的org.apache.commons.math3.linear.RealVector.toArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。