当前位置: 首页>>代码示例>>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;未经允许,请勿转载。