当前位置: 首页>>代码示例>>Java>>正文


Java RealVector.dotProduct方法代码示例

本文整理汇总了Java中org.apache.commons.math.linear.RealVector.dotProduct方法的典型用法代码示例。如果您正苦于以下问题:Java RealVector.dotProduct方法的具体用法?Java RealVector.dotProduct怎么用?Java RealVector.dotProduct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.math.linear.RealVector的用法示例。


在下文中一共展示了RealVector.dotProduct方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: cosine

import org.apache.commons.math.linear.RealVector; //导入方法依赖的package包/类
public static double cosine(RealVector vec1, RealVector vec2) throws Exception
{
    final double norm1 = vec1.getNorm();
    final double norm2 = vec2.getNorm();

    if (norm1 == 0 || norm2 == 0) 
        throw new Exception("Division by zero");
    return vec1.dotProduct(vec2) / (norm1 * norm2);
}
 
开发者ID:sinantie,项目名称:Generator,代码行数:10,代码来源:Utils.java

示例2: getInnerProduct

import org.apache.commons.math.linear.RealVector; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public double getInnerProduct(final Matrix<?> m1, final Matrix<?> m2) {
  Validate.notNull(m1, "m1");
  Validate.notNull(m2, "m2");
  if (m1 instanceof DoubleMatrix1D && m2 instanceof DoubleMatrix1D) {
    final RealVector t1 = CommonsMathWrapper.wrap((DoubleMatrix1D) m1);
    final RealVector t2 = CommonsMathWrapper.wrap((DoubleMatrix1D) m2);
    return t1.dotProduct(t2);
  }
  throw new IllegalArgumentException("Can only find inner product of DoubleMatrix1D; have " + m1.getClass() + " and " + m2.getClass());
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:15,代码来源:CommonsMatrixAlgebra.java

示例3: calculateYVariance

import org.apache.commons.math.linear.RealVector; //导入方法依赖的package包/类
/**
 * Calculates the variance on the y by GLS.
 * <pre>
 *  Var(y)=Tr(u' Omega^-1 u)/(n-k)
 * </pre>
 * @return The Y variance
 */
@Override
protected double calculateYVariance() {
    RealVector residuals = calculateResiduals();
    double t = residuals.dotProduct(getOmegaInverse().operate(residuals));
    return t / (X.getRowDimension() - X.getColumnDimension());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:14,代码来源:GLSMultipleLinearRegression.java

示例4: calculateYVariance

import org.apache.commons.math.linear.RealVector; //导入方法依赖的package包/类
/**
 * <p>Calculates the variance on the Y by OLS.
 * </p>
 * <p> Var(y) = Tr(u<sup>T</sup>u)/(n - k)
 * </p>
 * @return The Y variance
 */
@Override
protected double calculateYVariance() {
    RealVector residuals = calculateResiduals();
    return residuals.dotProduct(residuals) /
           (X.getRowDimension() - X.getColumnDimension());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:14,代码来源:OLSMultipleLinearRegression.java

示例5: calculateErrorVariance

import org.apache.commons.math.linear.RealVector; //导入方法依赖的package包/类
/**
 * Calculates the estimated variance of the error term using the formula
 * <pre>
 *  Var(u) = Tr(u' Omega^-1 u)/(n-k)
 * </pre>
 * where n and k are the row and column dimensions of the design
 * matrix X.
 *
 * @return error variance
 * @since 2.2
 */
@Override
protected double calculateErrorVariance() {
    RealVector residuals = calculateResiduals();
    double t = residuals.dotProduct(getOmegaInverse().operate(residuals));
    return t / (X.getRowDimension() - X.getColumnDimension());

}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:19,代码来源:GLSMultipleLinearRegression.java

示例6: cosAngle

import org.apache.commons.math.linear.RealVector; //导入方法依赖的package包/类
/**
 * Compute the cosine of the angle between 2 vectors.
 *
 * @param v Vector.
 * @param w Vector.
 * @return cosine of the angle
 */
private double cosAngle(final RealVector v, final RealVector w) {
    return v.dotProduct(w) / (v.getNorm() * w.getNorm());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:11,代码来源:MicrosphereInterpolatingFunction.java

示例7: calculateErrorVariance

import org.apache.commons.math.linear.RealVector; //导入方法依赖的package包/类
/**
 * <p>Calculates the variance of the error term.</p>
 * Uses the formula <pre>
 * var(u) = u &middot; u / (n - k)
 * </pre>
 * where n and k are the row and column dimensions of the design
 * matrix X.
 *
 * @return error variance estimate
 * @since 2.2
 */
protected double calculateErrorVariance() {
    RealVector residuals = calculateResiduals();
    return residuals.dotProduct(residuals) /
           (X.getRowDimension() - X.getColumnDimension());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:17,代码来源:AbstractMultipleLinearRegression.java

示例8: calculateResidualSumOfSquares

import org.apache.commons.math.linear.RealVector; //导入方法依赖的package包/类
/**
 * Returns the sum of squared residuals.
 *
 * @return residual sum of squares
 * @since 2.2
 */
public double calculateResidualSumOfSquares() {
    final RealVector residuals = calculateResiduals();
    return residuals.dotProduct(residuals);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:11,代码来源:OLSMultipleLinearRegression.java

示例9: cosAngle

import org.apache.commons.math.linear.RealVector; //导入方法依赖的package包/类
/**
 * Compute the cosine of the angle between 2 vectors.
 *
 * @param v Vector.
 * @param w Vector.
 * @return the cosine of the angle between {@code v} and {@code w}.
 */
private double cosAngle(final RealVector v, final RealVector w) {
    return v.dotProduct(w) / (v.getNorm() * w.getNorm());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:11,代码来源:MicrosphereInterpolatingFunction.java

示例10: distance

import org.apache.commons.math.linear.RealVector; //导入方法依赖的package包/类
/**
 * Cosine similarity.
 * @param v1 first vector
 * @param v2 second vector
 * @return The cosine of the angle between the vectors
 */
public static double distance(RealVector v1, RealVector v2) {
  return (v1.dotProduct(v2)) / (v1.getNorm() * v2.getNorm());
}
 
开发者ID:apache,项目名称:incubator-datafu,代码行数:10,代码来源:Cosine.java


注:本文中的org.apache.commons.math.linear.RealVector.dotProduct方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。