当前位置: 首页>>代码示例>>Java>>正文


Java NumberVector.getDimensionality方法代码示例

本文整理汇总了Java中de.lmu.ifi.dbs.elki.data.NumberVector.getDimensionality方法的典型用法代码示例。如果您正苦于以下问题:Java NumberVector.getDimensionality方法的具体用法?Java NumberVector.getDimensionality怎么用?Java NumberVector.getDimensionality使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在de.lmu.ifi.dbs.elki.data.NumberVector的用法示例。


在下文中一共展示了NumberVector.getDimensionality方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: uncenteredCorrelation

import de.lmu.ifi.dbs.elki.data.NumberVector; //导入方法依赖的package包/类
/**
 * Compute the uncentered correlation of two vectors.
 * 
 * @param x first NumberVector
 * @param y second NumberVector
 * @return the uncentered correlation coefficient for x and y
 */
public static double uncenteredCorrelation(NumberVector x, NumberVector y) {
  final int xdim = x.getDimensionality(), ydim = y.getDimensionality();
  if(xdim != ydim) {
    throw new IllegalArgumentException("Invalid arguments: number vectors differ in dimensionality.");
  }
  double sumXX = 0., sumYY = 0., sumXY = 0.;
  for(int i = 0; i < xdim; i++) {
    final double xv = x.doubleValue(i), yv = y.doubleValue(i);
    sumXX += xv * xv;
    sumYY += yv * yv;
    sumXY += xv * yv;
  }
  // One or both series were constant:
  if(!(sumXX > 0. && sumYY > 0.)) {
    return (sumXX == sumYY) ? 1. : 0.;
  }
  return sumXY / FastMath.sqrt(sumXX * sumYY);
}
 
开发者ID:elki-project,项目名称:elki,代码行数:26,代码来源:UncenteredCorrelationDistanceFunction.java

示例2: distance

import de.lmu.ifi.dbs.elki.data.NumberVector; //导入方法依赖的package包/类
@Override
public double distance(NumberVector v1, NumberVector v2) {
  final int dim1 = v1.getDimensionality(), dim2 = v2.getDimensionality();
  final int mindim = (dim1 < dim2) ? dim1 : dim2;
  double agg = 0.;
  for(int d = 0; d < mindim; d++) {
    final double xd = v1.doubleValue(d), yd = v2.doubleValue(d);
    final double div = Math.abs(xd) + Math.abs(yd);
    if(div > 0.) {
      final double v = (xd - yd) / div;
      agg += v * v;
    }
  }
  for(int d = mindim; d < dim1; d++) {
    if(v1.doubleValue(d) != 0) {
      agg += 1;
    }
  }
  for(int d = mindim; d < dim2; d++) {
    if(v2.doubleValue(d) != 0) {
      agg += 1;
    }
  }
  return FastMath.sqrt(agg / Math.max(dim1, dim2));
}
 
开发者ID:elki-project,项目名称:elki,代码行数:26,代码来源:ClarkDistanceFunction.java

示例3: distance

import de.lmu.ifi.dbs.elki.data.NumberVector; //导入方法依赖的package包/类
@Override
public double distance(final NumberVector fv1, final NumberVector fv2) {
  final int dim1 = fv1.getDimensionality(), dim2 = fv2.getDimensionality();
  final int mindim = (dim1 < dim2) ? dim1 : dim2;
  double agg = 0.;
  for(int d = 0; d < mindim; d++) {
    final double v = FastMath.sqrt(fv1.doubleValue(d)) - FastMath.sqrt(fv2.doubleValue(d));
    agg += v * v;
  }
  for(int d = mindim; d < dim1; d++) {
    agg += Math.abs(fv1.doubleValue(d));
  }
  for(int d = mindim; d < dim2; d++) {
    agg += Math.abs(fv2.doubleValue(d));
  }
  return MathUtil.SQRTHALF * FastMath.sqrt(agg);
}
 
开发者ID:elki-project,项目名称:elki,代码行数:18,代码来源:HellingerDistanceFunction.java

示例4: minDistObject

import de.lmu.ifi.dbs.elki.data.NumberVector; //导入方法依赖的package包/类
@Override
protected double minDistObject(SpatialComparable mbr, NumberVector v) {
  if(mbr.getDimensionality() != v.getDimensionality()) {
    throw new IllegalArgumentException("Different dimensionality of objects\n  " + "first argument: " + mbr.toString() + "\n  " + "second argument: " + v.toString());
  }

  double sum = 0;
  for(int d = BitsUtil.nextSetBit(dimensions, 0); d >= 0; d = BitsUtil.nextSetBit(dimensions, d + 1)) {
    final double value = v.doubleValue(d);
    final double omin = mbr.getMin(d);
    if(value < omin) {
      sum += omin - value;
    }
    else {
      final double omax = mbr.getMax(d);
      if(value > omax) {
        sum += value - omax;
      }
      else {
        continue;
      }
    }
  }
  return sum;
}
 
开发者ID:elki-project,项目名称:elki,代码行数:26,代码来源:SubspaceManhattanDistanceFunction.java

示例5: minDistObject

import de.lmu.ifi.dbs.elki.data.NumberVector; //导入方法依赖的package包/类
@Override
protected double minDistObject(SpatialComparable mbr, NumberVector v) {
  if(mbr.getDimensionality() != v.getDimensionality()) {
    throw new IllegalArgumentException("Different dimensionality of objects\n  " + "first argument: " + mbr.toString() + "\n  " + "second argument: " + v.toString());
  }

  double agg = 0.;
  for(int d = BitsUtil.nextSetBit(dimensions, 0); d >= 0; d = BitsUtil.nextSetBit(dimensions, d + 1)) {
    final double value = v.doubleValue(d);
    final double omin = mbr.getMin(d);
    final double diff1 = omin - value;
    if(diff1 > 0.) {
      if(diff1 > agg) {
        agg = diff1;
      }
    }
    else {
      final double omax = mbr.getMax(d);
      final double diff2 = value - omax;
      if(diff2 > agg) {
        agg = diff2;
      }
    }
  }
  return agg;
}
 
开发者ID:elki-project,项目名称:elki,代码行数:27,代码来源:SubspaceMaximumDistanceFunction.java

示例6: distance

import de.lmu.ifi.dbs.elki.data.NumberVector; //导入方法依赖的package包/类
@Override
public double distance(NumberVector v1, NumberVector v2) {
  final int dim1 = v1.getDimensionality(), dim2 = v2.getDimensionality();
  final int mindim = (dim1 < dim2) ? dim1 : dim2;
  double agg = preDistance(v1, v2, 0, mindim);
  if(dim1 > mindim) {
    agg += preNorm(v1, mindim, dim1);
  }
  else if(dim2 > mindim) {
    agg += preNorm(v2, mindim, dim2);
  }
  return agg;
}
 
开发者ID:elki-project,项目名称:elki,代码行数:14,代码来源:WeightedManhattanDistanceFunction.java

示例7: minDistObject

import de.lmu.ifi.dbs.elki.data.NumberVector; //导入方法依赖的package包/类
@Override
protected double minDistObject(SpatialComparable mbr, NumberVector v) {
  if(mbr.getDimensionality() != v.getDimensionality()) {
    throw new IllegalArgumentException("Different dimensionality of objects\n  " + "first argument: " + mbr.toString() + "\n  " + "second argument: " + v.toString());
  }

  double sqrDist = 0;
  for(int d = BitsUtil.nextSetBit(dimensions, 0); d >= 0; d = BitsUtil.nextSetBit(dimensions, d + 1)) {
    final double delta;
    final double value = v.doubleValue(d);
    final double omin = mbr.getMin(d);
    if(value < omin) {
      delta = omin - value;
    }
    else {
      final double omax = mbr.getMax(d);
      if(value > omax) {
        delta = value - omax;
      }
      else {
        continue;
      }
    }
    sqrDist += delta * delta;
  }
  return FastMath.sqrt(sqrDist);
}
 
开发者ID:elki-project,项目名称:elki,代码行数:28,代码来源:SubspaceEuclideanDistanceFunction.java

示例8: distance

import de.lmu.ifi.dbs.elki.data.NumberVector; //导入方法依赖的package包/类
@Override
public double distance(NumberVector v1, NumberVector v2) {
  final int dim1 = v1.getDimensionality(), dim2 = v2.getDimensionality();
  final int mindim = (dim1 < dim2) ? dim1 : dim2;
  double agg = preDistance(v1, v2, 0, mindim);
  if(dim1 > mindim) {
    agg += preNorm(v1, mindim, dim1);
  }
  else if(dim2 > mindim) {
    agg += preNorm(v2, mindim, dim2);
  }
  return FastMath.pow(agg, invp);
}
 
开发者ID:elki-project,项目名称:elki,代码行数:14,代码来源:LPNormDistanceFunction.java

示例9: similarity

import de.lmu.ifi.dbs.elki.data.NumberVector; //导入方法依赖的package包/类
@Override
public double similarity(final NumberVector o1, final NumberVector o2) {
  // TODO: accelerate sparse!
  final int dim1 = o1.getDimensionality(), dim2 = o2.getDimensionality();
  final int mindim = (dim1 < dim2) ? dim1 : dim2;
  double agg = 0.;
  for(int d = 0; d < mindim; d++) {
    agg += FastMath.sqrt(o1.doubleValue(d) * o2.doubleValue(d));
  }
  return agg;
}
 
开发者ID:elki-project,项目名称:elki,代码行数:12,代码来源:HellingerDistanceFunction.java

示例10: filter

import de.lmu.ifi.dbs.elki.data.NumberVector; //导入方法依赖的package包/类
@Override
public MultipleObjectsBundle filter(final MultipleObjectsBundle objects) {
  if(LOG.isDebuggingFinest()) {
    LOG.debugFinest("Removing records with NaN values.");
  }

  updateMeta(objects.meta());
  MultipleObjectsBundle bundle = new MultipleObjectsBundle();
  for(int j = 0; j < objects.metaLength(); j++) {
    bundle.appendColumn(objects.meta(j), new ArrayList<>());
  }
  for(int i = 0; i < objects.dataLength(); i++) {
    final Object[] row = objects.getRow(i);
    for(int j = 0; j < densecols.length; j++) {
      if(densecols[j] != null) {
        NumberVector v = (NumberVector) row[j];
        double[] ro = null; // replacement
        if(v != null) {
          for(int d = 0; d < v.getDimensionality(); d++) {
            if(Double.isNaN(v.doubleValue(d))) {
              if(ro != null) {
                ro = v.toArray();
              }
              ro[d] = dist.nextRandom();
            }
          }
        }
        row[j] = densecols[j].newNumberVector(ro);
      }
    }
    bundle.appendSimple(row);
  }
  return bundle;
}
 
开发者ID:elki-project,项目名称:elki,代码行数:35,代码来源:ReplaceNaNWithRandomFilter.java

示例11: nextEvent

import de.lmu.ifi.dbs.elki.data.NumberVector; //导入方法依赖的package包/类
@Override
public Event nextEvent() {
  while(true) {
    Event ev = source.nextEvent();
    switch(ev){
    case END_OF_STREAM:
      return ev;
    case META_CHANGED:
      updateMeta(source.getMeta());
      return ev;
    case NEXT_OBJECT:
      if(densecols == null) {
        updateMeta(source.getMeta());
      }
      boolean good = true;
      for(int j = BitsUtil.nextSetBit(densecols, 0); j >= 0; j = BitsUtil.nextSetBit(densecols, j + 1)) {
        NumberVector v = (NumberVector) source.data(j);
        if(v == null) {
          good = false;
          break;
        }
        for(int i = 0; i < v.getDimensionality(); i++) {
          if(Double.isNaN(v.doubleValue(i))) {
            good = false;
            break;
          }
        }
      }
      if(good) {
        return ev;
      }
      continue;
    }
  }
}
 
开发者ID:elki-project,项目名称:elki,代码行数:36,代码来源:DropNaNFilter.java

示例12: distance

import de.lmu.ifi.dbs.elki.data.NumberVector; //导入方法依赖的package包/类
@Override
public double distance(NumberVector v1, NumberVector v2) {
  if(dim >= v1.getDimensionality() || dim >= v2.getDimensionality() || dim < 0) {
    throw new IllegalArgumentException("Specified dimension to be considered " + "is larger that dimensionality of FeatureVectors:" + "\n  first argument: " + v1.toString() + "\n  second argument: " + v2.toString() + "\n  dimension: " + dim);
  }

  double delta = v1.doubleValue(dim) - v2.doubleValue(dim);
  return delta >= 0 ? delta : -delta;
}
 
开发者ID:elki-project,项目名称:elki,代码行数:10,代码来源:OnedimensionalDistanceFunction.java

示例13: norm

import de.lmu.ifi.dbs.elki.data.NumberVector; //导入方法依赖的package包/类
@Override
public double norm(NumberVector obj) {
  final int dim = obj.getDimensionality();
  double agg = 0.;
  for(int d = 0; d < dim; d++) {
    final double delta = obj.doubleValue(dim);
    agg += delta * delta * weights[d];
  }
  return agg;
}
 
开发者ID:elki-project,项目名称:elki,代码行数:11,代码来源:WeightedSquaredEuclideanDistanceFunction.java

示例14: distance

import de.lmu.ifi.dbs.elki.data.NumberVector; //导入方法依赖的package包/类
@Override
public double distance(NumberVector v1, NumberVector v2) {
  if(v1.getDimensionality() != v2.getDimensionality()) {
    throw new IllegalArgumentException("Different dimensionality of FeatureVectors\n  " + "first argument: " + v1 + "\n  " + "second argument: " + v2);
  }

  double agg = 0.;
  for(int d = BitsUtil.nextSetBit(dimensions, 0); d >= 0; d = BitsUtil.nextSetBit(dimensions, d + 1)) {
    double v = Math.abs(v1.doubleValue(d) - v2.doubleValue(d));
    if(v > agg) {
      agg = v;
    }
  }
  return agg;
}
 
开发者ID:elki-project,项目名称:elki,代码行数:16,代码来源:SubspaceMaximumDistanceFunction.java

示例15: derivative

import de.lmu.ifi.dbs.elki.data.NumberVector; //导入方法依赖的package包/类
/**
 * Given a NumberVector and the position of an element, approximates the
 * gradient of given element.
 * 
 * @return Derivative as double
 */
protected double derivative(int i, NumberVector v) {
  final int dim = v.getDimensionality();
  if(dim == 1) {
    return 0.;
  }
  // Adjust for boundary conditions, as per the article:
  i = (i == 0) ? 1 : (i == dim - 1) ? dim - 2 : i;
  return (v.doubleValue(i) - v.doubleValue(i - 1) + (v.doubleValue(i + 1) - v.doubleValue(i - 1)) * .5) * .5;
}
 
开发者ID:elki-project,项目名称:elki,代码行数:16,代码来源:DerivativeDTWDistanceFunction.java


注:本文中的de.lmu.ifi.dbs.elki.data.NumberVector.getDimensionality方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。