本文整理汇总了Java中org.apache.commons.math3.stat.descriptive.moment.Variance.increment方法的典型用法代码示例。如果您正苦于以下问题:Java Variance.increment方法的具体用法?Java Variance.increment怎么用?Java Variance.increment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.stat.descriptive.moment.Variance
的用法示例。
在下文中一共展示了Variance.increment方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: score
import org.apache.commons.math3.stat.descriptive.moment.Variance; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public double score(final List<? extends Cluster<T>> clusters) {
double varianceSum = 0.0;
for (final Cluster<T> cluster : clusters) {
if (!cluster.getPoints().isEmpty()) {
final Clusterable center = centroidOf(cluster);
// compute the distance variance of the current cluster
final Variance stat = new Variance();
for (final T point : cluster.getPoints()) {
stat.increment(distance(point, center));
}
varianceSum += stat.getResult();
}
}
return varianceSum;
}
示例2: score
import org.apache.commons.math3.stat.descriptive.moment.Variance; //导入方法依赖的package包/类
@Override
public double score(final List<? extends Cluster<T>> clusters) {
double varianceSum = 0.0;
for (final Cluster<T> cluster : clusters) {
if (!cluster.getPoints().isEmpty()) {
final Clusterable center = centroidOf(cluster);
// compute the distance variance of the current cluster
final Variance stat = new Variance();
for (final T point : cluster.getPoints()) {
stat.increment(distance(point, center));
}
varianceSum += stat.getResult();
}
}
return varianceSum;
}
示例3: getPointFromLargestVarianceCluster
import org.apache.commons.math3.stat.descriptive.moment.Variance; //导入方法依赖的package包/类
/**
* Get a random point from the {@link Cluster} with the largest distance variance.
*
* @param clusters the {@link Cluster}s to search
* @return a random point from the selected cluster
* @throws ConvergenceException if clusters are all empty
*/
private T getPointFromLargestVarianceCluster(final Collection<CentroidCluster<T>> clusters)
throws ConvergenceException {
double maxVariance = Double.NEGATIVE_INFINITY;
Cluster<T> selected = null;
for (final CentroidCluster<T> cluster : clusters) {
if (!cluster.getPoints().isEmpty()) {
// compute the distance variance of the current cluster
final Clusterable center = cluster.getCenter();
final Variance stat = new Variance();
for (final T point : cluster.getPoints()) {
stat.increment(distance(point, center));
}
final double variance = stat.getResult();
// select the cluster with the largest variance
if (variance > maxVariance) {
maxVariance = variance;
selected = cluster;
}
}
}
// did we find at least one non-empty cluster ?
if (selected == null) {
throw new ConvergenceException(LocalizedFormats.EMPTY_CLUSTER_IN_K_MEANS);
}
// extract a random point from the cluster
final List<T> selectedPoints = selected.getPoints();
return selectedPoints.remove(random.nextInt(selectedPoints.size()));
}
示例4: getPointFromLargestVarianceCluster
import org.apache.commons.math3.stat.descriptive.moment.Variance; //导入方法依赖的package包/类
/**
* Get a random point from the {@link Cluster} with the largest distance variance.
*
* @param clusters the {@link Cluster}s to search
* @return a random point from the selected cluster
* @throws ConvergenceException if clusters are all empty
*/
private T getPointFromLargestVarianceCluster(final Collection<Cluster<T>> clusters)
throws ConvergenceException {
double maxVariance = Double.NEGATIVE_INFINITY;
Cluster<T> selected = null;
for (final Cluster<T> cluster : clusters) {
if (!cluster.getPoints().isEmpty()) {
// compute the distance variance of the current cluster
final T center = cluster.getCenter();
final Variance stat = new Variance();
for (final T point : cluster.getPoints()) {
stat.increment(point.distanceFrom(center));
}
final double variance = stat.getResult();
// select the cluster with the largest variance
if (variance > maxVariance) {
maxVariance = variance;
selected = cluster;
}
}
}
// did we find at least one non-empty cluster ?
if (selected == null) {
throw new ConvergenceException(LocalizedFormats.EMPTY_CLUSTER_IN_K_MEANS);
}
// extract a random point from the cluster
final List<T> selectedPoints = selected.getPoints();
return selectedPoints.remove(random.nextInt(selectedPoints.size()));
}
示例5: getPointFromLargestVarianceCluster
import org.apache.commons.math3.stat.descriptive.moment.Variance; //导入方法依赖的package包/类
/**
* Get a random point from the {@link Cluster} with the largest distance variance.
*
* @param clusters the {@link Cluster}s to search
* @return a random point from the selected cluster
* @throws ConvergenceException if clusters are all empty
*/
private T getPointFromLargestVarianceCluster(final Collection<CentroidCluster<T>> clusters)
throws ConvergenceException {
double maxVariance = Double.NEGATIVE_INFINITY;
Cluster<T> selected = null;
for (final CentroidCluster<T> cluster : clusters) {
if (!cluster.getPoints().isEmpty()) {
// compute the distance variance of the current cluster
final Clusterable center = cluster.getCenter();
final Variance stat = new Variance();
for (final T point : cluster.getPoints()) {
stat.increment(point.getWeight() * distance(point, center));
}
final double variance = stat.getResult();
// select the cluster with the largest variance
if (variance > maxVariance) {
maxVariance = variance;
selected = cluster;
}
}
}
// did we find at least one non-empty cluster ?
if (selected == null) {
throw new ConvergenceException(LocalizedFormats.EMPTY_CLUSTER_IN_K_MEANS);
}
// extract a random point from the cluster
final List<T> selectedPoints = selected.getPoints();
return selectedPoints.remove(random.nextInt(selectedPoints.size()));
}
示例6: getPointFromLargestVarianceCluster
import org.apache.commons.math3.stat.descriptive.moment.Variance; //导入方法依赖的package包/类
/**
* Get a random point from the {@link Cluster} with the largest distance variance.
*
* @param clusters the {@link Cluster}s to search
* @return a random point from the selected cluster
*/
private T getPointFromLargestVarianceCluster(final Collection<Cluster<T>> clusters) {
double maxVariance = Double.NEGATIVE_INFINITY;
Cluster<T> selected = null;
for (final Cluster<T> cluster : clusters) {
if (!cluster.getPoints().isEmpty()) {
// compute the distance variance of the current cluster
final T center = cluster.getCenter();
final Variance stat = new Variance();
for (final T point : cluster.getPoints()) {
stat.increment(point.distanceFrom(center));
}
final double variance = stat.getResult();
// select the cluster with the largest variance
if (variance > maxVariance) {
maxVariance = variance;
selected = cluster;
}
}
}
// did we find at least one non-empty cluster ?
if (selected == null) {
throw new ConvergenceException(LocalizedFormats.EMPTY_CLUSTER_IN_K_MEANS);
}
// extract a random point from the cluster
final List<T> selectedPoints = selected.getPoints();
return selectedPoints.remove(random.nextInt(selectedPoints.size()));
}