Examples of TObjectDoubleIterator


Examples of gnu.trove.iterator.TObjectDoubleIterator

  public static void AddScores(TObjectDoubleHashMap result, double mult,
                               TObjectDoubleHashMap addDist) {
    assert (result != null);
    assert (addDist != null);

    TObjectDoubleIterator iter = addDist.iterator();
    while (iter.hasNext()) {
      iter.advance();
      double adjVal = mult * iter.value();
     
      //      System.out.println(">> adjVal: " + mult + " " + iter.key() + " " + iter.value() + " " + adjVal);
      result.adjustOrPutValue(iter.key(), adjVal, adjVal);
    }
  }
View Full Code Here

Examples of gnu.trove.iterator.TObjectDoubleIterator

  public static void DivScores(TObjectDoubleHashMap result, double divisor) {
    assert (result != null);
    assert (divisor > 0);

    TObjectDoubleIterator li = result.iterator();
    while (li.hasNext()) {
      li.advance();
      // System.out.println("Before: " + " " + li.key() + " " + li.value() + " " + divisor);
      double newVal = (1.0 * li.value()) / divisor;
      result.put(li.key(), newVal);
      // System.out.println("After: " + " " + li.key() + " " + result.get(li.key()) + " " + divisor);
    }
  }
View Full Code Here

Examples of gnu.trove.iterator.TObjectDoubleIterator

    // default value, then keep the top scoring k labels as requested
    if (keepTopK != Integer.MAX_VALUE) {
      KeepTopScoringKeys(m, keepTopK);
    }

    TObjectDoubleIterator mi = m.iterator();
    double denom = 0;
    while (mi.hasNext()) {
      mi.advance();
      denom += mi.value();
    }
    // assert (denom > 0);

    if (denom > 0) {
      mi = m.iterator();
      while (mi.hasNext()) {
        mi.advance();
        double newVal = mi.value() / denom;
        mi.setValue(newVal);
      }
    }
  }
View Full Code Here

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

Examples of gnu.trove.iterator.TObjectDoubleIterator

      }
    }
  }

  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

Examples of gnu.trove.iterator.TObjectDoubleIterator

             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

Examples of gnu.trove.iterator.TObjectDoubleIterator

  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

Examples of gnu.trove.iterator.TObjectDoubleIterator

  // 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

Examples of gnu.trove.iterator.TObjectDoubleIterator

  }

  // 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

Examples of gnu.trove.iterator.TObjectDoubleIterator

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
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.