Package de.lmu.ifi.dbs.elki.math.linearalgebra

Examples of de.lmu.ifi.dbs.elki.math.linearalgebra.Vector


      outStream.write("## Cluster: " + curclus.getName() + LINE_SEPARATOR);
      outStream.write("########################################################" + LINE_SEPARATOR);
      outStream.write("## Size: " + curclus.getSize() + LINE_SEPARATOR);
      if(curclus instanceof GeneratorSingleCluster) {
        GeneratorSingleCluster cursclus = (GeneratorSingleCluster) curclus;
        Vector cmin = cursclus.getClipmin();
        Vector cmax = cursclus.getClipmax();
        if(cmin != null && cmax != null) {
          outStream.write("## Clipping: " + cmin.toString() + " - " + cmax.toString() + LINE_SEPARATOR);
        }
        outStream.write("## Density correction factor: " + cursclus.getDensityCorrection() + LINE_SEPARATOR);
        outStream.write("## Generators:" + LINE_SEPARATOR);
        for(Distribution gen : cursclus.getAxes()) {
          outStream.write("##   " + gen.toString() + LINE_SEPARATOR);
View Full Code Here


   * @param y1 y-value of the first dimension
   * @param y2 y-value of the second dimension
   */
  private void updateSelectionRectKoordinates(double x1, double x2, double y1, double y2, DoubleDoublePair[] ranges) {
    BitSet actDim = proj.getVisibleDimensions2D();
    Vector v1 = new Vector(dim);
    Vector v2 = new Vector(dim);
    v1.set(0, x1);
    v1.set(1, y1);
    v2.set(0, x2);
    v2.set(1, y2);

    NV factory = DatabaseUtil.assumeVectorField(rel).getFactory();

    NV nv1 = proj.projectRenderToDataSpace(v1, factory);
    NV nv2 = proj.projectRenderToDataSpace(v2, factory);
View Full Code Here

    WritableDataStore<Vector> deltas = DataStoreUtil.makeStorage(attributes.getDBIDs(), DataStoreFactory.HINT_TEMP, Vector.class);
    for(DBID id : attributes.iterDBIDs()) {
      final O obj = attributes.get(id);
      final DBIDs neighbors = npred.getNeighborDBIDs(id);
      // Compute the median vector
      final Vector median;
      {
        double[][] data = new double[dim][neighbors.size()];
        int i = 0;
        // Load data
        for(DBID n : neighbors) {
          // TODO: skip object itself within neighbors?
          O nobj = attributes.get(n);
          for(int d = 0; d < dim; d++) {
            data[d][i] = nobj.doubleValue(d + 1);
          }
          i++;
        }
        double[] md = new double[dim];
        for(int d = 0; d < dim; d++) {
          md[d] = QuickSelect.median(data[d]);
        }
        median = new Vector(md);
      }

      // Delta vector "h"
      Vector delta = obj.getColumnVector().minus(median);
      deltas.put(id, delta);
      covmaker.put(delta);
    }
    // Finalize covariance matrix:
    Vector mean = covmaker.getMeanVector();
    Matrix cmati = covmaker.destroyToSampleMatrix().inverse();

    DoubleMinMax minmax = new DoubleMinMax();
    WritableDataStore<Double> scores = DataStoreUtil.makeStorage(attributes.getDBIDs(), DataStoreFactory.HINT_STATIC, Double.class);
    for(DBID id : attributes.iterDBIDs()) {
      Vector temp = deltas.get(id).minus(mean);
      final Vector res = temp.transposeTimes(cmati).times(temp);
      assert (res.getDimensionality() == 1);
      double score = res.get(0);
      minmax.put(score);
      scores.put(id, score);
    }

    Relation<Double> scoreResult = new MaterializedRelation<Double>("Median multiple attributes outlier", "median-outlier", TypeUtil.DOUBLE, scores, attributes.getDBIDs());
View Full Code Here

      final DBIDs ids = clus.getIDs();
      ConvexHull2D hull = new ConvexHull2D();

      for(DBID clpnum : ids) {
        double[] projP = proj.fastProjectDataToRenderSpace(rel.get(clpnum).getColumnVector());
        hull.add(new Vector(projP));
      }
      Polygon chres = hull.getHull();

      // Plot the convex hull:
      if(chres != null) {
View Full Code Here

      final int dim = proj.getDimensionality();
      DoubleMinMax minmaxx = new DoubleMinMax();
      DoubleMinMax minmaxy = new DoubleMinMax();

      // Origin
      Vector orig = new Vector(dim);
      orig = projectScaledToRender(orig);
      minmaxx.put(orig.get(0));
      minmaxy.put(orig.get(1));
      // Diagonal point
      Vector diag = new Vector(dim);
      for(int d2 = 0; d2 < dim; d2++) {
        diag.set(d2, 1);
      }
      diag = projectScaledToRender(diag);
      minmaxx.put(diag.get(0));
      minmaxy.put(diag.get(1));
      // Axis end points
      for(int d = 0; d < dim; d++) {
        Vector v = new Vector(dim);
        v.set(d, 1);
        Vector ax = projectScaledToRender(v);
        minmaxx.put(ax.get(0));
        minmaxy.put(ax.get(1));
      }
      viewport = new CanvasSize(minmaxx.getMin(), minmaxx.getMax(), minmaxy.getMin(), minmaxy.getMax());
    }
    return viewport;
  }
View Full Code Here

    // Assuming that the data was normalized on [0:1], center it:
    double[] trans = new double[dim];
    for(int i = 0; i < dim; i++) {
      trans[i] = -.5;
    }
    proj.addTranslation(new Vector(trans));
    // mirror on the y axis, since the SVG coordinate system is screen
    // coordinates (y = down) and not mathematical coordinates (y = up)
    proj.addAxisReflection(2);
    // scale it up
    proj.addScaling(SCALE);
View Full Code Here

  }

  @Override
  public double[] fastProjectDataToScaledSpace(double[] data) {
    // FIXME: implement with less objects?
    return projectDataToScaledSpace(new Vector(data)).getArrayRef();
  }
View Full Code Here

  }

  @Override
  public double[] fastProjectRelativeDataToRenderSpace(double[] data) {
    // FIXME: implement with less objects?
    return fastProjectRelativeScaledToRenderSpace(projectRelativeDataToScaledSpace(new Vector(data)).getArrayRef());
  }
View Full Code Here

  }

  @Override
  public double[] fastProjectRenderToScaledSpace(double[] v) {
    if(v.length == scales.length) {
      return projectRenderToScaled(new Vector(v)).getArrayRef();
    }
    double[] c = Arrays.copyOf(v, scales.length);
    for(int d = v.length; d < scales.length; d++) {
      c[d] = 0.5;
    }
    return projectRenderToScaled(new Vector(c)).getArrayRef();
  }
View Full Code Here

  @Override
  public BitSet getVisibleDimensions2D() {
    final int dim = proj.getDimensionality();
    BitSet actDim = new BitSet(dim);
    Vector vScale = new Vector(dim);
    for(int d = 0; d < dim; d++) {
      vScale.setZero();
      vScale.set(d, 1);
      double[] vRender = fastProjectScaledToRenderSpace(vScale.getArrayRef());

      // TODO: Can't we do this by inspecting the projection matrix directly?
      if(vRender[0] != 0.0 || vRender[1] != 0) {
        actDim.set(d);
      }
View Full Code Here

TOP

Related Classes of de.lmu.ifi.dbs.elki.math.linearalgebra.Vector

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.