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


Java Vector.zSum方法代码示例

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


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

示例1: rMultinom

import org.apache.mahout.math.Vector; //导入方法依赖的package包/类
/** Returns one sample from a multinomial. */
public static int rMultinom(Vector probabilities) {
  // our probability argument are not normalized.
  double total = probabilities.zSum();
  double nextDouble = RANDOM.nextDouble();
  double p = nextDouble * total;
  for (int i = 0; i < probabilities.size(); i++) {
    double pi = probabilities.get(i);
    if (p < pi) {
      return i;
    } else {
      p -= pi;
    }
  }
  // can't happen except for round-off error so we don't care what we return here
  return 0;
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:18,代码来源:UncommonDistributions.java

示例2: getAverageStd

import org.apache.mahout.math.Vector; //导入方法依赖的package包/类
@Override
public double getAverageStd() {
  if (sumWeight == 0.0) {
    return 0.0;
  } else {
    Vector std = getStd();
    return std.zSum() / std.size();
  }
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:10,代码来源:OnlineGaussianAccumulator.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: median

import org.apache.mahout.math.Vector; //导入方法依赖的package包/类
/**
 * A quick and dirty hack to compute the median of a vector...
 * @param v
 * @return
 */
private static double median(Vector v) {
  OnlineSummarizer med = new OnlineSummarizer();
  if (v.size() < 100) {
    return v.zSum() / v.size();
  }
  for (Vector.Element e : v) {
    med.add(e.get());
  }
  return med.getMedian();
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:16,代码来源:EigencutsDriver.java

示例5: trace

import org.apache.mahout.math.Vector; //导入方法依赖的package包/类
/**
 * @param m matrix
 * @return m.viewDiagonal().zSum()
 */
static double trace(Matrix m) {
  Vector d = m.viewDiagonal();
  return d.zSum();
}
 
开发者ID:SiddharthMalhotra,项目名称:sPCA,代码行数:9,代码来源:PCACommon.java

示例6: trace

import org.apache.mahout.math.Vector; //导入方法依赖的package包/类
/**
   * @param m matrix
   * @return trace of matrix m
*/

static double trace(Matrix m) {
	Vector d = m.viewDiagonal();
	return d.zSum();
}
 
开发者ID:SiddharthMalhotra,项目名称:sPCA,代码行数:10,代码来源:PCAUtils.java


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