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


Java Vector.minus方法代码示例

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


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

示例1: observe

import org.apache.mahout.math.Vector; //导入方法依赖的package包/类
@Override
public void observe(Vector x, double weight) {
  double temp = weight + sumWeight;
  Vector q;
  if (mean == null) {
    mean = x.like();
    q = x.clone();
  } else {
    q = x.minus(mean);
  }
  Vector r = q.times(weight).divide(temp);
  if (s == null) {
    s = q.times(sumWeight).times(r);
  } else {
    s = s.plus(q.times(sumWeight).times(r));
  }
  mean = mean.plus(r);
  sumWeight = temp;
  variance = s.divide(sumWeight - 1); //  # if sample is the population, omit -1
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:21,代码来源:OnlineGaussianAccumulator.java

示例2: distance

import org.apache.mahout.math.Vector; //导入方法依赖的package包/类
@Override
public double distance(Vector v1, Vector v2) {
  if (v1.size() != v2.size()) {
    throw new CardinalityException(v1.size(), v2.size());
  }
  double result = 0.0;
  Vector vector = v1.minus(v2);
  Iterator<Vector.Element> iter = vector.iterateNonZero(); 
  while (iter.hasNext()) {
    Vector.Element e = iter.next();
    double d = Math.abs(e.get());
    if (d > result) {
      result = d;
    }
  }
  return result;
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:18,代码来源:ChebyshevDistanceMeasure.java

示例3: distance

import org.apache.mahout.math.Vector; //导入方法依赖的package包/类
@Override
public double distance(Vector v1, Vector v2) {
  if (v1.size() != v2.size()) {
    throw new CardinalityException(v1.size(), v2.size());
  }
  double result = 0;
  Vector vector = v1.minus(v2);
  Iterator<Vector.Element> iter = vector.iterateNonZero(); 
  // this contains all non zero elements between the two
  while (iter.hasNext()) {
    Vector.Element e = iter.next();
    result += Math.abs(e.get());
  }
  return result;
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:16,代码来源:ManhattanDistanceMeasure.java

示例4: distance

import org.apache.mahout.math.Vector; //导入方法依赖的package包/类
/**
 *  Math.pow is clever about integer-valued doubles
 */
@Override
public double distance(Vector v1, Vector v2) {
  Vector distVector = v1.minus(v2);
  double sum = 0.0;
  Iterator<Element> it = distVector.iterateNonZero();
  while (it.hasNext()) {
    Element e = it.next();
    sum += Math.pow(Math.abs(e.get()), exponent);
  }
  return Math.pow(sum, 1.0 / exponent);
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:15,代码来源:MinkowskiDistanceMeasure.java


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