本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
}