Commit 0ce6cda0 authored by Björn Richerzhagen's avatar Björn Richerzhagen
Browse files

updating apache math to v3

parent 826d3956
...@@ -235,10 +235,18 @@ ...@@ -235,10 +235,18 @@
<version>3.0</version> <version>3.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.6.1</version>
</dependency>
<!-- OLD Math for some outdated classes -->
<!-- <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-math</artifactId> <artifactId>commons-math</artifactId>
<version>2.2</version> <version>2.2</version>
</dependency> </dependency>-->
<dependency> <dependency>
<groupId>commons-net</groupId> <groupId>commons-net</groupId>
<artifactId>commons-net</artifactId> <artifactId>commons-net</artifactId>
......
...@@ -24,7 +24,7 @@ import java.util.Arrays; ...@@ -24,7 +24,7 @@ import java.util.Arrays;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.apache.commons.math.stat.StatUtils; import org.apache.commons.math3.stat.StatUtils;
import de.tudarmstadt.maki.simonstrator.api.Host; import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.common.metric.Metric; import de.tudarmstadt.maki.simonstrator.api.common.metric.Metric;
......
...@@ -28,7 +28,7 @@ import java.util.Map; ...@@ -28,7 +28,7 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
import de.tud.kom.p2psim.api.common.SimHost; import de.tud.kom.p2psim.api.common.SimHost;
import de.tud.kom.p2psim.impl.util.db.dao.DAO; import de.tud.kom.p2psim.impl.util.db.dao.DAO;
......
...@@ -26,8 +26,8 @@ import java.util.HashMap; ...@@ -26,8 +26,8 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.math.MathException; import org.apache.commons.math3.distribution.ExponentialDistribution;
import org.apache.commons.math.distribution.ExponentialDistributionImpl; import org.apache.commons.math3.exception.OutOfRangeException;
import de.tud.kom.p2psim.api.churn.ChurnModel; import de.tud.kom.p2psim.api.churn.ChurnModel;
import de.tud.kom.p2psim.api.common.SimHost; import de.tud.kom.p2psim.api.common.SimHost;
...@@ -42,11 +42,11 @@ public class ExponentialChurnModel implements ChurnModel { ...@@ -42,11 +42,11 @@ public class ExponentialChurnModel implements ChurnModel {
TRANSIENT(MEAN_SESSION_LENGTH), NORMAL(10 * MEAN_SESSION_LENGTH), LONG_LASTING( TRANSIENT(MEAN_SESSION_LENGTH), NORMAL(10 * MEAN_SESSION_LENGTH), LONG_LASTING(
100 * MEAN_SESSION_LENGTH); 100 * MEAN_SESSION_LENGTH);
public final ExponentialDistributionImpl expDist; public final ExponentialDistribution expDist;
private UserType(long length) { private UserType(long length) {
double meanLength = Double.parseDouble(Long.toString(length)); double meanLength = Double.parseDouble(Long.toString(length));
expDist = new ExponentialDistributionImpl(meanLength); expDist = new ExponentialDistribution(meanLength);
Long.toString(length); Long.toString(length);
} }
...@@ -113,7 +113,7 @@ public class ExponentialChurnModel implements ChurnModel { ...@@ -113,7 +113,7 @@ public class ExponentialChurnModel implements ChurnModel {
* .inverseCumulativeProbability(Simulator.getRandom() * .inverseCumulativeProbability(Simulator.getRandom()
* .nextDouble()); data.setOnlineTime((long) value); * .nextDouble()); data.setOnlineTime((long) value);
*/ */
} catch (MathException e) { } catch (OutOfRangeException e) {
e.printStackTrace(); e.printStackTrace();
} }
return data.onlineTime; return data.onlineTime;
......
...@@ -24,8 +24,8 @@ import java.util.HashMap; ...@@ -24,8 +24,8 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.math.MathException; import org.apache.commons.math3.distribution.ExponentialDistribution;
import org.apache.commons.math.distribution.ExponentialDistributionImpl; import org.apache.commons.math3.exception.OutOfRangeException;
import de.tud.kom.p2psim.api.churn.ChurnModel; import de.tud.kom.p2psim.api.churn.ChurnModel;
import de.tud.kom.p2psim.api.common.SimHost; import de.tud.kom.p2psim.api.common.SimHost;
...@@ -39,11 +39,11 @@ public class HerreraChurnModel implements ChurnModel { ...@@ -39,11 +39,11 @@ public class HerreraChurnModel implements ChurnModel {
TRANSIENT(MEAN_SESSION_LENGTH), NORMAL(10 * MEAN_SESSION_LENGTH), LONG_LASTING( TRANSIENT(MEAN_SESSION_LENGTH), NORMAL(10 * MEAN_SESSION_LENGTH), LONG_LASTING(
100 * MEAN_SESSION_LENGTH); 100 * MEAN_SESSION_LENGTH);
public final ExponentialDistributionImpl expDist; public final ExponentialDistribution expDist;
private UserType(long length) { private UserType(long length) {
double meanLength = Double.parseDouble(Long.toString(length)); double meanLength = Double.parseDouble(Long.toString(length));
expDist = new ExponentialDistributionImpl(meanLength); expDist = new ExponentialDistribution(meanLength);
Long.toString(length); Long.toString(length);
} }
...@@ -81,7 +81,7 @@ public class HerreraChurnModel implements ChurnModel { ...@@ -81,7 +81,7 @@ public class HerreraChurnModel implements ChurnModel {
data.setOnlineTime(Math.round(data.type.expDist data.setOnlineTime(Math.round(data.type.expDist
.inverseCumulativeProbability(Randoms.getRandom( .inverseCumulativeProbability(Randoms.getRandom(
HerreraChurnModel.class).nextDouble()))); HerreraChurnModel.class).nextDouble())));
} catch (MathException e) { } catch (OutOfRangeException e) {
e.printStackTrace(); e.printStackTrace();
} }
// Simulator.getMonitor().nextSessionTime(data.onlineTime); // Simulator.getMonitor().nextSessionTime(data.onlineTime);
......
...@@ -22,7 +22,7 @@ package de.tud.kom.p2psim.impl.churn; ...@@ -22,7 +22,7 @@ package de.tud.kom.p2psim.impl.churn;
import java.util.List; import java.util.List;
import org.apache.commons.math.distribution.WeibullDistributionImpl; import org.apache.commons.math3.distribution.WeibullDistribution;
import de.tud.kom.p2psim.api.churn.ChurnModel; import de.tud.kom.p2psim.api.churn.ChurnModel;
import de.tud.kom.p2psim.api.common.SimHost; import de.tud.kom.p2psim.api.common.SimHost;
...@@ -53,11 +53,11 @@ import de.tudarmstadt.maki.simonstrator.api.Time; ...@@ -53,11 +53,11 @@ import de.tudarmstadt.maki.simonstrator.api.Time;
*/ */
public class KadChurnModel implements ChurnModel { public class KadChurnModel implements ChurnModel {
public WeibullDistributionImpl sessionTime, interSessionTime; public WeibullDistribution sessionTime, interSessionTime;
public KadChurnModel() { public KadChurnModel() {
sessionTime = new WeibullDistributionImpl(0.61511, 169.5385); sessionTime = new WeibullDistribution(0.61511, 169.5385);
interSessionTime = new WeibullDistributionImpl(0.47648, 413.6765); interSessionTime = new WeibullDistribution(0.47648, 413.6765);
} }
/** /**
...@@ -67,8 +67,8 @@ public class KadChurnModel implements ChurnModel { ...@@ -67,8 +67,8 @@ public class KadChurnModel implements ChurnModel {
* @param lambda * @param lambda
*/ */
public void setLambdaFactor(double lambda) { public void setLambdaFactor(double lambda) {
sessionTime = new WeibullDistributionImpl(0.61511, 169.5385 * lambda); sessionTime = new WeibullDistribution(0.61511, 169.5385 * lambda);
interSessionTime = new WeibullDistributionImpl(0.47648, interSessionTime = new WeibullDistribution(0.47648,
413.6765 * lambda); 413.6765 * lambda);
} }
......
...@@ -27,7 +27,7 @@ import java.util.HashMap; ...@@ -27,7 +27,7 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import org.apache.commons.math.stat.StatUtils; import org.apache.commons.math3.stat.StatUtils;
/** /**
* Implements the downhill simplx algorithm for positioning host in an * Implements the downhill simplx algorithm for positioning host in an
......
...@@ -25,8 +25,8 @@ import java.util.List; ...@@ -25,8 +25,8 @@ import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.Vector; import java.util.Vector;
import org.apache.commons.math.MathException; import org.apache.commons.math3.distribution.NormalDistribution;
import org.apache.commons.math.distribution.NormalDistributionImpl; import org.apache.commons.math3.exception.OutOfRangeException;
import de.tud.kom.p2psim.api.network.NetMessage; import de.tud.kom.p2psim.api.network.NetMessage;
import de.tud.kom.p2psim.impl.network.AbstractNetLayer; import de.tud.kom.p2psim.impl.network.AbstractNetLayer;
...@@ -68,7 +68,7 @@ public class NormalDistributionLatency implements LatencyStrategy { ...@@ -68,7 +68,7 @@ public class NormalDistributionLatency implements LatencyStrategy {
*/ */
private long standardDeviation = 2 * Time.MICROSECOND; // 2ms private long standardDeviation = 2 * Time.MICROSECOND; // 2ms
private NormalDistributionImpl normalDistribution = new NormalDistributionImpl( private NormalDistribution normalDistribution = new NormalDistribution(
propagationMeanDelay, standardDeviation); propagationMeanDelay, standardDeviation);
/** /**
...@@ -109,7 +109,7 @@ public class NormalDistributionLatency implements LatencyStrategy { ...@@ -109,7 +109,7 @@ public class NormalDistributionLatency implements LatencyStrategy {
try { try {
delay = (long) normalDistribution delay = (long) normalDistribution
.inverseCumulativeProbability(rnd.nextDouble()); .inverseCumulativeProbability(rnd.nextDouble());
} catch (MathException e) { } catch (OutOfRangeException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
if (delay <= 0) { if (delay <= 0) {
...@@ -125,13 +125,13 @@ public class NormalDistributionLatency implements LatencyStrategy { ...@@ -125,13 +125,13 @@ public class NormalDistributionLatency implements LatencyStrategy {
"Bad PropagationMeanDelay. It should be positiv!"); "Bad PropagationMeanDelay. It should be positiv!");
} }
this.propagationMeanDelay = delay; this.propagationMeanDelay = delay;
this.normalDistribution = new NormalDistributionImpl( this.normalDistribution = new NormalDistribution(
this.propagationMeanDelay, this.standardDeviation); this.propagationMeanDelay, this.standardDeviation);
} }
public void setStandardDeviation(long standardDeviation) { public void setStandardDeviation(long standardDeviation) {
this.standardDeviation = standardDeviation; this.standardDeviation = standardDeviation;
this.normalDistribution = new NormalDistributionImpl( this.normalDistribution = new NormalDistribution(
this.propagationMeanDelay, this.standardDeviation); this.propagationMeanDelay, this.standardDeviation);
} }
......
...@@ -30,8 +30,8 @@ import java.util.Locale; ...@@ -30,8 +30,8 @@ import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
import org.apache.commons.math.random.JDKRandomGenerator; import org.apache.commons.math3.random.JDKRandomGenerator;
import org.apache.commons.math.random.RandomGenerator; import org.apache.commons.math3.random.RandomGenerator;
import de.tud.kom.p2psim.api.scenario.ConfigurationException; import de.tud.kom.p2psim.api.scenario.ConfigurationException;
import de.tud.kom.p2psim.api.scenario.Configurator; import de.tud.kom.p2psim.api.scenario.Configurator;
......
...@@ -27,7 +27,7 @@ import java.util.Map; ...@@ -27,7 +27,7 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.TreeMap; import java.util.TreeMap;
import org.apache.commons.math.stat.Frequency; import org.apache.commons.math3.stat.Frequency;
import org.jfree.data.xy.YIntervalSeries; import org.jfree.data.xy.YIntervalSeries;
import de.tudarmstadt.maki.simonstrator.api.Time; import de.tudarmstadt.maki.simonstrator.api.Time;
......
...@@ -20,8 +20,7 @@ ...@@ -20,8 +20,7 @@
package de.tud.kom.p2psim.impl.topology.views.wifi.phy.errormodel; package de.tud.kom.p2psim.impl.topology.views.wifi.phy.errormodel;
import org.apache.commons.math.MathException; import org.apache.commons.math3.special.Erf;
import org.apache.commons.math.special.Erf;
import de.tud.kom.p2psim.api.topology.views.wifi.phy.WifiMode; import de.tud.kom.p2psim.api.topology.views.wifi.phy.WifiMode;
import de.tud.kom.p2psim.impl.util.NotSupportedException; import de.tud.kom.p2psim.impl.util.NotSupportedException;
...@@ -130,13 +129,7 @@ public class NistErrorRateModel extends AbstractErrorRateModel { ...@@ -130,13 +129,7 @@ public class NistErrorRateModel extends AbstractErrorRateModel {
} }
private double getErfc(double z) { private double getErfc(double z) {
try {
return Erf.erfc(z); return Erf.erfc(z);
} catch (MathException e) {
Monitor.log(NistErrorRateModel.class, Level.ERROR,
"Unable to compute the complimentary error function! Returning '0'...");
}
return 0;
} }
private double getBpskBer(double snr) { private double getBpskBer(double snr) {
......
...@@ -22,8 +22,7 @@ package de.tud.kom.p2psim.impl.topology.views.wifi.phy.errormodel; ...@@ -22,8 +22,7 @@ package de.tud.kom.p2psim.impl.topology.views.wifi.phy.errormodel;
import java.util.HashMap; import java.util.HashMap;
import org.apache.commons.math.MathException; import org.apache.commons.math3.special.Erf;
import org.apache.commons.math.special.Erf;
import de.tud.kom.p2psim.api.topology.views.wifi.phy.WifiMode; import de.tud.kom.p2psim.api.topology.views.wifi.phy.WifiMode;
import de.tud.kom.p2psim.impl.util.NotSupportedException; import de.tud.kom.p2psim.impl.util.NotSupportedException;
...@@ -200,13 +199,7 @@ public class YansErrorRateModel extends AbstractErrorRateModel { ...@@ -200,13 +199,7 @@ public class YansErrorRateModel extends AbstractErrorRateModel {
} }
private double getErfc(double z) { private double getErfc(double z) {
try {
return Erf.erfc(z); return Erf.erfc(z);
} catch (MathException e) {
Monitor.log(YansErrorRateModel.class, Level.ERROR,
"Unable to compute the complimentary error function! Returning '0'...");
}
return 0;
} }
private double getQamBer(double snr, int m, int signalSpread, int phyRate) { private double getQamBer(double snr, int m, int signalSpread, int phyRate) {
......
...@@ -38,8 +38,8 @@ import java.util.Vector; ...@@ -38,8 +38,8 @@ import java.util.Vector;
import javax.swing.JComponent; import javax.swing.JComponent;
import org.apache.commons.math.random.JDKRandomGenerator; import org.apache.commons.math3.random.JDKRandomGenerator;
import org.apache.commons.math.random.RandomGenerator; import org.apache.commons.math3.random.RandomGenerator;
import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.Geometry;
......
...@@ -22,7 +22,7 @@ package de.tud.kom.p2psim.impl.util.db.dao.metric; ...@@ -22,7 +22,7 @@ package de.tud.kom.p2psim.impl.util.db.dao.metric;
import java.util.List; import java.util.List;
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
import de.tud.kom.p2psim.impl.util.db.dao.DAO; import de.tud.kom.p2psim.impl.util.db.dao.DAO;
import de.tud.kom.p2psim.impl.util.db.metric.CustomMeasurement; import de.tud.kom.p2psim.impl.util.db.metric.CustomMeasurement;
......
...@@ -30,7 +30,7 @@ import javax.persistence.JoinColumn; ...@@ -30,7 +30,7 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
/** /**
* *
......
...@@ -22,8 +22,7 @@ ...@@ -22,8 +22,7 @@
package de.tud.kom.p2psim.impl.util.stat.distributions; package de.tud.kom.p2psim.impl.util.stat.distributions;
import org.apache.commons.math.MathException; import org.apache.commons.math3.exception.OutOfRangeException;
import org.apache.commons.math.distribution.ExponentialDistributionImpl;
import de.tud.kom.p2psim.api.scenario.ConfigurationException; import de.tud.kom.p2psim.api.scenario.ConfigurationException;
import de.tudarmstadt.maki.simonstrator.api.Randoms; import de.tudarmstadt.maki.simonstrator.api.Randoms;
...@@ -32,13 +31,13 @@ import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor; ...@@ -32,13 +31,13 @@ import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
public class ExponentialDistribution implements Distribution { public class ExponentialDistribution implements Distribution {
private ExponentialDistributionImpl distr = null; private org.apache.commons.math3.distribution.ExponentialDistribution distr = null;
private double mu; private double mu;
@XMLConfigurableConstructor({"mu"}) @XMLConfigurableConstructor({"mu"})
public ExponentialDistribution(double mu) { public ExponentialDistribution(double mu) {
this.mu = mu; this.mu = mu;
this.distr = new ExponentialDistributionImpl(mu); this.distr = new org.apache.commons.math3.distribution.ExponentialDistribution(mu);
} }
/** /**
...@@ -56,7 +55,7 @@ public class ExponentialDistribution implements Distribution { ...@@ -56,7 +55,7 @@ public class ExponentialDistribution implements Distribution {
try { try {
result = distr.inverseCumulativeProbability(random); result = distr.inverseCumulativeProbability(random);
} catch (MathException e) { } catch (OutOfRangeException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
result = 0; result = 0;
...@@ -73,11 +72,11 @@ public class ExponentialDistribution implements Distribution { ...@@ -73,11 +72,11 @@ public class ExponentialDistribution implements Distribution {
*/ */
public static double returnValue(double _mu) { public static double returnValue(double _mu) {
try { try {
ExponentialDistributionImpl d = new ExponentialDistributionImpl(_mu); org.apache.commons.math3.distribution.ExponentialDistribution d = new org.apache.commons.math3.distribution.ExponentialDistribution(_mu);
return d.inverseCumulativeProbability(Randoms.getRandom( return d.inverseCumulativeProbability(Randoms.getRandom(
ExponentialDistribution.class) ExponentialDistribution.class)
.nextDouble()); .nextDouble());
} catch (MathException e) { } catch (OutOfRangeException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
return 0; return 0;
......
...@@ -22,15 +22,14 @@ ...@@ -22,15 +22,14 @@
package de.tud.kom.p2psim.impl.util.stat.distributions; package de.tud.kom.p2psim.impl.util.stat.distributions;
import org.apache.commons.math.MathException; import org.apache.commons.math3.distribution.NormalDistribution;
import org.apache.commons.math.distribution.NormalDistributionImpl;
import de.tudarmstadt.maki.simonstrator.api.Randoms; import de.tudarmstadt.maki.simonstrator.api.Randoms;
import de.tudarmstadt.maki.simonstrator.api.util.Distribution; import de.tudarmstadt.maki.simonstrator.api.util.Distribution;
import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor; import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
public class LimitedNormalDistribution implements Distribution { public class LimitedNormalDistribution implements Distribution {
private NormalDistributionImpl limitedNormal; private NormalDistribution limitedNormal;
private double mu; private double mu;
...@@ -77,7 +76,7 @@ public class LimitedNormalDistribution implements Distribution { ...@@ -77,7 +76,7 @@ public class LimitedNormalDistribution implements Distribution {
limitedMin = dc.isLimitedMin(); limitedMin = dc.isLimitedMin();
limitedMax = dc.isLimitedMax(); limitedMax = dc.isLimitedMax();
limitedNormal = new NormalDistributionImpl(mu, sigma); limitedNormal = new NormalDistribution(mu, sigma);
if (limitedMin == false) { if (limitedMin == false) {
if (limitedMax == false) { if (limitedMax == false) {
...@@ -86,23 +85,14 @@ public class LimitedNormalDistribution implements Distribution { ...@@ -86,23 +85,14 @@ public class LimitedNormalDistribution implements Distribution {
// only max is limted // only max is limted
limitType = LIMIT_NORMAL_DIST_MAX; limitType = LIMIT_NORMAL_DIST_MAX;
max = dc.getMax(); max = dc.getMax();
try {
pmax = limitedNormal.cumulativeProbability(max); pmax = limitedNormal.cumulativeProbability(max);
} catch (MathException e) {
e.printStackTrace();
}
} }
} else { } else {
if (limitedMax == false) { if (limitedMax == false) {
// only min is limited. // only min is limited.
limitType = LIMIT_NORMAL_DIST_MIN; limitType = LIMIT_NORMAL_DIST_MIN;
min = dc.getMin(); min = dc.getMin();
try {
pmin = limitedNormal.cumulativeProbability(min); pmin = limitedNormal.cumulativeProbability(min);
} catch (MathException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else { } else {
// both sides limited. // both sides limited.
limitType = LIMIT_NORMAL_DIST_BOTH; limitType = LIMIT_NORMAL_DIST_BOTH;
...@@ -117,15 +107,9 @@ public class LimitedNormalDistribution implements Distribution { ...@@ -117,15 +107,9 @@ public class LimitedNormalDistribution implements Distribution {
} }
// get min and max probabilites that are possible // get min and max probabilites that are possible
try {
pmin = limitedNormal.cumulativeProbability(min); pmin = limitedNormal.cumulativeProbability(min);
pmax = limitedNormal.cumulativeProbability(max); pmax = limitedNormal.cumulativeProbability(max);
pfactor = pmax - pmin; pfactor = pmax - pmin;
} catch (MathException e) {
e.printStackTrace();
}
} }
} }
pfactor = pmax - pmin; pfactor = pmax - pmin;
...@@ -137,13 +121,7 @@ public class LimitedNormalDistribution implements Distribution { ...@@ -137,13 +121,7 @@ public class LimitedNormalDistribution implements Distribution {
.nextDouble() * pfactor; .nextDouble() * pfactor;
double result; double result;
try {
result = limitedNormal.inverseCumulativeProbability(random); result = limitedNormal.inverseCumulativeProbability(random);
} catch (MathException e) {
// TODO Auto-generated catch block
e.printStackTrace();
result = 0;
}
return result; return result;
} }
...@@ -178,7 +156,7 @@ public class LimitedNormalDistribution implements Distribution { ...@@ -178,7 +156,7 @@ public class LimitedNormalDistribution implements Distribution {
double lpmin = 0; double lpmin = 0;
double lpfactor; double lpfactor;
NormalDistributionImpl llimitedNormal = new NormalDistributionImpl(_mu, NormalDistribution llimitedNormal = new NormalDistribution(_mu,
_sigma); _sigma);
if (_min == null) { if (_min == null) {
if (_max == null) { if (_max == null) {
...@@ -187,23 +165,14 @@ public class LimitedNormalDistribution implements Distribution { ...@@ -187,23 +165,14 @@ public class LimitedNormalDistribution implements Distribution {
// only max is limted // only max is limted
llimitType = LIMIT_NORMAL_DIST_MAX; llimitType = LIMIT_NORMAL_DIST_MAX;
lmax = _max.doubleValue(); lmax = _max.doubleValue();
try {
lpmax = llimitedNormal.cumulativeProbability(lmax); lpmax = llimitedNormal.cumulativeProbability(lmax);
} catch (MathException e) {
e.printStackTrace();
}
} }
} else { } else {
if (_max == null) { if (_max == null) {
// only min is limited. // only min is limited.
llimitType = LIMIT_NORMAL_DIST_MIN; llimitType = LIMIT_NORMAL_DIST_MIN;
lmin = _min.doubleValue(); lmin = _min.doubleValue();
try {
lpmin = llimitedNormal.cumulativeProbability(lmin); lpmin = llimitedNormal.cumulativeProbability(lmin);
} catch (MathException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else { } else {
// both sides limited. // both sides limited.
llimitType = LIMIT_NORMAL_DIST_BOTH; llimitType = LIMIT_NORMAL_DIST_BOTH;
...@@ -218,15 +187,10 @@ public class LimitedNormalDistribution implements Distribution { ...@@ -218,15 +187,10 @@ public class LimitedNormalDistribution implements Distribution {
} }
// get min and max probabilites that are possible // get min and max probabilites that are possible
try {
lpmin = llimitedNormal.cumulativeProbability(lmin); lpmin = llimitedNormal.cumulativeProbability(lmin);
lpmax = llimitedNormal.cumulativeProbability(lmax); lpmax = llimitedNormal.cumulativeProbability(lmax);
lpfactor = lpmax - lpmin; lpfactor = lpmax - lpmin;
} catch (MathException e) {
e.printStackTrace();
}
} }
} }
lpfactor = lpmax - lpmin; lpfactor = lpmax - lpmin;
...@@ -237,13 +201,8 @@ public class LimitedNormalDistribution implements Distribution { ...@@ -237,13 +201,8 @@ public class LimitedNormalDistribution implements Distribution {
* lpfactor; * lpfactor;
double lresult; double lresult;
try {
lresult = llimitedNormal.inverseCumulativeProbability(lrandom); lresult = llimitedNormal.inverseCumulativeProbability(lrandom);
} catch (MathException e) {
// TODO Auto-generated catch block
e.printStackTrace();
lresult = 0;
}
return lresult; return lresult;
......
...@@ -24,8 +24,7 @@ package de.tud.kom.p2psim.impl.util.stat.distributions; ...@@ -24,8 +24,7 @@ package de.tud.kom.p2psim.impl.util.stat.distributions;
import java.util.Random; import java.util.Random;
import org.apache.commons.math.MathException; import org.apache.commons.math3.exception.OutOfRangeException;
import org.apache.commons.math.distribution.NormalDistributionImpl;
import de.tudarmstadt.maki.simonstrator.api.Randoms; import de.tudarmstadt.maki.simonstrator.api.Randoms;
import de.tudarmstadt.maki.simonstrator.api.util.Distribution; import de.tudarmstadt.maki.simonstrator.api.util.Distribution;
...@@ -33,7 +32,7 @@ import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor; ...@@ -33,7 +32,7 @@ import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
public class NormalDistribution implements Distribution { public class NormalDistribution implements Distribution {
private NormalDistributionImpl normal; private org.apache.commons.math3.distribution.NormalDistribution normal;
private Random randomGen = Randoms.getRandom(NormalDistribution.class); private Random randomGen = Randoms.getRandom(NormalDistribution.class);
...@@ -45,7 +44,7 @@ public class NormalDistribution implements Distribution { ...@@ -45,7 +44,7 @@ public class NormalDistribution implements Distribution {
public NormalDistribution(double mu, double sigma) { public NormalDistribution(double mu, double sigma) {
this.mu = mu; this.mu = mu;
this.sigma = sigma; this.sigma = sigma;
normal = new NormalDistributionImpl(mu, sigma); normal = new org.apache.commons.math3.distribution.NormalDistribution(mu, sigma);
} }
@Override @Override
...@@ -56,7 +55,7 @@ public class NormalDistribution implements Distribution { ...@@ -56,7 +55,7 @@ public class NormalDistribution implements Distribution {
try { try {
result = normal.inverseCumulativeProbability(random); result = normal.inverseCumulativeProbability(random);
} catch (MathException e) { } catch (OutOfRangeException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
result = 0; result = 0;
...@@ -80,7 +79,7 @@ public class NormalDistribution implements Distribution { ...@@ -80,7 +79,7 @@ public class NormalDistribution implements Distribution {
*/ */
public static double returnValue(double _mu, double _sigma) { public static double returnValue(double _mu, double _sigma) {
try { try {
NormalDistributionImpl d = new NormalDistributionImpl(_mu, _sigma); org.apache.commons.math3.distribution.NormalDistribution d = new org.apache.commons.math3.distribution.NormalDistribution(_mu, _sigma);
return d.inverseCumulativeProbability(Randoms.getRandom( return d.inverseCumulativeProbability(Randoms.getRandom(
NormalDistribution.class) NormalDistribution.class)
.nextDouble()); .nextDouble());
......
...@@ -22,8 +22,7 @@ ...@@ -22,8 +22,7 @@
package de.tud.kom.p2psim.impl.util.stat.distributions; package de.tud.kom.p2psim.impl.util.stat.distributions;
import org.apache.commons.math.MathException; import org.apache.commons.math3.exception.OutOfRangeException;
import org.apache.commons.math.distribution.PoissonDistributionImpl;
import de.tudarmstadt.maki.simonstrator.api.Randoms; import de.tudarmstadt.maki.simonstrator.api.Randoms;
import de.tudarmstadt.maki.simonstrator.api.util.Distribution; import de.tudarmstadt.maki.simonstrator.api.util.Distribution;
...@@ -32,12 +31,12 @@ import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor; ...@@ -32,12 +31,12 @@ import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
public class PoissonDistribution implements Distribution { public class PoissonDistribution implements Distribution {
private double lambda; private double lambda;
private PoissonDistributionImpl poisson; private org.apache.commons.math3.distribution.PoissonDistribution poisson;
@XMLConfigurableConstructor({"lambda"}) @XMLConfigurableConstructor({"lambda"})
public PoissonDistribution(double lambda){ public PoissonDistribution(double lambda){
this.lambda = lambda; this.lambda = lambda;
this.poisson = new PoissonDistributionImpl(lambda); this.poisson = new org.apache.commons.math3.distribution.PoissonDistribution(lambda);
} }
// returns the x-value for a random value in the cdf // returns the x-value for a random value in the cdf
...@@ -48,7 +47,7 @@ public class PoissonDistribution implements Distribution { ...@@ -48,7 +47,7 @@ public class PoissonDistribution implements Distribution {
try { try {
result = poisson.inverseCumulativeProbability(random); result = poisson.inverseCumulativeProbability(random);
} catch (MathException e) { } catch (OutOfRangeException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
result = 0; result = 0;
...@@ -64,10 +63,10 @@ public class PoissonDistribution implements Distribution { ...@@ -64,10 +63,10 @@ public class PoissonDistribution implements Distribution {
*/ */
public static double returnValue(double _lamda) { public static double returnValue(double _lamda) {
try { try {
PoissonDistributionImpl d = new PoissonDistributionImpl(_lamda); org.apache.commons.math3.distribution.PoissonDistribution d = new org.apache.commons.math3.distribution.PoissonDistribution(_lamda);
return d.inverseCumulativeProbability(Randoms.getRandom( return d.inverseCumulativeProbability(Randoms.getRandom(
PoissonDistribution.class).nextDouble()); PoissonDistribution.class).nextDouble());
} catch (MathException e) { } catch (OutOfRangeException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
return 0; return 0;
......
...@@ -20,9 +20,8 @@ ...@@ -20,9 +20,8 @@
package de.tud.kom.p2psim.impl.util.stats; package de.tud.kom.p2psim.impl.util.stats;
import org.apache.commons.math.MathException; import org.apache.commons.math3.distribution.TDistribution;
import org.apache.commons.math.distribution.TDistribution; import org.apache.commons.math3.exception.OutOfRangeException;
import org.apache.commons.math.distribution.TDistributionImpl;
/** /**
* As it is not possible to get a perfect estimate of the population mean from * As it is not possible to get a perfect estimate of the population mean from
...@@ -55,14 +54,14 @@ public class ConfidenceInterval { ...@@ -55,14 +54,14 @@ public class ConfidenceInterval {
* @return the upper/lower bound as positiv number * @return the upper/lower bound as positiv number
*/ */
public static double getDeltaBound(double sdev, int n, double alpha) { public static double getDeltaBound(double sdev, int n, double alpha) {
TDistribution tDist = new TDistributionImpl(n - 1); TDistribution tDist = new TDistribution(n - 1);
double errorConfCoeff = 1d - (alpha / 2); double errorConfCoeff = 1d - (alpha / 2);
double delta; double delta;
try { try {
double t = Math.abs(tDist double t = Math.abs(tDist
.inverseCumulativeProbability(errorConfCoeff)); .inverseCumulativeProbability(errorConfCoeff));
delta = t * sdev / Math.sqrt(n); delta = t * sdev / Math.sqrt(n);
} catch (MathException e) { } catch (OutOfRangeException e) {
throw new IllegalStateException(e); throw new IllegalStateException(e);
} }
return delta; return delta;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment