當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。