Replaced Raw types by Parameterized types where appropriate.
The various ArrayList, HashSet and HashMap used in math have be restricted to the content they are intended for. This removes lots of warnings that have appeared after the switch to Java 5, and improves safety (for example the categories used by OneWayAnova are guaranteed to be double arrays at compile time). Two difficult cases where not handled here: the Frequency class and the Fitness interface. The first one mixes types and needs to be studied before any change is attempted. The second one generates some side effects on the overall package which is still under development. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/branches/MATH_2_0@657612 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f8b2fa71fb
commit
4e50bbcb90
|
@ -18,7 +18,6 @@
|
|||
package org.apache.commons.math.estimation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -46,8 +45,8 @@ public class SimpleEstimationProblem implements EstimationProblem {
|
|||
* Build an empty instance without parameters nor measurements.
|
||||
*/
|
||||
public SimpleEstimationProblem() {
|
||||
parameters = new ArrayList();
|
||||
measurements = new ArrayList();
|
||||
parameters = new ArrayList<EstimatedParameter>();
|
||||
measurements = new ArrayList<WeightedMeasurement>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,9 +64,8 @@ public class SimpleEstimationProblem implements EstimationProblem {
|
|||
public EstimatedParameter[] getUnboundParameters() {
|
||||
|
||||
// filter the unbound parameters
|
||||
List unbound = new ArrayList(parameters.size());
|
||||
for (Iterator iterator = parameters.iterator(); iterator.hasNext();) {
|
||||
EstimatedParameter p = (EstimatedParameter) iterator.next();
|
||||
List<EstimatedParameter> unbound = new ArrayList<EstimatedParameter>(parameters.size());
|
||||
for (EstimatedParameter p : parameters) {
|
||||
if (! p.isBound()) {
|
||||
unbound.add(p);
|
||||
}
|
||||
|
@ -102,9 +100,9 @@ public class SimpleEstimationProblem implements EstimationProblem {
|
|||
}
|
||||
|
||||
/** Estimated parameters. */
|
||||
private final List parameters;
|
||||
private final List<EstimatedParameter> parameters;
|
||||
|
||||
/** Measurements. */
|
||||
private final List measurements;
|
||||
private final List<WeightedMeasurement> measurements;
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.apache.commons.math.util.MathUtils;
|
|||
* @since 1.1
|
||||
* @version $Revision$ $Date$
|
||||
*/
|
||||
public class Fraction extends Number implements Comparable {
|
||||
public class Fraction extends Number implements Comparable<Fraction> {
|
||||
|
||||
/** A fraction representing "1 / 1". */
|
||||
public static final Fraction ONE = new Fraction(1, 1);
|
||||
|
@ -34,7 +34,7 @@ public class Fraction extends Number implements Comparable {
|
|||
public static final Fraction ZERO = new Fraction(0, 1);
|
||||
|
||||
/** Serializable version identifier */
|
||||
private static final long serialVersionUID = -8958519416450949235L;
|
||||
private static final long serialVersionUID = -5731055832688548463L;
|
||||
|
||||
/** The denominator. */
|
||||
private final int denominator;
|
||||
|
@ -246,13 +246,12 @@ public class Fraction extends Number implements Comparable {
|
|||
* @return -1 if this is less than <tt>object</tt>, +1 if this is greater
|
||||
* than <tt>object</tt>, 0 if they are equal.
|
||||
*/
|
||||
public int compareTo(Object object) {
|
||||
public int compareTo(Fraction object) {
|
||||
int ret = 0;
|
||||
|
||||
if (this != object) {
|
||||
Fraction other = (Fraction)object;
|
||||
double first = doubleValue();
|
||||
double second = other.doubleValue();
|
||||
double second = object.doubleValue();
|
||||
|
||||
if (first < second) {
|
||||
ret = -1;
|
||||
|
|
|
@ -163,7 +163,7 @@ public abstract class AdaptiveStepsizeIntegrator
|
|||
double maxCheckInterval,
|
||||
double convergence,
|
||||
int maxIterationCount) {
|
||||
switchesHandler.add(function, maxCheckInterval, convergence, maxIterationCount);
|
||||
switchesHandler.addSwitchingFunction(function, maxCheckInterval, convergence, maxIterationCount);
|
||||
}
|
||||
|
||||
/** Get all the switching functions that have been added to the integrator.
|
||||
|
@ -171,7 +171,7 @@ public abstract class AdaptiveStepsizeIntegrator
|
|||
* @see #addSwitchingFunction(SwitchingFunction, double, double, int)
|
||||
* @see #clearSwitchingFunctions()
|
||||
*/
|
||||
public Collection getSwitchingFunctions() {
|
||||
public Collection<SwitchState> getSwitchingFunctions() {
|
||||
return switchesHandler.getSwitchingFunctions();
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
package org.apache.commons.math.ode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
@ -45,14 +44,14 @@ import java.io.Serializable;
|
|||
* get the model value at any time or to navigate through the
|
||||
* data).</p>
|
||||
*
|
||||
* <p>If problem modelization is done with several separate
|
||||
* <p>If problem modeling is done with several separate
|
||||
* integration phases for contiguous intervals, the same
|
||||
* ContinuousOutputModel can be used as step handler for all
|
||||
* integration phases as long as they are performed in order and in
|
||||
* the same direction. As an example, one can extrapolate the
|
||||
* trajectory of a satellite with one model (i.e. one set of
|
||||
* differential equations) up to the beginning of a maneuver, use
|
||||
* another more complex model including thrusters modelization and
|
||||
* another more complex model including thrusters modeling and
|
||||
* accurate attitude control during the maneuver, and revert to the
|
||||
* first model after the end of the maneuver. If the same continuous
|
||||
* output model handles the steps of all integration phases, the user
|
||||
|
@ -86,7 +85,7 @@ public class ContinuousOutputModel
|
|||
* Build an empty continuous output model.
|
||||
*/
|
||||
public ContinuousOutputModel() {
|
||||
steps = new ArrayList();
|
||||
steps = new ArrayList<StepInterpolator>();
|
||||
reset();
|
||||
}
|
||||
|
||||
|
@ -129,8 +128,8 @@ public class ContinuousOutputModel
|
|||
|
||||
}
|
||||
|
||||
for (Iterator iter = model.steps.iterator(); iter.hasNext(); ) {
|
||||
steps.add(((AbstractStepInterpolator) iter.next()).copy());
|
||||
for (StepInterpolator interpolator : model.steps) {
|
||||
steps.add(interpolator.copy());
|
||||
}
|
||||
|
||||
index = steps.size() - 1;
|
||||
|
@ -171,17 +170,15 @@ public class ContinuousOutputModel
|
|||
public void handleStep(StepInterpolator interpolator, boolean isLast)
|
||||
throws DerivativeException {
|
||||
|
||||
AbstractStepInterpolator ai = (AbstractStepInterpolator) interpolator;
|
||||
|
||||
if (steps.size() == 0) {
|
||||
initialTime = interpolator.getPreviousTime();
|
||||
forward = interpolator.isForward();
|
||||
}
|
||||
|
||||
steps.add(ai.copy());
|
||||
steps.add(interpolator.copy());
|
||||
|
||||
if (isLast) {
|
||||
finalTime = ai.getCurrentTime();
|
||||
finalTime = interpolator.getCurrentTime();
|
||||
index = steps.size() - 1;
|
||||
}
|
||||
|
||||
|
@ -210,7 +207,7 @@ public class ContinuousOutputModel
|
|||
* @return interpolation point time
|
||||
*/
|
||||
public double getInterpolatedTime() {
|
||||
return ((StepInterpolator) steps.get(index)).getInterpolatedTime();
|
||||
return steps.get(index).getInterpolatedTime();
|
||||
}
|
||||
|
||||
/** Set the time of the interpolated point.
|
||||
|
@ -230,11 +227,11 @@ public class ContinuousOutputModel
|
|||
try {
|
||||
// initialize the search with the complete steps table
|
||||
int iMin = 0;
|
||||
StepInterpolator sMin = (StepInterpolator) steps.get(iMin);
|
||||
StepInterpolator sMin = steps.get(iMin);
|
||||
double tMin = 0.5 * (sMin.getPreviousTime() + sMin.getCurrentTime());
|
||||
|
||||
int iMax = steps.size() - 1;
|
||||
StepInterpolator sMax = (StepInterpolator) steps.get(iMax);
|
||||
StepInterpolator sMax = steps.get(iMax);
|
||||
double tMax = 0.5 * (sMax.getPreviousTime() + sMax.getCurrentTime());
|
||||
|
||||
// handle points outside of the integration interval
|
||||
|
@ -254,7 +251,7 @@ public class ContinuousOutputModel
|
|||
while (iMax - iMin > 5) {
|
||||
|
||||
// use the last estimated index as the splitting index
|
||||
StepInterpolator si = (StepInterpolator) steps.get(index);
|
||||
StepInterpolator si = steps.get(index);
|
||||
int location = locatePoint(time, si);
|
||||
if (location < 0) {
|
||||
iMax = index;
|
||||
|
@ -270,7 +267,7 @@ public class ContinuousOutputModel
|
|||
|
||||
// compute a new estimate of the index in the reduced table slice
|
||||
int iMed = (iMin + iMax) / 2;
|
||||
StepInterpolator sMed = (StepInterpolator) steps.get(iMed);
|
||||
StepInterpolator sMed = steps.get(iMed);
|
||||
double tMed = 0.5 * (sMed.getPreviousTime() + sMed.getCurrentTime());
|
||||
|
||||
if ((Math.abs(tMed - tMin) < 1e-6) || (Math.abs(tMax - tMed) < 1e-6)) {
|
||||
|
@ -306,14 +303,11 @@ public class ContinuousOutputModel
|
|||
|
||||
// now the table slice is very small, we perform an iterative search
|
||||
index = iMin;
|
||||
while ((index <= iMax) &&
|
||||
(locatePoint(time, (StepInterpolator) steps.get(index)) > 0)) {
|
||||
while ((index <= iMax) && (locatePoint(time, steps.get(index)) > 0)) {
|
||||
++index;
|
||||
}
|
||||
|
||||
StepInterpolator si = (StepInterpolator) steps.get(index);
|
||||
|
||||
si.setInterpolatedTime(time);
|
||||
steps.get(index).setInterpolatedTime(time);
|
||||
|
||||
} catch (DerivativeException de) {
|
||||
throw new RuntimeException("unexpected DerivativeException caught: " +
|
||||
|
@ -327,7 +321,7 @@ public class ContinuousOutputModel
|
|||
* @return state vector at time {@link #getInterpolatedTime}
|
||||
*/
|
||||
public double[] getInterpolatedState() {
|
||||
return ((StepInterpolator) steps.get(index)).getInterpolatedState();
|
||||
return steps.get(index).getInterpolatedState();
|
||||
}
|
||||
|
||||
/** Compare a step interval and a double.
|
||||
|
@ -369,9 +363,9 @@ public class ContinuousOutputModel
|
|||
private int index;
|
||||
|
||||
/** Steps table. */
|
||||
private List steps;
|
||||
private List<StepInterpolator> steps;
|
||||
|
||||
/** Serializable version identifier */
|
||||
private static final long serialVersionUID = 2259286184268533249L;
|
||||
private static final long serialVersionUID = -1417964919405031606L;
|
||||
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public interface FirstOrderIntegrator {
|
|||
* @see #addSwitchingFunction(SwitchingFunction, double, double, int)
|
||||
* @see #clearSwitchingFunctions()
|
||||
*/
|
||||
public Collection getSwitchingFunctions();
|
||||
public Collection<SwitchState> getSwitchingFunctions();
|
||||
|
||||
/** Remove all the switching functions that have been added to the integrator.
|
||||
* @see #addSwitchingFunction(SwitchingFunction, double, double, int)
|
||||
|
|
|
@ -105,7 +105,7 @@ public abstract class RungeKuttaIntegrator
|
|||
double maxCheckInterval,
|
||||
double convergence,
|
||||
int maxIterationCount) {
|
||||
switchesHandler.add(function, maxCheckInterval, convergence, maxIterationCount);
|
||||
switchesHandler.addSwitchingFunction(function, maxCheckInterval, convergence, maxIterationCount);
|
||||
}
|
||||
|
||||
/** Get all the switching functions that have been added to the integrator.
|
||||
|
@ -113,7 +113,7 @@ public abstract class RungeKuttaIntegrator
|
|||
* @see #addSwitchingFunction(SwitchingFunction, double, double, int)
|
||||
* @see #clearSwitchingFunctions()
|
||||
*/
|
||||
public Collection getSwitchingFunctions() {
|
||||
public Collection<SwitchState> getSwitchingFunctions() {
|
||||
return switchesHandler.getSwitchingFunctions();
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.apache.commons.math.ode;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.math.ConvergenceException;
|
||||
|
@ -39,7 +38,7 @@ public class SwitchingFunctionsHandler {
|
|||
* Create an empty handler
|
||||
*/
|
||||
public SwitchingFunctionsHandler() {
|
||||
functions = new ArrayList();
|
||||
functions = new ArrayList<SwitchState>();
|
||||
first = null;
|
||||
initialized = false;
|
||||
}
|
||||
|
@ -55,23 +54,23 @@ public class SwitchingFunctionsHandler {
|
|||
* @see #getSwitchingFunctions()
|
||||
* @see #clearSwitchingFunctions()
|
||||
*/
|
||||
public void add(SwitchingFunction function, double maxCheckInterval,
|
||||
double convergence, int maxIterationCount) {
|
||||
public void addSwitchingFunction(SwitchingFunction function, double maxCheckInterval,
|
||||
double convergence, int maxIterationCount) {
|
||||
functions.add(new SwitchState(function, maxCheckInterval,
|
||||
convergence, maxIterationCount));
|
||||
}
|
||||
|
||||
/** Get all the switching functions that have been added to the handler.
|
||||
* @return an unmodifiable collection of the added switching functions
|
||||
* @see #add(SwitchingFunction, double, double, int)
|
||||
* @see #addSwitchingFunction(SwitchingFunction, double, double, int)
|
||||
* @see #clearSwitchingFunctions()
|
||||
*/
|
||||
public Collection getSwitchingFunctions() {
|
||||
public Collection<SwitchState> getSwitchingFunctions() {
|
||||
return Collections.unmodifiableCollection(functions);
|
||||
}
|
||||
|
||||
/** Remove all the switching functions that have been added to the handler.
|
||||
* @see #add(SwitchingFunction, double, double, int)
|
||||
* @see #addSwitchingFunction(SwitchingFunction, double, double, int)
|
||||
* @see #getSwitchingFunctions()
|
||||
*/
|
||||
public void clearSwitchingFunctions() {
|
||||
|
@ -114,8 +113,8 @@ public class SwitchingFunctionsHandler {
|
|||
double t0 = interpolator.getPreviousTime();
|
||||
interpolator.setInterpolatedTime(t0);
|
||||
double [] y = interpolator.getInterpolatedState();
|
||||
for (Iterator iter = functions.iterator(); iter.hasNext();) {
|
||||
((SwitchState) iter.next()).reinitializeBegin(t0, y);
|
||||
for (SwitchState state : functions) {
|
||||
state.reinitializeBegin(t0, y);
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
|
@ -123,9 +122,8 @@ public class SwitchingFunctionsHandler {
|
|||
}
|
||||
|
||||
// check events occurrence
|
||||
for (Iterator iter = functions.iterator(); iter.hasNext();) {
|
||||
for (SwitchState state : functions) {
|
||||
|
||||
SwitchState state = (SwitchState) iter.next();
|
||||
if (state.evaluateStep(interpolator)) {
|
||||
if (first == null) {
|
||||
first = state;
|
||||
|
@ -176,8 +174,8 @@ public class SwitchingFunctionsHandler {
|
|||
public void stepAccepted(double t, double[] y)
|
||||
throws IntegratorException {
|
||||
try {
|
||||
for (Iterator iter = functions.iterator(); iter.hasNext();) {
|
||||
((SwitchState) iter.next()).stepAccepted(t, y);
|
||||
for (SwitchState state : functions) {
|
||||
state.stepAccepted(t, y);
|
||||
}
|
||||
} catch (SwitchException se) {
|
||||
throw new IntegratorException(se);
|
||||
|
@ -189,8 +187,8 @@ public class SwitchingFunctionsHandler {
|
|||
* @return true if the integration should be stopped
|
||||
*/
|
||||
public boolean stop() {
|
||||
for (Iterator iter = functions.iterator(); iter.hasNext();) {
|
||||
if (((SwitchState) iter.next()).stop()) {
|
||||
for (SwitchState state : functions) {
|
||||
if (state.stop()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -209,8 +207,8 @@ public class SwitchingFunctionsHandler {
|
|||
public boolean reset(double t, double[] y) throws IntegratorException {
|
||||
try {
|
||||
boolean resetDerivatives = false;
|
||||
for (Iterator iter = functions.iterator(); iter.hasNext();) {
|
||||
if (((SwitchState) iter.next()).reset(t, y)) {
|
||||
for (SwitchState state : functions) {
|
||||
if (state.reset(t, y)) {
|
||||
resetDerivatives = true;
|
||||
}
|
||||
}
|
||||
|
@ -221,7 +219,7 @@ public class SwitchingFunctionsHandler {
|
|||
}
|
||||
|
||||
/** Switching functions. */
|
||||
private List functions;
|
||||
private List<SwitchState> functions;
|
||||
|
||||
/** First active switching function. */
|
||||
private SwitchState first;
|
||||
|
|
|
@ -571,16 +571,15 @@ public abstract class DirectSearchOptimizer {
|
|||
}
|
||||
|
||||
/** Comparator for {@link PointCostPair PointCostPair} objects. */
|
||||
private static Comparator pointCostPairComparator = new Comparator() {
|
||||
public int compare(Object o1, Object o2) {
|
||||
private static Comparator<PointCostPair> pointCostPairComparator =
|
||||
new Comparator<PointCostPair>() {
|
||||
public int compare(PointCostPair o1, PointCostPair o2) {
|
||||
if (o1 == null) {
|
||||
return (o2 == null) ? 0 : +1;
|
||||
} else if (o2 == null) {
|
||||
return -1;
|
||||
}
|
||||
double cost1 = ((PointCostPair) o1).getCost();
|
||||
double cost2 = ((PointCostPair) o2).getCost();
|
||||
return (cost1 < cost2) ? -1 : ((o1 == o2) ? 0 : +1);
|
||||
return (o1.getCost() < o2.getCost()) ? -1 : ((o1 == o2) ? 0 : +1);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.net.URL;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.commons.math.stat.descriptive.StatisticalSummary;
|
||||
import org.apache.commons.math.stat.descriptive.SummaryStatistics;
|
||||
|
||||
/**
|
||||
* Represents an <a href="http://random.mat.sbg.ac.at/~ste/dipl/node11.html">
|
||||
|
@ -118,7 +119,7 @@ public interface EmpiricalDistribution {
|
|||
*
|
||||
* @return List of bin statistics
|
||||
*/
|
||||
List getBinStats();
|
||||
List<SummaryStatistics> getBinStats();
|
||||
|
||||
/**
|
||||
* Returns the array of upper bounds for the bins. Bins are: <br/>
|
||||
|
|
|
@ -61,10 +61,10 @@ import org.apache.commons.math.stat.descriptive.StatisticalSummary;
|
|||
public class EmpiricalDistributionImpl implements Serializable, EmpiricalDistribution {
|
||||
|
||||
/** Serializable version identifier */
|
||||
private static final long serialVersionUID = -6773236347582113490L;
|
||||
private static final long serialVersionUID = 5729073523949762654L;
|
||||
|
||||
/** List of SummaryStatistics objects characterizing the bins */
|
||||
private List binStats = null;
|
||||
private List<SummaryStatistics> binStats = null;
|
||||
|
||||
/** Sample statistics */
|
||||
private SummaryStatistics sampleStats = null;
|
||||
|
@ -85,7 +85,7 @@ public class EmpiricalDistributionImpl implements Serializable, EmpiricalDistrib
|
|||
* Creates a new EmpiricalDistribution with the default bin count.
|
||||
*/
|
||||
public EmpiricalDistributionImpl() {
|
||||
binStats = new ArrayList();
|
||||
binStats = new ArrayList<SummaryStatistics>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -95,7 +95,7 @@ public class EmpiricalDistributionImpl implements Serializable, EmpiricalDistrib
|
|||
*/
|
||||
public EmpiricalDistributionImpl(int binCount) {
|
||||
this.binCount = binCount;
|
||||
binStats = new ArrayList();
|
||||
binStats = new ArrayList<SummaryStatistics>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -254,8 +254,7 @@ public class EmpiricalDistributionImpl implements Serializable, EmpiricalDistrib
|
|||
double val = 0.0d;
|
||||
while ((str = inputStream.readLine()) != null) {
|
||||
val = Double.parseDouble(str);
|
||||
SummaryStatistics stats =
|
||||
(SummaryStatistics) binStats.get(findBin(min, val, delta));
|
||||
SummaryStatistics stats = binStats.get(findBin(min, val, delta));
|
||||
stats.addValue(val);
|
||||
}
|
||||
|
||||
|
@ -319,8 +318,7 @@ public class EmpiricalDistributionImpl implements Serializable, EmpiricalDistrib
|
|||
throws IOException {
|
||||
for (int i = 0; i < inputArray.length; i++) {
|
||||
SummaryStatistics stats =
|
||||
(SummaryStatistics) binStats.get(
|
||||
findBin(min, inputArray[i], delta));
|
||||
binStats.get(findBin(min, inputArray[i], delta));
|
||||
stats.addValue(inputArray[i]);
|
||||
}
|
||||
}
|
||||
|
@ -369,12 +367,10 @@ public class EmpiricalDistributionImpl implements Serializable, EmpiricalDistrib
|
|||
// Assign upperBounds based on bin counts
|
||||
upperBounds = new double[binCount];
|
||||
upperBounds[0] =
|
||||
((double)((SummaryStatistics)binStats.get(0)).getN())/
|
||||
(double)sampleStats.getN();
|
||||
((double) binStats.get(0).getN()) / (double) sampleStats.getN();
|
||||
for (int i = 1; i < binCount-1; i++) {
|
||||
upperBounds[i] = upperBounds[i-1] +
|
||||
((double)((SummaryStatistics)binStats.get(i)).getN())/
|
||||
(double)sampleStats.getN();
|
||||
((double) binStats.get(i).getN()) / (double) sampleStats.getN();
|
||||
}
|
||||
upperBounds[binCount-1] = 1.0d;
|
||||
}
|
||||
|
@ -411,7 +407,7 @@ public class EmpiricalDistributionImpl implements Serializable, EmpiricalDistrib
|
|||
// Use this to select the bin and generate a Gaussian within the bin
|
||||
for (int i = 0; i < binCount; i++) {
|
||||
if (x <= upperBounds[i]) {
|
||||
SummaryStatistics stats = (SummaryStatistics)binStats.get(i);
|
||||
SummaryStatistics stats = binStats.get(i);
|
||||
if (stats.getN() > 0) {
|
||||
if (stats.getStandardDeviation() > 0) { // more than one obs
|
||||
return randomData.nextGaussian
|
||||
|
@ -453,7 +449,7 @@ public class EmpiricalDistributionImpl implements Serializable, EmpiricalDistrib
|
|||
*
|
||||
* @return List of bin statistics.
|
||||
*/
|
||||
public List getBinStats() {
|
||||
public List<SummaryStatistics> getBinStats() {
|
||||
return binStats;
|
||||
}
|
||||
|
||||
|
|
|
@ -268,5 +268,5 @@ public interface RandomData {
|
|||
* @param k size of the sample
|
||||
* @return random sample of k elements from c
|
||||
*/
|
||||
Object[] nextSample(Collection c, int k);
|
||||
Object[] nextSample(Collection<?> c, int k);
|
||||
}
|
||||
|
|
|
@ -545,7 +545,7 @@ public class RandomDataImpl implements RandomData, Serializable {
|
|||
* @param k sample size.
|
||||
* @return the random sample.
|
||||
*/
|
||||
public Object[] nextSample(Collection c, int k) {
|
||||
public Object[] nextSample(Collection<?> c, int k) {
|
||||
int len = c.size();
|
||||
if (k > len) {
|
||||
throw new IllegalArgumentException
|
||||
|
|
|
@ -50,7 +50,7 @@ public interface OneWayAnova {
|
|||
* @throws MathException if the statistic can not be computed do to a
|
||||
* convergence or other numerical error.
|
||||
*/
|
||||
public double anovaFValue(Collection categoryData)
|
||||
public double anovaFValue(Collection<double[]> categoryData)
|
||||
throws IllegalArgumentException, MathException;
|
||||
|
||||
/**
|
||||
|
@ -71,7 +71,7 @@ public interface OneWayAnova {
|
|||
* @throws MathException if the statistic can not be computed do to a
|
||||
* convergence or other numerical error.
|
||||
*/
|
||||
public double anovaPValue(Collection categoryData)
|
||||
public double anovaPValue(Collection<double[]> categoryData)
|
||||
throws IllegalArgumentException, MathException;
|
||||
|
||||
/**
|
||||
|
@ -96,7 +96,7 @@ public interface OneWayAnova {
|
|||
* @throws MathException if the statistic can not be computed do to a
|
||||
* convergence or other numerical error.
|
||||
*/
|
||||
public boolean anovaTest(Collection categoryData, double alpha)
|
||||
public boolean anovaTest(Collection<double[]> categoryData, double alpha)
|
||||
throws IllegalArgumentException, MathException;
|
||||
|
||||
}
|
|
@ -16,15 +16,13 @@
|
|||
*/
|
||||
package org.apache.commons.math.stat.inference;
|
||||
|
||||
import org.apache.commons.math.MathException;
|
||||
import org.apache.commons.math.stat.descriptive.summary.Sum;
|
||||
import org.apache.commons.math.stat.descriptive.summary.SumOfSquares;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.commons.math.MathException;
|
||||
import org.apache.commons.math.distribution.FDistribution;
|
||||
import org.apache.commons.math.distribution.FDistributionImpl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import org.apache.commons.math.stat.descriptive.summary.Sum;
|
||||
import org.apache.commons.math.stat.descriptive.summary.SumOfSquares;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -65,7 +63,7 @@ public class OneWayAnovaImpl implements OneWayAnova {
|
|||
* are as defined <a href="http://faculty.vassar.edu/lowry/ch13pt1.html">
|
||||
* here</a></p>
|
||||
*/
|
||||
public double anovaFValue(Collection categoryData)
|
||||
public double anovaFValue(Collection<double[]> categoryData)
|
||||
throws IllegalArgumentException, MathException {
|
||||
AnovaStats a = anovaStats(categoryData);
|
||||
return a.F;
|
||||
|
@ -81,7 +79,7 @@ public class OneWayAnovaImpl implements OneWayAnova {
|
|||
* where <code>F</code> is the F value and <code>cumulativeProbability</code>
|
||||
* is the commons-math implementation of the F distribution.</p>
|
||||
*/
|
||||
public double anovaPValue(Collection categoryData)
|
||||
public double anovaPValue(Collection<double[]> categoryData)
|
||||
throws IllegalArgumentException, MathException {
|
||||
AnovaStats a = anovaStats(categoryData);
|
||||
FDistribution fdist = new FDistributionImpl(a.dfbg, a.dfwg);
|
||||
|
@ -99,7 +97,7 @@ public class OneWayAnovaImpl implements OneWayAnova {
|
|||
* is the commons-math implementation of the F distribution.</p>
|
||||
* <p>True is returned iff the estimated p-value is less than alpha.</p>
|
||||
*/
|
||||
public boolean anovaTest(Collection categoryData, double alpha)
|
||||
public boolean anovaTest(Collection<double[]> categoryData, double alpha)
|
||||
throws IllegalArgumentException, MathException {
|
||||
if ((alpha <= 0) || (alpha > 0.5)) {
|
||||
throw new IllegalArgumentException("bad significance level: " + alpha);
|
||||
|
@ -118,7 +116,7 @@ public class OneWayAnovaImpl implements OneWayAnova {
|
|||
* preconditions specified in the interface definition
|
||||
* @throws MathException if an error occurs computing the Anova stats
|
||||
*/
|
||||
private AnovaStats anovaStats(Collection categoryData)
|
||||
private AnovaStats anovaStats(Collection<double[]> categoryData)
|
||||
throws IllegalArgumentException, MathException {
|
||||
|
||||
// check if we have enough categories
|
||||
|
@ -128,14 +126,7 @@ public class OneWayAnovaImpl implements OneWayAnova {
|
|||
}
|
||||
|
||||
// check if each category has enough data and all is double[]
|
||||
for (Iterator iterator = categoryData.iterator(); iterator.hasNext();) {
|
||||
double[] array;
|
||||
try {
|
||||
array = (double[])iterator.next();
|
||||
} catch (ClassCastException ex) {
|
||||
throw new IllegalArgumentException(
|
||||
"ANOVA: categoryData contains non-double[] elements.");
|
||||
}
|
||||
for (double[] array : categoryData) {
|
||||
if (array.length <= 1) {
|
||||
throw new IllegalArgumentException(
|
||||
"ANOVA: one element of categoryData has fewer than 2 values.");
|
||||
|
@ -148,8 +139,7 @@ public class OneWayAnovaImpl implements OneWayAnova {
|
|||
SumOfSquares totsumsq = new SumOfSquares();
|
||||
int totnum = 0;
|
||||
|
||||
for (Iterator iterator = categoryData.iterator(); iterator.hasNext();) {
|
||||
double[] data = (double[])iterator.next();
|
||||
for (double[] data : categoryData) {
|
||||
|
||||
Sum sum = new Sum();
|
||||
SumOfSquares sumsq = new SumOfSquares();
|
||||
|
|
|
@ -382,7 +382,7 @@ public class TestUtils {
|
|||
*
|
||||
* @since 1.2
|
||||
*/
|
||||
public static double oneWayAnovaFValue(Collection categoryData)
|
||||
public static double oneWayAnovaFValue(Collection<double[]> categoryData)
|
||||
throws IllegalArgumentException, MathException {
|
||||
return oneWayAnova.anovaFValue(categoryData);
|
||||
}
|
||||
|
@ -392,7 +392,7 @@ public class TestUtils {
|
|||
*
|
||||
* @since 1.2
|
||||
*/
|
||||
public static double oneWayAnovaPValue(Collection categoryData)
|
||||
public static double oneWayAnovaPValue(Collection<double[]> categoryData)
|
||||
throws IllegalArgumentException, MathException {
|
||||
return oneWayAnova.anovaPValue(categoryData);
|
||||
}
|
||||
|
@ -402,7 +402,7 @@ public class TestUtils {
|
|||
*
|
||||
* @since 1.2
|
||||
*/
|
||||
public static boolean oneWayAnovaTest(Collection categoryData, double alpha)
|
||||
public static boolean oneWayAnovaTest(Collection<double[]> categoryData, double alpha)
|
||||
throws IllegalArgumentException, MathException {
|
||||
return oneWayAnova.anovaTest(categoryData, alpha);
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ import org.apache.commons.math.MathException;
|
|||
public class TransformerMap implements NumberTransformer, Serializable {
|
||||
|
||||
/** Serializable version identifier */
|
||||
private static final long serialVersionUID = -942772950698439883L;
|
||||
|
||||
private static final long serialVersionUID = 4605318041528645258L;
|
||||
|
||||
/**
|
||||
* A default Number Transformer for Numbers and numeric Strings.
|
||||
*/
|
||||
|
@ -44,13 +44,13 @@ public class TransformerMap implements NumberTransformer, Serializable {
|
|||
/**
|
||||
* The internal Map.
|
||||
*/
|
||||
private Map map = null;
|
||||
private Map<Class<?>, NumberTransformer> map = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* Build a map containing only the default transformer.
|
||||
*/
|
||||
public TransformerMap() {
|
||||
map = new HashMap();
|
||||
map = new HashMap<Class<?>, NumberTransformer>();
|
||||
defaultTransformer = new DefaultTransformer();
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ public class TransformerMap implements NumberTransformer, Serializable {
|
|||
* @param key Class to check
|
||||
* @return true|false
|
||||
*/
|
||||
public boolean containsClass(Class key) {
|
||||
public boolean containsClass(Class<?> key) {
|
||||
return map.containsKey(key);
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ public class TransformerMap implements NumberTransformer, Serializable {
|
|||
* @param key The Class of the object
|
||||
* @return the mapped NumberTransformer or null.
|
||||
*/
|
||||
public NumberTransformer getTransformer(Class key) {
|
||||
public NumberTransformer getTransformer(Class<?> key) {
|
||||
return (NumberTransformer) map.get(key);
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ public class TransformerMap implements NumberTransformer, Serializable {
|
|||
* @param transformer The NumberTransformer
|
||||
* @return the replaced transformer if one is present
|
||||
*/
|
||||
public Object putTransformer(Class key, NumberTransformer transformer) {
|
||||
public NumberTransformer putTransformer(Class<?> key, NumberTransformer transformer) {
|
||||
return map.put(key, transformer);
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ public class TransformerMap implements NumberTransformer, Serializable {
|
|||
* @return the removed transformer if one is present or
|
||||
* null if none was present.
|
||||
*/
|
||||
public Object removeTransformer(Class key) {
|
||||
public NumberTransformer removeTransformer(Class<?> key) {
|
||||
return map.remove(key);
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ public class TransformerMap implements NumberTransformer, Serializable {
|
|||
* Returns the Set of Classes used as keys in the map.
|
||||
* @return Set of Classes
|
||||
*/
|
||||
public Set classes() {
|
||||
public Set<Class<?>> classes() {
|
||||
return map.keySet();
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ public class TransformerMap implements NumberTransformer, Serializable {
|
|||
* in the map.
|
||||
* @return Set of NumberTransformers
|
||||
*/
|
||||
public Collection transformers() {
|
||||
public Collection<NumberTransformer> transformers() {
|
||||
return map.values();
|
||||
}
|
||||
|
||||
|
|
|
@ -19,15 +19,10 @@ package org.apache.commons.math.estimation;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.commons.math.estimation.EstimatedParameter;
|
||||
import org.apache.commons.math.estimation.EstimationException;
|
||||
import org.apache.commons.math.estimation.EstimationProblem;
|
||||
import org.apache.commons.math.estimation.GaussNewtonEstimator;
|
||||
import org.apache.commons.math.estimation.WeightedMeasurement;
|
||||
|
||||
import junit.framework.*;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* <p>Some of the unit tests are re-implementations of the MINPACK <a
|
||||
|
@ -570,7 +565,7 @@ public class GaussNewtonEstimatorTest
|
|||
private static class LinearProblem extends SimpleEstimationProblem {
|
||||
|
||||
public LinearProblem(LinearMeasurement[] measurements) {
|
||||
HashSet set = new HashSet();
|
||||
HashSet<EstimatedParameter> set = new HashSet<EstimatedParameter>();
|
||||
for (int i = 0; i < measurements.length; ++i) {
|
||||
addMeasurement(measurements[i]);
|
||||
EstimatedParameter[] parameters = measurements[i].getParameters();
|
||||
|
@ -578,8 +573,8 @@ public class GaussNewtonEstimatorTest
|
|||
set.add(parameters[j]);
|
||||
}
|
||||
}
|
||||
for (Iterator iterator = set.iterator(); iterator.hasNext();) {
|
||||
addParameter((EstimatedParameter) iterator.next());
|
||||
for (EstimatedParameter p : set) {
|
||||
addParameter(p);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -627,7 +622,7 @@ public class GaussNewtonEstimatorTest
|
|||
public Circle(double cx, double cy) {
|
||||
this.cx = new EstimatedParameter("cx", cx);
|
||||
this.cy = new EstimatedParameter(new EstimatedParameter("cy", cy));
|
||||
points = new ArrayList();
|
||||
points = new ArrayList<PointModel>();
|
||||
}
|
||||
|
||||
public void addPoint(double px, double py) {
|
||||
|
@ -652,24 +647,24 @@ public class GaussNewtonEstimatorTest
|
|||
|
||||
public double getPartialRadiusX() {
|
||||
double dRdX = 0;
|
||||
for (Iterator iterator = points.iterator(); iterator.hasNext();) {
|
||||
dRdX += ((PointModel) iterator.next()).getPartialDiX();
|
||||
for (PointModel point : points) {
|
||||
dRdX += point.getPartialDiX();
|
||||
}
|
||||
return dRdX / points.size();
|
||||
}
|
||||
|
||||
public double getPartialRadiusY() {
|
||||
double dRdY = 0;
|
||||
for (Iterator iterator = points.iterator(); iterator.hasNext();) {
|
||||
dRdY += ((PointModel) iterator.next()).getPartialDiY();
|
||||
for (PointModel point : points) {
|
||||
dRdY += point.getPartialDiY();
|
||||
}
|
||||
return dRdY / points.size();
|
||||
}
|
||||
|
||||
public double getRadius() {
|
||||
double r = 0;
|
||||
for (Iterator iterator = points.iterator(); iterator.hasNext();) {
|
||||
r += ((PointModel) iterator.next()).getCenterDistance();
|
||||
for (PointModel point : points) {
|
||||
r += point.getCenterDistance();
|
||||
}
|
||||
return r / points.size();
|
||||
}
|
||||
|
@ -725,7 +720,7 @@ public class GaussNewtonEstimatorTest
|
|||
|
||||
private EstimatedParameter cx;
|
||||
private EstimatedParameter cy;
|
||||
private ArrayList points;
|
||||
private ArrayList<PointModel> points;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -18,17 +18,11 @@
|
|||
package org.apache.commons.math.estimation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.apache.commons.math.estimation.EstimatedParameter;
|
||||
import org.apache.commons.math.estimation.EstimationException;
|
||||
import org.apache.commons.math.estimation.EstimationProblem;
|
||||
import org.apache.commons.math.estimation.LevenbergMarquardtEstimator;
|
||||
import org.apache.commons.math.estimation.WeightedMeasurement;
|
||||
|
||||
import junit.framework.*;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* <p>Some of the unit tests are re-implementations of the MINPACK <a
|
||||
|
@ -618,14 +612,13 @@ public class LevenbergMarquardtEstimatorTest
|
|||
}
|
||||
|
||||
public EstimatedParameter[] getAllParameters() {
|
||||
HashMap map = new HashMap();
|
||||
HashSet<EstimatedParameter> set = new HashSet<EstimatedParameter>();
|
||||
for (int i = 0; i < measurements.length; ++i) {
|
||||
EstimatedParameter[] parameters = measurements[i].getParameters();
|
||||
for (int j = 0; j < parameters.length; ++j) {
|
||||
map.put(parameters[j], null);
|
||||
set.add(parameters[j]);
|
||||
}
|
||||
}
|
||||
Set set = map.keySet();
|
||||
return (EstimatedParameter[]) set.toArray(new EstimatedParameter[set.size()]);
|
||||
}
|
||||
|
||||
|
@ -674,7 +667,7 @@ public class LevenbergMarquardtEstimatorTest
|
|||
public Circle(double cx, double cy) {
|
||||
this.cx = new EstimatedParameter("cx", cx);
|
||||
this.cy = new EstimatedParameter("cy", cy);
|
||||
points = new ArrayList();
|
||||
points = new ArrayList<PointModel>();
|
||||
}
|
||||
|
||||
public void addPoint(double px, double py) {
|
||||
|
@ -699,24 +692,24 @@ public class LevenbergMarquardtEstimatorTest
|
|||
|
||||
public double getPartialRadiusX() {
|
||||
double dRdX = 0;
|
||||
for (Iterator iterator = points.iterator(); iterator.hasNext();) {
|
||||
dRdX += ((PointModel) iterator.next()).getPartialDiX();
|
||||
for (PointModel point : points) {
|
||||
dRdX += point.getPartialDiX();
|
||||
}
|
||||
return dRdX / points.size();
|
||||
}
|
||||
|
||||
public double getPartialRadiusY() {
|
||||
double dRdY = 0;
|
||||
for (Iterator iterator = points.iterator(); iterator.hasNext();) {
|
||||
dRdY += ((PointModel) iterator.next()).getPartialDiY();
|
||||
for (PointModel point : points) {
|
||||
dRdY += point.getPartialDiY();
|
||||
}
|
||||
return dRdY / points.size();
|
||||
}
|
||||
|
||||
public double getRadius() {
|
||||
double r = 0;
|
||||
for (Iterator iterator = points.iterator(); iterator.hasNext();) {
|
||||
r += ((PointModel) iterator.next()).getCenterDistance();
|
||||
for (PointModel point : points) {
|
||||
r += point.getCenterDistance();
|
||||
}
|
||||
return r / points.size();
|
||||
}
|
||||
|
@ -772,7 +765,7 @@ public class LevenbergMarquardtEstimatorTest
|
|||
|
||||
private EstimatedParameter cx;
|
||||
private EstimatedParameter cy;
|
||||
private ArrayList points;
|
||||
private ArrayList<PointModel> points;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -16,16 +16,15 @@
|
|||
*/
|
||||
package org.apache.commons.math.random;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.apache.commons.math.RetryTestCase;
|
||||
import org.apache.commons.math.TestUtils;
|
||||
|
@ -58,7 +57,7 @@ public final class EmpiricalDistributionTest extends RetryTestCase {
|
|||
new BufferedReader(new InputStreamReader(
|
||||
url.openStream()));
|
||||
String str = null;
|
||||
ArrayList list = new ArrayList();
|
||||
ArrayList<Double> list = new ArrayList<Double>();
|
||||
while ((str = in.readLine()) != null) {
|
||||
list.add(Double.valueOf(str));
|
||||
}
|
||||
|
@ -67,8 +66,8 @@ public final class EmpiricalDistributionTest extends RetryTestCase {
|
|||
|
||||
dataArray = new double[list.size()];
|
||||
int i = 0;
|
||||
for (Iterator iter = list.iterator(); iter.hasNext();) {
|
||||
dataArray[i] = ((Double)iter.next()).doubleValue();
|
||||
for (Double data : list) {
|
||||
dataArray[i] = data.doubleValue();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -486,14 +486,14 @@ public class RandomDataTest extends RetryTestCase {
|
|||
long[] observed = {0,0,0,0,0,0,0,0,0,0};
|
||||
double[] expected = {100,100,100,100,100,100,100,100,100,100};
|
||||
|
||||
HashSet cPop = new HashSet(); //{0,1,2,3,4}
|
||||
HashSet<Object> cPop = new HashSet<Object>(); //{0,1,2,3,4}
|
||||
for (int i = 0; i < 5; i++) {
|
||||
cPop.add(Integer.toString(i));
|
||||
}
|
||||
|
||||
Object[] sets = new Object[10]; // 2-sets from 5
|
||||
for (int i = 0; i < 10; i ++) {
|
||||
HashSet hs = new HashSet();
|
||||
HashSet<Object> hs = new HashSet<Object>();
|
||||
hs.add(c[i][0]);
|
||||
hs.add(c[i][1]);
|
||||
sets[i] = hs;
|
||||
|
@ -511,7 +511,7 @@ public class RandomDataTest extends RetryTestCase {
|
|||
testStatistic.chiSquare(expected,observed) < 27.88);
|
||||
|
||||
// Make sure sample of size = size of collection returns same collection
|
||||
HashSet hs = new HashSet();
|
||||
HashSet<Object> hs = new HashSet<Object>();
|
||||
hs.add("one");
|
||||
Object[] one = randomData.nextSample(hs,1);
|
||||
String oneString = (String) one[0];
|
||||
|
@ -529,18 +529,19 @@ public class RandomDataTest extends RetryTestCase {
|
|||
|
||||
// Make sure we fail for empty collection
|
||||
try {
|
||||
hs = new HashSet();
|
||||
hs = new HashSet<Object>();
|
||||
one = randomData.nextSample(hs,0);
|
||||
fail("n = k = 0, expecting IllegalArgumentException");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private int findSample(Object[] u, Object[] samp) {
|
||||
for (int i = 0; i < u.length; i++) {
|
||||
HashSet set = (HashSet) u[i];
|
||||
HashSet sampSet = new HashSet();
|
||||
HashSet<Object> set = (HashSet<Object>) u[i];
|
||||
HashSet<Object> sampSet = new HashSet<Object>();
|
||||
for (int j = 0; j < samp.length; j++) {
|
||||
sampSet.add(samp[j]);
|
||||
}
|
||||
|
|
|
@ -24,15 +24,14 @@ import java.lang.reflect.InvocationTargetException;
|
|||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.commons.math.TestUtils;
|
||||
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;
|
||||
import org.apache.commons.math.stat.descriptive.SummaryStatistics;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* @version $Revision$ $Date$
|
||||
*/
|
||||
|
@ -42,12 +41,12 @@ public abstract class CertifiedDataAbstractTest extends TestCase {
|
|||
|
||||
private SummaryStatistics summaries;
|
||||
|
||||
private Map certifiedValues;
|
||||
private Map<String, Double> certifiedValues;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
descriptives = new DescriptiveStatistics();
|
||||
summaries = new SummaryStatistics();
|
||||
certifiedValues = new HashMap();
|
||||
certifiedValues = new HashMap<String, Double>();
|
||||
|
||||
loadData();
|
||||
}
|
||||
|
@ -110,10 +109,7 @@ public abstract class CertifiedDataAbstractTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testCertifiedValues() {
|
||||
Iterator iter = certifiedValues.keySet().iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
String name = iter.next().toString();
|
||||
for (String name : certifiedValues.keySet()) {
|
||||
Double expectedValue = (Double)certifiedValues.get(name);
|
||||
|
||||
Double summariesValue = getProperty(summaries, name);
|
||||
|
|
|
@ -38,7 +38,7 @@ public class ListUnivariateImpl extends DescriptiveStatistics implements Seriali
|
|||
* Holds a reference to a list - GENERICs are going to make
|
||||
* our lives easier here as we could only accept List<Number>
|
||||
*/
|
||||
protected List list;
|
||||
protected List<Object> list;
|
||||
|
||||
/** Number Transformer maps Objects to Number for us. */
|
||||
protected NumberTransformer transformer;
|
||||
|
@ -47,14 +47,14 @@ public class ListUnivariateImpl extends DescriptiveStatistics implements Seriali
|
|||
* No argument Constructor
|
||||
*/
|
||||
public ListUnivariateImpl(){
|
||||
this(new ArrayList());
|
||||
this(new ArrayList<Object>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a ListUnivariate with a specific List.
|
||||
* @param list The list that will back this DescriptiveStatistics
|
||||
*/
|
||||
public ListUnivariateImpl(List list) {
|
||||
public ListUnivariateImpl(List<Object> list) {
|
||||
this(list, new DefaultTransformer());
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ public class ListUnivariateImpl extends DescriptiveStatistics implements Seriali
|
|||
* @param list The list that will back this DescriptiveStatistics
|
||||
* @param transformer the number transformer used to convert the list items.
|
||||
*/
|
||||
public ListUnivariateImpl(List list, NumberTransformer transformer) {
|
||||
public ListUnivariateImpl(List<Object> list, NumberTransformer transformer) {
|
||||
super();
|
||||
this.list = list;
|
||||
this.transformer = transformer;
|
||||
|
|
|
@ -62,7 +62,7 @@ public final class ListUnivariateImplTest extends TestCase {
|
|||
|
||||
/** test stats */
|
||||
public void testStats() {
|
||||
List externalList = new ArrayList();
|
||||
List<Object> externalList = new ArrayList<Object>();
|
||||
|
||||
DescriptiveStatistics u = new ListUnivariateImpl( externalList );
|
||||
|
||||
|
@ -84,7 +84,7 @@ public final class ListUnivariateImplTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testN0andN1Conditions() throws Exception {
|
||||
List list = new ArrayList();
|
||||
List<Object> list = new ArrayList<Object>();
|
||||
|
||||
DescriptiveStatistics u = new ListUnivariateImpl( list );
|
||||
|
||||
|
@ -115,7 +115,7 @@ public final class ListUnivariateImplTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testProductAndGeometricMean() throws Exception {
|
||||
ListUnivariateImpl u = new ListUnivariateImpl(new ArrayList());
|
||||
ListUnivariateImpl u = new ListUnivariateImpl(new ArrayList<Object>());
|
||||
u.setWindowSize(10);
|
||||
|
||||
u.addValue( 1.0 );
|
||||
|
|
|
@ -69,7 +69,7 @@ public final class MixedListUnivariateImplTest extends TestCase {
|
|||
|
||||
/** test stats */
|
||||
public void testStats() {
|
||||
List externalList = new ArrayList();
|
||||
List<Object> externalList = new ArrayList<Object>();
|
||||
|
||||
DescriptiveStatistics u = new ListUnivariateImpl(externalList,transformers);
|
||||
|
||||
|
@ -91,7 +91,7 @@ public final class MixedListUnivariateImplTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testN0andN1Conditions() throws Exception {
|
||||
DescriptiveStatistics u = new ListUnivariateImpl(new ArrayList(),transformers);
|
||||
DescriptiveStatistics u = new ListUnivariateImpl(new ArrayList<Object>(),transformers);
|
||||
|
||||
assertTrue(
|
||||
"Mean of n = 0 set should be NaN",
|
||||
|
@ -120,7 +120,7 @@ public final class MixedListUnivariateImplTest extends TestCase {
|
|||
|
||||
public void testSkewAndKurtosis() {
|
||||
ListUnivariateImpl u =
|
||||
new ListUnivariateImpl(new ArrayList(), transformers);
|
||||
new ListUnivariateImpl(new ArrayList<Object>(), transformers);
|
||||
|
||||
u.addObject("12.5");
|
||||
u.addObject(new Integer(12));
|
||||
|
@ -153,7 +153,7 @@ public final class MixedListUnivariateImplTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testProductAndGeometricMean() throws Exception {
|
||||
ListUnivariateImpl u = new ListUnivariateImpl(new ArrayList(),transformers);
|
||||
ListUnivariateImpl u = new ListUnivariateImpl(new ArrayList<Object>(),transformers);
|
||||
u.setWindowSize(10);
|
||||
|
||||
u.addValue(1.0);
|
||||
|
|
|
@ -33,7 +33,6 @@ public class OneWayAnovaTest extends TestCase {
|
|||
|
||||
protected OneWayAnova testStatistic = new OneWayAnovaImpl();
|
||||
|
||||
private char[] wrongArray = { 'a', 'b', 'c' };
|
||||
private double[] emptyArray = {};
|
||||
|
||||
private double[] classA =
|
||||
|
@ -58,7 +57,7 @@ public class OneWayAnovaTest extends TestCase {
|
|||
|
||||
public void testAnovaFValue() throws Exception {
|
||||
// Target comparison values computed using R version 2.6.0 (Linux version)
|
||||
List threeClasses = new ArrayList();
|
||||
List<double[]> threeClasses = new ArrayList<double[]>();
|
||||
threeClasses.add(classA);
|
||||
threeClasses.add(classB);
|
||||
threeClasses.add(classC);
|
||||
|
@ -66,25 +65,14 @@ public class OneWayAnovaTest extends TestCase {
|
|||
assertEquals("ANOVA F-value", 24.67361709460624,
|
||||
testStatistic.anovaFValue(threeClasses), 1E-12);
|
||||
|
||||
List twoClasses = new ArrayList();
|
||||
List<double[]> twoClasses = new ArrayList<double[]>();
|
||||
twoClasses.add(classA);
|
||||
twoClasses.add(classB);
|
||||
|
||||
assertEquals("ANOVA F-value", 0.0150579150579,
|
||||
testStatistic.anovaFValue(twoClasses), 1E-12);
|
||||
|
||||
// now try some input hashes which should fail
|
||||
List wrongContents = new ArrayList();
|
||||
wrongContents.add(classC);
|
||||
wrongContents.add(wrongArray);
|
||||
try {
|
||||
testStatistic.anovaFValue(wrongContents);
|
||||
fail("non double[] hash value for key classX, IllegalArgumentException expected");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected
|
||||
}
|
||||
|
||||
List emptyContents = new ArrayList();
|
||||
List<double[]> emptyContents = new ArrayList<double[]>();
|
||||
emptyContents.add(emptyArray);
|
||||
emptyContents.add(classC);
|
||||
try {
|
||||
|
@ -94,7 +82,7 @@ public class OneWayAnovaTest extends TestCase {
|
|||
// expected
|
||||
}
|
||||
|
||||
List tooFew = new ArrayList();
|
||||
List<double[]> tooFew = new ArrayList<double[]>();
|
||||
tooFew.add(classA);
|
||||
try {
|
||||
testStatistic.anovaFValue(tooFew);
|
||||
|
@ -107,7 +95,7 @@ public class OneWayAnovaTest extends TestCase {
|
|||
|
||||
public void testAnovaPValue() throws Exception {
|
||||
// Target comparison values computed using R version 2.6.0 (Linux version)
|
||||
List threeClasses = new ArrayList();
|
||||
List<double[]> threeClasses = new ArrayList<double[]>();
|
||||
threeClasses.add(classA);
|
||||
threeClasses.add(classB);
|
||||
threeClasses.add(classC);
|
||||
|
@ -115,7 +103,7 @@ public class OneWayAnovaTest extends TestCase {
|
|||
assertEquals("ANOVA P-value", 6.959446E-06,
|
||||
testStatistic.anovaPValue(threeClasses), 1E-12);
|
||||
|
||||
List twoClasses = new ArrayList();
|
||||
List<double[]> twoClasses = new ArrayList<double[]>();
|
||||
twoClasses.add(classA);
|
||||
twoClasses.add(classB);
|
||||
|
||||
|
@ -126,14 +114,14 @@ public class OneWayAnovaTest extends TestCase {
|
|||
|
||||
public void testAnovaTest() throws Exception {
|
||||
// Target comparison values computed using R version 2.3.1 (Linux version)
|
||||
List threeClasses = new ArrayList();
|
||||
List<double[]> threeClasses = new ArrayList<double[]>();
|
||||
threeClasses.add(classA);
|
||||
threeClasses.add(classB);
|
||||
threeClasses.add(classC);
|
||||
|
||||
assertTrue("ANOVA Test P<0.01", testStatistic.anovaTest(threeClasses, 0.01));
|
||||
|
||||
List twoClasses = new ArrayList();
|
||||
List<double[]> twoClasses = new ArrayList<double[]>();
|
||||
twoClasses.add(classA);
|
||||
twoClasses.add(classB);
|
||||
|
||||
|
|
|
@ -451,7 +451,7 @@ public class TestUtilsTest extends TestCase {
|
|||
private double[] classC =
|
||||
{110.0, 115.0, 111.0, 117.0, 128.0};
|
||||
|
||||
private List classes = new ArrayList();
|
||||
private List<double[]> classes = new ArrayList<double[]>();
|
||||
private OneWayAnova oneWayAnova = new OneWayAnovaImpl();
|
||||
|
||||
public void testOneWayAnovaUtils() throws Exception {
|
||||
|
|
Loading…
Reference in New Issue