Package org.apache.mahout.math

Examples of org.apache.mahout.math.DenseVector.assign()


    for (Model<VectorWritable>[] models : result) {
      g2.setStroke(new BasicStroke(i == 0 ? 3 : 1));
      g2.setColor(colors[Math.min(DisplayDirichlet.colors.length - 1, i--)]);
      for (Model<VectorWritable> m : models) {
        NormalModel mm = (NormalModel) m;
        dv.assign(mm.getStdDev() * 3);
        if (DisplayDirichlet.isSignificant(mm)) {
          DisplayDirichlet.plotEllipse(g2, mm.getMean(), dv);
        }
      }
    }
View Full Code Here


    for (List<Cluster> cls : clusters) {
      g2.setStroke(new BasicStroke(i == 0 ? 3 : 1));
      g2.setColor(colors[Math.min(DisplayDirichlet.colors.length - 1, i--)]);
      for (Cluster cluster : cls) {
        // if (true || cluster.getNumPoints() > sampleData.size() * 0.05) {
        dv.assign(cluster.getStd() * 3);
        System.out.println(cluster.getCenter().asFormatString() + ' ' + dv.asFormatString());
        DisplayDirichlet.plotEllipse(g2, cluster.getCenter(), dv);
        // }
      }
    }
View Full Code Here

    for (Model<VectorWritable>[] models : result) {
      g2.setStroke(new BasicStroke(i == 0 ? 3 : 1));
      g2.setColor(colors[Math.min(DisplayDirichlet.colors.length - 1, i--)]);
      for (Model<VectorWritable> m : models) {
        AsymmetricSampledNormalModel mm = (AsymmetricSampledNormalModel) m;
        dv.assign(mm.getStdDev().times(3));
        if (DisplayDirichlet.isSignificant(mm)) {
          DisplayDirichlet.plotEllipse(g2, mm.getMean(), dv);
        }
      }
    }
View Full Code Here

    for (Model<VectorWritable>[] models : result) {
      g2.setStroke(new BasicStroke(i == 0 ? 3 : 1));
      g2.setColor(colors[Math.min(DisplayDirichlet.colors.length - 1, i--)]);
      for (Model<VectorWritable> m : models) {
        NormalModel mm = (NormalModel) m;
        dv.assign(mm.getStdDev() * 3);
        if (DisplayDirichlet.isSignificant(mm)) {
          DisplayDirichlet.plotEllipse(g2, mm.getMean(), dv);
        }
      }
    }
View Full Code Here

    for (Model<VectorWritable>[] models : result) {
      g2.setStroke(new BasicStroke(i == 0 ? 3 : 1));
      g2.setColor(colors[Math.min(DisplayDirichlet.colors.length - 1, i--)]);
      for (Model<VectorWritable> m : models) {
        NormalModel mm = (NormalModel) m;
        dv.assign(mm.getStdDev() * 3);
        if (DisplayDirichlet.isSignificant(mm)) {
          DisplayDirichlet.plotEllipse(g2, mm.getMean(), dv);
        }
      }
    }
View Full Code Here

      Vector realEigen = new DenseVector(corpus.numCols());
      // the eigenvectors live as columns of V, in reverse order.  Weird but true.
      DoubleMatrix1D ejCol = eigenVects.viewColumn(basis.numRows() - i - 1);
      for (int j = 0; j < ejCol.size(); j++) {
        double d = ejCol.getQuick(j);
        realEigen.assign(basis.getRow(j), new PlusMult(d));
      }
      realEigen = realEigen.normalize();
      eigenVectors.assignRow(i, realEigen);
      log.info("Eigenvector {} found with eigenvalue {}", i, eigenVals.get(i));
      eigenValues.add(eigenVals.get(i));
View Full Code Here

    double docTotal = wordCounts.zSum();
    int docLength = wordCounts.size(); // cardinality of document vectors
   
    // initialize variational approximation to p(z|doc)
    Vector gamma = new DenseVector(state.numTopics);
    gamma.assign(state.topicSmoothing + docTotal / state.numTopics);
    Vector nextGamma = new DenseVector(state.numTopics);
    createPhiMatrix(docLength);
   
    Vector digammaGamma = digammaGamma(gamma);
   
View Full Code Here

    int iteration = 0;
   
    boolean converged = false;
    double oldLL = 1;
    while (!converged && (iteration < MAX_ITER)) {
      nextGamma.assign(state.topicSmoothing); // nG := alpha, for all topics
     
      int mapping = 0;
      for (Iterator<Vector.Element> iter = wordCounts.iterateNonZero(); iter.hasNext();) {
        Vector.Element e = iter.next();
        int word = e.index();
View Full Code Here

    return phi;
  }
 
  private static Vector digamma(Vector v) {
    Vector digammaGamma = new DenseVector(v.size());
    digammaGamma.assign(v, new BinaryFunction() {
      @Override
      public double apply(double unused, double g) {
        return digamma(g);
      }
    });
View Full Code Here

      if (max < p) {
        max = p;
      }
    }
    // normalize the probabilities by largest observed value
    pi.assign(new TimesFunction(), 1.0 / max);
    return pi;
  }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.