Package de.lmu.ifi.dbs.elki.utilities.pairs

Examples of de.lmu.ifi.dbs.elki.utilities.pairs.DoubleDoublePair


      double v1 = proj.fastProjectRenderToDataSpace(z1, i);
      double v2 = proj.fastProjectRenderToDataSpace(z2, i);
      if (logger.isDebugging()) {
        logger.debug("Axis "+i+" dimension "+proj.getDimForVisibleAxis(i)+" "+v1+" to "+v2);
      }
      ranges[proj.getDimForVisibleAxis(i)] = new DoubleDoublePair(Math.min(v1, v2), Math.max(v1, v2));
    }
  }
View Full Code Here


    NV nv1 = proj.projectRenderToDataSpace(v1, factory);
    NV nv2 = proj.projectRenderToDataSpace(v2, factory);

    for(int d = actDim.nextSetBit(0); d >= 0; d = actDim.nextSetBit(d + 1)) {
      ranges[d] = new DoubleDoublePair(Math.min(nv1.doubleValue(d + 1), nv2.doubleValue(d + 1)), Math.max(nv1.doubleValue(d + 1), nv2.doubleValue(d + 1)));
    }
  }
View Full Code Here

    double[] nv1 = proj.fastProjectRenderToDataSpace(v1);
    double[] nv2 = proj.fastProjectRenderToDataSpace(v2);

    for(int d = actDim.nextSetBit(0); d >= 0; d = actDim.nextSetBit(d + 1)) {
      ranges[d] = new DoubleDoublePair(Math.min(nv1[d], nv2[d]), Math.max(nv1[d], nv2[d]));
    }
  }
View Full Code Here

    int poscnt = 0;
    int negcnt = 0;
    ArrayList<DoubleDoublePair> res = new ArrayList<DoubleDoublePair>(postot + 2);

    // start in bottom left
    res.add(new DoubleDoublePair(0.0, 0.0));

    PairInterface<C, T> prev = null;
    while(nei.hasNext()) {
      // Previous positive rate - y axis
      double curpos = ((double) poscnt) / postot;
      // Previous negative rate - x axis
      double curneg = ((double) negcnt) / negtot;

      // Analyze next point
      PairInterface<C, T> cur = nei.next();
      // positive or negative match?
      if(ids.contains(cur.getSecond())) {
        poscnt += 1;
      }
      else {
        negcnt += 1;
      }
      // defer calculation for ties
      if((prev != null) && (prev.getFirst().compareTo(cur.getFirst()) == 0)) {
        continue;
      }
      // simplify curve when possible:
      if(res.size() >= 2) {
        DoubleDoublePair last1 = res.get(res.size() - 2);
        DoubleDoublePair last2 = res.get(res.size() - 1);
        final double ldx = last2.first - last1.first;
        final double cdx = curneg - last2.first;
        final double ldy = last2.second - last1.second;
        final double cdy = curpos - last2.second;
        // vertical simplification
        if((ldx == 0) && (cdx == 0)) {
          res.remove(res.size() - 1);
        }
        // horizontal simplification
        else if((ldy == 0) && (cdy == 0)) {
          res.remove(res.size() - 1);
        }
        // diagonal simplification
        else if(ldy > 0 && cdy > 0) {
          if(Math.abs((ldx / ldy) - (cdx / cdy)) < 1E-10) {
            res.remove(res.size() - 1);
          }
        }
      }
      // Add a new point (for the previous entry!)
      res.add(new DoubleDoublePair(curneg, curpos));
      prev = cur;
    }
    // ensure we end up in the top right corner.
    // Since we didn't add a point for the last entry yet, this likely is
    // needed.
    {
      DoubleDoublePair last = res.get(res.size() - 1);
      if(last.first < 1.0 || last.second < 1.0) {
        res.add(new DoubleDoublePair(1.0, 1.0));
      }
    }
    return res;
  }
View Full Code Here

    // is no curve.
    if(!iter.hasNext()) {
      return Double.NaN;
    }
    // starting point
    DoubleDoublePair prev = iter.next();
    // check there is at least a second point
    if(!iter.hasNext()) {
      return Double.NaN;
    }
    while(iter.hasNext()) {
      DoubleDoublePair next = iter.next();
      // width * height at half way.
      double width = next.first - prev.first;
      double meanheight = (next.second + prev.second) / 2;
      result += width * meanheight;
      prev = next;
View Full Code Here

   */
  public static ReplacingHistogram<DoubleDoublePair> DoubleDoubleHistogram(int bins, double min, double max) {
    return new ReplacingHistogram<DoubleDoublePair>(bins, min, max, new Adapter<DoubleDoublePair>() {
      @Override
      public DoubleDoublePair make() {
        return new DoubleDoublePair(0.0, 0.0);
      }
    });
  }
View Full Code Here

   */
  public static FlexiHistogram<DoubleDoublePair, DoubleDoublePair> DoubleSumDoubleSumHistogram(int bins) {
    return new FlexiHistogram<DoubleDoublePair, DoubleDoublePair>(bins, new Adapter<DoubleDoublePair, DoubleDoublePair>() {
      @Override
      public DoubleDoublePair make() {
        return new DoubleDoublePair(0., 0.);
      }

      @Override
      public DoubleDoublePair cloneForCache(DoubleDoublePair data) {
        return new DoubleDoublePair(data.first, data.second);
      }

      @Override
      public DoubleDoublePair downsample(DoubleDoublePair first, DoubleDoublePair second) {
        return new DoubleDoublePair(first.first + second.first, first.second + second.second);
      }

      @Override
      public DoubleDoublePair aggregate(DoubleDoublePair existing, DoubleDoublePair data) {
        existing.first = existing.first + data.first;
View Full Code Here

    }
    else {
      hist = AggregatingHistogram.DoubleSumDoubleSumHistogram(bins, min, max);
    }
    // first fill histogram only with values of outliers
    DoubleDoublePair positive, negative;
    if(!splitfreq) {
      positive = new DoubleDoublePair(0., 1. / ids.size());
      negative = new DoubleDoublePair(1. / ids.size(), 0.);
    }
    else {
      positive = new DoubleDoublePair(0., 1. / outlierIds.size());
      negative = new DoubleDoublePair(1. / (ids.size() - outlierIds.size()), 0.);
    }
    ids.removeDBIDs(outlierIds);
    // fill histogram with values of each object
    for(DBID id : ids) {
      double result = or.getScores().get(id);
      result = scaling.getScaled(result);
      hist.aggregate(result, negative);
    }
    for(DBID id : outlierIds) {
      double result = or.getScores().get(id);
      result = scaling.getScaled(result);
      hist.aggregate(result, positive);
    }

    // turn into Collection

    Collection<DoubleVector> collHist = new ArrayList<DoubleVector>(hist.getNumBins());
    for(DoubleObjPair<DoubleDoublePair> ppair : hist) {
      DoubleDoublePair data = ppair.getSecond();
      DoubleVector row = new DoubleVector(new double[] { ppair.first, data.first, data.second });
      collHist.add(row);
    }
    return new HistogramResult<DoubleVector>("Outlier Score Histogram", "outlier-histogram", collHist);
  }
View Full Code Here

    int poscnt = 0;
    int negcnt = 0;
    ArrayList<DoubleDoublePair> res = new ArrayList<DoubleDoublePair>(postot + 2);

    // start in bottom left
    res.add(new DoubleDoublePair(0.0, 0.0));

    PairInterface<C, T> prev = null;
    while(nei.hasNext()) {
      // Previous positive rate - y axis
      double curpos = ((double) poscnt) / postot;
      // Previous negative rate - x axis
      double curneg = ((double) negcnt) / negtot;

      // Analyze next point
      PairInterface<C, T> cur = nei.next();
      // positive or negative match?
      if(ids.contains(cur.getSecond())) {
        poscnt += 1;
      }
      else {
        negcnt += 1;
      }
      // defer calculation for ties
      if((prev != null) && (prev.getFirst().compareTo(cur.getFirst()) == 0)) {
        continue;
      }
      // simplify curve when possible:
      if(res.size() >= 2) {
        DoubleDoublePair last1 = res.get(res.size() - 2);
        DoubleDoublePair last2 = res.get(res.size() - 1);
        final double ldx = last2.first - last1.first;
        final double cdx = curneg - last2.first;
        final double ldy = last2.second - last1.second;
        final double cdy = curpos - last2.second;
        // vertical simplification
        if((ldx == 0) && (cdx == 0)) {
          res.remove(res.size() - 1);
        }
        // horizontal simplification
        else if((ldy == 0) && (cdy == 0)) {
          res.remove(res.size() - 1);
        }
        // diagonal simplification
        else if(ldy > 0 && cdy > 0) {
          if(Math.abs((ldx / ldy) - (cdx / cdy)) < 1E-10) {
            res.remove(res.size() - 1);
          }
        }
      }
      // Add a new point (for the previous entry!)
      res.add(new DoubleDoublePair(curneg, curpos));
      prev = cur;
    }
    // ensure we end up in the top right corner.
    // Since we didn't add a point for the last entry yet, this likely is
    // needed.
    {
      DoubleDoublePair last = res.get(res.size() - 1);
      if(last.first < 1.0 || last.second < 1.0) {
        res.add(new DoubleDoublePair(1.0, 1.0));
      }
    }
    return res;
  }
View Full Code Here

    int poscnt = 0;
    int negcnt = 0;
    ArrayList<DoubleDoublePair> res = new ArrayList<DoubleDoublePair>(postot + 2);

    // start in bottom left
    res.add(new DoubleDoublePair(0.0, 0.0));

    PairInterface<C, DBID> prev = null;
    while(nei.hasNext()) {
      // Previous positive rate - y axis
      double curpos = ((double) poscnt) / postot;
      // Previous negative rate - x axis
      double curneg = ((double) negcnt) / negtot;

      // Analyze next point
      PairInterface<C, DBID> cur = nei.next();
      // positive or negative match?
      if(ids.contains(cur.getSecond())) {
        poscnt += 1;
      }
      else {
        negcnt += 1;
      }
      // defer calculation for ties
      if((prev != null) && (prev.getFirst().compareTo(cur.getFirst()) == 0)) {
        continue;
      }
      // simplify curve when possible:
      if(res.size() >= 2) {
        DoubleDoublePair last1 = res.get(res.size() - 2);
        DoubleDoublePair last2 = res.get(res.size() - 1);
        final double ldx = last2.first - last1.first;
        final double cdx = curneg - last2.first;
        final double ldy = last2.second - last1.second;
        final double cdy = curpos - last2.second;
        // vertical simplification
        if((ldx == 0) && (cdx == 0)) {
          res.remove(res.size() - 1);
        }
        // horizontal simplification
        else if((ldy == 0) && (cdy == 0)) {
          res.remove(res.size() - 1);
        }
        // diagonal simplification
        else if(ldy > 0 && cdy > 0) {
          if(Math.abs((ldx / ldy) - (cdx / cdy)) < 1E-10) {
            res.remove(res.size() - 1);
          }
        }
      }
      // Add a new point (for the previous entry!)
      res.add(new DoubleDoublePair(curneg, curpos));
      prev = cur;
    }
    // ensure we end up in the top right corner.
    // Since we didn't add a point for the last entry yet, this likely is
    // needed.
    {
      DoubleDoublePair last = res.get(res.size() - 1);
      if(last.first < 1.0 || last.second < 1.0) {
        res.add(new DoubleDoublePair(1.0, 1.0));
      }
    }
    return res;
  }
View Full Code Here

TOP

Related Classes of de.lmu.ifi.dbs.elki.utilities.pairs.DoubleDoublePair

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.