Package gnu.trove.iterator

Examples of gnu.trove.iterator.TObjectDoubleIterator


      //
      // message to self
      output.collect(new Text(fields[0]), new Text("labels" + _kDelim + line));

      // message to neighbors
      TObjectDoubleIterator neighIterator = neighbors.iterator();
      while (neighIterator.hasNext()) {
  neighIterator.advance();
        
  // message (neighbor_node, current_node + DELIM + curr_node_label_scores
  output.collect(new Text((String) neighIterator.key()),
           new Text("labels" + _kDelim + fields[0] + _kDelim + fields[3]));
        
  // message (neighbor_node, curr_node + DELIM + curr_node_edge_weights + DELIM curr_node_cont_prob
  assert(neighbors.containsKey((String) neighIterator.key()));
  output.collect(new Text((String) neighIterator.key()),
           new Text("edge_info" + _kDelim +
        fields[0] + _kDelim +
        neighbors.get((String) neighIterator.key()) + _kDelim +
        rwProbabilities.get(Constants._kContProb)));
      }
    }
View Full Code Here


      }
    }
  }

  public static double GetSum(TObjectDoubleHashMap m) {
    TObjectDoubleIterator mi = m.iterator();
    double sum = 0;
    while (mi.hasNext()) {
      mi.advance();
      sum += mi.value();
    }
    return (sum);
  }
View Full Code Here

             TObjectDoubleHashMap incomingEdgeWeights,
             TObjectDoubleHashMap neighborContProb,
             double mu1, double mu2, double mu3) {
      double mii = 0;
      double totalNeighWeight = 0;
      TObjectDoubleIterator nIter = neighbors.iterator();
      while (nIter.hasNext()) {
  nIter.advance();
  totalNeighWeight +=
    randWalkProbs.get(Constants._kContProb) * nIter.value();

  String neighName = (String) nIter.key();
  totalNeighWeight += neighborContProb.get(neighName) *
    incomingEdgeWeights.get(neighName);
      }
     
      // mu1 x p^{inj} +
View Full Code Here

  public static double GetDifferenceNorm2Squarred(TObjectDoubleHashMap m1,
                                                  double m1Mult, TObjectDoubleHashMap m2, double m2Mult) {
    TObjectDoubleHashMap diffMap = new TObjectDoubleHashMap();

    // copy m1 into the difference map
    TObjectDoubleIterator iter = m1.iterator();
    while (iter.hasNext()) {
      iter.advance();
      diffMap.put(iter.key(), m1Mult * iter.value());
    }

    iter = m2.iterator();
    while (iter.hasNext()) {
      iter.advance();
      diffMap.adjustOrPutValue(iter.key(), -1 * m2Mult * iter.value(), -1
                               * m2Mult * iter.value());
    }

    double val = 0;
    iter = diffMap.iterator();
    while (iter.hasNext()) {
      iter.advance();
      val += iter.value() * iter.value();
    }

    return (Math.sqrt(val));
  }
View Full Code Here

  // KL (m1 || m2)
  public static double GetKLDifference(TObjectDoubleHashMap m1,
                                       TObjectDoubleHashMap m2) {
    double divergence = 0;

    TObjectDoubleIterator iter = m1.iterator();
    while (iter.hasNext()) {
      iter.advance();
      if (iter.value() > 0) {
        //        if (!m2.containsKey(iter.key()) && m2.get(iter.key()) <= 0) {
        //          divergence += Double.NEGATIVE_INFINITY;
        //        } else {
        // add a small quantity to the numerator and denominator to avoid
        // infinite divergence
        divergence += iter.value()
          * Math.log((iter.value() + Constants.GetSmallConstant())
                     / (m2.get(iter.key()) + Constants.GetSmallConstant()));
        //        }
      }
    }

    return (divergence);
View Full Code Here

  }

  // Entropy(m1)
  public static double GetEntropy(TObjectDoubleHashMap m1) {
    double entropy = 0;
    TObjectDoubleIterator iter = m1.iterator();
    while (iter.hasNext()) {
      iter.advance();
      if (iter.value() > 0) {
        entropy += -1 * iter.value() * Math.log(iter.value());
      }
    }

    return (entropy);
  }
View Full Code Here

public class CollectionUtil {

  public static ArrayList<ObjectDoublePair> ReverseSortMap(TObjectDoubleHashMap m) {
    ArrayList<ObjectDoublePair> lsps = new ArrayList<ObjectDoublePair>();

    TObjectDoubleIterator mi = m.iterator();
    while (mi.hasNext()) {
      mi.advance();
      lsps.add(new ObjectDoublePair(mi.key(), mi.value()));
    }

    ObjectDoublePairComparator lspComparator = new ObjectDoublePairComparator();
    Collections.sort(lsps, lspComparator);
View Full Code Here

    return (Map2String(m, null));
  }

  public static String Map2String(TObjectDoubleHashMap m, RyanAlphabet a) {
    String retString = "";
    TObjectDoubleIterator mIter = m.iterator();
   
    ArrayList<ObjectDoublePair> sortedMap = ReverseSortMap(m);
    int n = sortedMap.size();
    for (int i = 0; i < n; ++i) {
      String label = (String) sortedMap.get(i).GetLabel();
View Full Code Here

TOP

Related Classes of gnu.trove.iterator.TObjectDoubleIterator

Copyright © 2018 www.massapicom. 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.