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


Java RelationUtil.computeMinMax方法代码示例

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


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

示例1: getReferencePoints

import de.lmu.ifi.dbs.elki.database.relation.RelationUtil; //导入方法依赖的package包/类
@Override
public Collection<? extends NumberVector> getReferencePoints(Relation<? extends NumberVector> db) {
  double[][] minmax = RelationUtil.computeMinMax(db);
  int dim = RelationUtil.dimensionality(db);

  // Compute mean and extend from minmax.
  double[] mean = minmax[0], delta = minmax[1];
  for(int d = 0; d < dim; d++) {
    delta[d] -= mean[d];
    mean[d] -= delta[d] * .5;
  }

  Random rand = rnd.getSingleThreadedRandom();
  ArrayList<DoubleVector> result = new ArrayList<>(samplesize);
  for(int i = 0; i < samplesize; i++) {
    double[] vec = new double[dim];
    for(int d = 0; d < dim; d++) {
      vec[d] = mean[d] + (rand.nextDouble() - 0.5) * scale * delta[d];
    }
    result.add(DoubleVector.wrap(vec));
  }

  return result;
}
 
开发者ID:elki-project,项目名称:elki,代码行数:25,代码来源:RandomGeneratedReferencePoints.java

示例2: chooseInitialMeans

import de.lmu.ifi.dbs.elki.database.relation.RelationUtil; //导入方法依赖的package包/类
@Override
public <T extends NumberVector> double[][] chooseInitialMeans(Database database, Relation<T> relation, int k, NumberVectorDistanceFunction<? super T> distanceFunction) {
  final int dim = RelationUtil.dimensionality(relation);
  double[][] minmax = RelationUtil.computeMinMax(relation);
  double[] min = minmax[0], scale = minmax[1];
  for(int d = 0; d < dim; d++) {
    scale[d] = scale[d] - min[d];
  }
  double[][] means = new double[k][];
  final Random random = rnd.getSingleThreadedRandom();
  for(int i = 0; i < k; i++) {
    double[] r = MathUtil.randomDoubleArray(dim, random);
    // Rescale
    for(int d = 0; d < dim; d++) {
      r[d] = min[d] + scale[d] * r[d];
    }
    means[i] = r;
  }
  return means;
}
 
开发者ID:elki-project,项目名称:elki,代码行数:21,代码来源:RandomlyGeneratedInitialMeans.java

示例3: run

import de.lmu.ifi.dbs.elki.database.relation.RelationUtil; //导入方法依赖的package包/类
/**
 * Add scales to a single vector relation.
 *
 * @param rel Relation
 * @return Scales
 */
private ScalesResult run(Relation<? extends NumberVector> rel) {
  double[][] mms = RelationUtil.computeMinMax(rel);
  int dim = mms[0].length;
  double delta = 0.;
  for(int d = 0; d < dim; d++) {
    double del = mms[1][d] - mms[0][d];
    delta = del > delta ? del : delta;
  }
  if(delta < Double.MIN_NORMAL) {
    delta = 1.;
  }
  int log10res = (int) Math.ceil(Math.log10(delta / (LinearScale.MAXTICKS - 1)));
  double res = MathUtil.powi(10, log10res);
  double target = Math.ceil(delta / res) * res; // Target width
  LinearScale[] scales = new LinearScale[dim];
  for(int d = 0; d < dim; d++) {
    double mid = (mms[0][d] + mms[1][d] - target) * .5;
    double min = Math.floor(mid / res) * res;
    double max = Math.ceil((mid + target) / res) * res;
    scales[d] = new LinearScale(min, max);
  }
  return new ScalesResult(scales);
}
 
开发者ID:elki-project,项目名称:elki,代码行数:30,代码来源:AddUniformScale.java

示例4: getReferencePoints

import de.lmu.ifi.dbs.elki.database.relation.RelationUtil; //导入方法依赖的package包/类
@Override
public Collection<? extends NumberVector> getReferencePoints(Relation<? extends NumberVector> db) {
  double[][] minmax = RelationUtil.computeMinMax(db);
  int dim = RelationUtil.dimensionality(db);

  // Compute mean and extend from minmax.
  double[] mean = minmax[0], delta = minmax[1];
  for(int d = 0; d < dim; d++) {
    delta[d] -= mean[d];
    mean[d] -= delta[d] * .5;
  }

  ArrayList<NumberVector> result = new ArrayList<>(2 + dim);

  double[] vec = new double[dim];
  // Use min and max
  for(int d = 0; d < dim; d++) {
    vec[d] = mean[d] - delta[d];
  }
  result.add(DoubleVector.copy(vec));
  for(int d = 0; d < dim; d++) {
    vec[d] = mean[d] + delta[d];
  }
  result.add(DoubleVector.copy(vec));

  // Plus axis end points:
  for(int i = 0; i < dim; i++) {
    for(int d = 0; d < dim; d++) {
      if(d != i) {
        vec[d] = mean[d] - delta[d];
      }
      else {
        vec[d] = mean[d] + delta[d];
      }
    }
    result.add(DoubleVector.copy(vec));
  }

  return result;
}
 
开发者ID:elki-project,项目名称:elki,代码行数:41,代码来源:AxisBasedReferencePoints.java

示例5: initializeDataExtends

import de.lmu.ifi.dbs.elki.database.relation.RelationUtil; //导入方法依赖的package包/类
/**
 * Initialize the uniform sampling area.
 *
 * @param relation Data relation
 * @param dim Dimensionality
 * @param min Minima output array (preallocated!)
 * @param extend Data extend output array (preallocated!)
 */
protected void initializeDataExtends(Relation<NumberVector> relation, int dim, double[] min, double[] extend) {
  assert (min.length == dim && extend.length == dim);
  // if no parameter for min max compute min max values for each dimension
  // from dataset
  if(minima == null || maxima == null || minima.length == 0 || maxima.length == 0) {
    double[][] minmax = RelationUtil.computeMinMax(relation);
    final double[] dmin = minmax[0], dmax = minmax[1];
    for(int d = 0; d < dim; d++) {
      min[d] = dmin[d];
      extend[d] = dmax[d] - dmin[d];
    }
    return;
  }
  if(minima.length == dim) {
    System.arraycopy(minima, 0, min, 0, dim);
  }
  else if(minima.length == 1) {
    Arrays.fill(min, minima[0]);
  }
  else {
    throw new AbortException("Invalid minima specified: expected " + dim + " got minima dimensionality: " + minima.length);
  }
  if(maxima.length == dim) {
    for(int d = 0; d < dim; d++) {
      extend[d] = maxima[d] - min[d];
    }
    return;
  }
  else if(maxima.length == 1) {
    for(int d = 0; d < dim; d++) {
      extend[d] = maxima[0] - min[d];
    }
    return;
  }
  else {
    throw new AbortException("Invalid maxima specified: expected " + dim + " got maxima dimensionality: " + maxima.length);
  }
}
 
开发者ID:elki-project,项目名称:elki,代码行数:47,代码来源:HopkinsStatisticClusteringTendency.java


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