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


Java Vector.like方法代码示例

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


在下文中一共展示了Vector.like方法的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: sampleFromPrior

import org.apache.mahout.math.Vector; //导入方法依赖的package包/类
@Override
public Model<VectorWritable>[] sampleFromPrior(int howMany) {
  Model<VectorWritable>[] result = new GaussianCluster[howMany];
  for (int i = 0; i < howMany; i++) {
    Vector prototype = getModelPrototype().get();
    Vector mean = prototype.like();
    for (int j = 0; j < prototype.size(); j++) {
      mean.set(j, UncommonDistributions.rNorm(0, 1));
    }
    Vector sd = prototype.like();
    for (int j = 0; j < prototype.size(); j++) {
      sd.set(j, UncommonDistributions.rNorm(1, 1));
    }
    result[i] = new GaussianCluster(mean, sd, i);
  }
  return result;
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:18,代码来源:GaussianClusterDistribution.java

示例3: rDirichlet

import org.apache.mahout.math.Vector; //导入方法依赖的package包/类
/**
 * Sample from a Dirichlet distribution, returning a vector of probabilities using a stick-breaking
 * algorithm
 * 
 * @param totalCounts
 *          an unnormalized count Vector
 * @param alpha0
 *          a double
 * @return a Vector of probabilities
 */
public static Vector rDirichlet(Vector totalCounts, double alpha0) {
  Vector pi = totalCounts.like();
  double total = totalCounts.zSum();
  double remainder = 1.0;
  for (int k = 0; k < pi.size(); k++) {
    double countK = totalCounts.get(k);
    total -= countK;
    double betaK = rBeta(1.0 + countK, Math.max(0.0, alpha0 + total));
    double piK = betaK * remainder;
    pi.set(k, piK);
    remainder -= piK;
  }
  return pi;
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:25,代码来源:UncommonDistributions.java

示例4: infer

import org.apache.mahout.math.Vector; //导入方法依赖的package包/类
public Vector infer(Vector original, Vector docTopics) {
  Vector pTerm = original.like();
  Iterator<Vector.Element> it = original.iterateNonZero();
  while (it.hasNext()) {
    Vector.Element e = it.next();
    int term = e.index();
    // p(a) = sum_x (p(a|x) * p(x|i))
    double pA = 0;
    for (int x = 0; x < numTopics; x++) {
      pA += (topicTermCounts.viewRow(x).get(term) / topicSums.get(x)) * docTopics.get(x);
    }
    pTerm.set(term, pA);
  }
  return pTerm;
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:16,代码来源:TopicModel.java


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