Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions commons-math-legacy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
<artifactId>commons-statistics-ranking</artifactId>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-statistics-descriptive</artifactId>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-numbers-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
import org.apache.commons.math4.legacy.ml.distance.DistanceMeasure;
import org.apache.commons.math4.legacy.ml.distance.EuclideanDistance;
import org.apache.commons.math4.legacy.stat.descriptive.moment.Variance;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;

import org.apache.commons.statistics.descriptive.Variance;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -431,11 +430,11 @@ private T getPointFromLargestVarianceCluster(final Collection<CentroidCluster<T>

// compute the distance variance of the current cluster
final Clusterable center = cluster.getCenter();
final Variance stat = new Variance();
final Variance stat = Variance.create();
for (final T point : cluster.getPoints()) {
stat.increment(distance(point, center));
stat.accept(distance(point, center));
}
final double variance = stat.getResult();
final double variance = stat.getAsDouble();

// select the cluster with the largest variance
if (variance > maxVariance) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.apache.commons.math4.legacy.ml.clustering.Clusterable;
import org.apache.commons.math4.legacy.ml.clustering.ClusterEvaluator;
import org.apache.commons.math4.legacy.ml.distance.DistanceMeasure;
import org.apache.commons.math4.legacy.stat.descriptive.moment.Variance;
import org.apache.commons.statistics.descriptive.Variance;

/**
* Computes the sum of intra-cluster distance variances according to the formula:
Expand Down Expand Up @@ -56,12 +56,12 @@ public double score(List<? extends Cluster<? extends Clusterable>> clusters) {
final Clusterable center = cluster.centroid();

// compute the distance variance of the current cluster
final Variance stat = new Variance();
final Variance stat = Variance.create();
for (final Clusterable point : cluster.getPoints()) {
stat.increment(distance(point, center));
stat.accept(distance(point, center));
}

varianceSum += stat.getResult();
varianceSum += stat.getAsDouble();
}
}
return varianceSum;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.util.function.BiFunction;
import java.util.function.DoublePredicate;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.math4.legacy.stat.descriptive.moment.StandardDeviation;
import org.apache.commons.statistics.descriptive.StandardDeviation;
import org.apache.commons.math4.legacy.optim.OptimizationData;
import org.apache.commons.math4.legacy.optim.nonlinear.scalar.noderiv.Simplex;

Expand Down Expand Up @@ -164,11 +164,11 @@ static CoolingSchedule aarstAndVanLaarhoven(final double delta) {

return (previousTemperature, simplex) -> {
// Standard deviation of the values of the objective function.
final StandardDeviation stddev = new StandardDeviation();
final StandardDeviation stddev = StandardDeviation.create();
for (int i = 0; i < simplex.getSize(); i++) {
stddev.increment(simplex.get(i).getValue());
stddev.accept(simplex.get(i).getValue());
}
final double sigma = stddev.getResult();
final double sigma = stddev.getAsDouble();

final double a = previousTemperature * Math.log(1 + delta);
final double b = 3 * sigma;
Expand Down
Loading
Loading