JavaDoc erweitert.

This commit is contained in:
Armin Wolf 2017-10-15 15:21:53 +02:00
parent 5b177b36e3
commit 80d132516e
8 changed files with 184 additions and 343 deletions

View File

@ -15,17 +15,6 @@ public class YOrderLineComparatorBegin implements Comparator<Line> {
@Override
public int compare(Line o1, Line o2) {
// if (o1.getY1() == o2.getY1()) {
// if (o1.getX1() <= o2.getX1()) {
// return -1;
// } else {
// return 1;
// }
// } else if (o1.getY1() < o2.getY1()) {
// return -1;
// } else {
// return 1;
// }
return o1.getY1().compareTo(o2.getY1());
}
}

View File

@ -15,17 +15,6 @@ public class YOrderLineComparatorEnd implements Comparator<Line> {
@Override
public int compare(Line o1, Line o2) {
// if (o1.getY2() == o2.getY2()) {
// if (o1.getX2() <= o2.getX2()) {
// return -1;
// } else {
// return 1;
// }
// } else if (o1.getY2() < o2.getY2()) {
// return -1;
// } else {
// return 1;
// }
return o1.getY2().compareTo(o2.getY2());
}
}

View File

@ -39,15 +39,19 @@ public class LeastMedianOfSquaresEstimator extends Observable implements Algorit
private Double slope;
private Double yInterception;
/**
* Konstruktor
* @param set Liste der Geraden
* @param intersections Liste der Schnittpunkte
* @param presenter Presenter (Beobachter)
*/
public LeastMedianOfSquaresEstimator(LinkedList<Line> set, ArrayList<Point> intersections,
Presenter presenter) {
this.set = set;
this.intersections = intersections;
//(1.) Let n <- |S|; q+ <- q; q- <- q+ * (1 - quantileError);....
n = set.size();
double quantile = 0.5;
double qPlus = quantile;
double qPlus = 0.5;
quantileError = 0.1;
double qMinus = qPlus * (1 - quantileError);
kMinus = (int) Math.ceil(n * qMinus);
@ -55,12 +59,22 @@ public class LeastMedianOfSquaresEstimator extends Observable implements Algorit
this.presenter = presenter;
}
/**
* Konstruktor
* @param set Liste der Geraden
* @param intersections Liste der Schnittpunkte
*/
public LeastMedianOfSquaresEstimator(LinkedList<Line> set, ArrayList<Point> intersections) {
this(set, intersections, null);
}
/**
* Algorithmus zum berechnen des LMS-Schätzers
*
* Paper:
* Mount, David M, Nathan S Netanyahu, Kathleen Romanik, Ruth Silverman und Angela Y Wu
* A practical approximation algorithm for the LMS line estimator. 2007
* Computational statistics & data Analysis 51.5, S. 24612486
*/
public void run() {
@ -110,7 +124,6 @@ public class LeastMedianOfSquaresEstimator extends Observable implements Algorit
intersectionsPoint = null;
}
}
if (intersectionsPoint != null) {
splitActiveSlab(intersectionsPoint, interval);
//(d.) this may update sigma min
@ -130,8 +143,6 @@ public class LeastMedianOfSquaresEstimator extends Observable implements Algorit
this.intervals.poll();
}
}
} else {
this.intervals.remove(interval);
}
@ -141,23 +152,21 @@ public class LeastMedianOfSquaresEstimator extends Observable implements Algorit
}
/**
* @param interval
* @return
* Liefert die Anzahl der Schnittpunkte in einem Intervall
* @param interval Intervall
* @return Anzahl der Schnittpunkte
*/
public int countInversions(Interval interval) {
int numberOfInversions = 0;
// debug
//for (int i=0;i<listA.size();i++){
// System.out.println(listA.get(i)+", "+listB.get(i));
//}
numberOfInversions = invCounter.run(set, interval);
return numberOfInversions;
return invCounter.run(set, interval);
}
/**
* In der Literatur wird ein planesweep vorrausgesetzt um in einem Intervall das minimale kMinus Segment zu
* identifizieren. An dieser Stelle wird eine naivere Lösung verwendet, mithilfe der Schleife werden alle
* Schnittpunkte betrachtet und bei passenden x-Koordinaten werden wird die vertikale Gerade auf kMinus Segmente
* untersucht.
*
* @param interval
* @return
*/
@ -204,7 +213,9 @@ public class LeastMedianOfSquaresEstimator extends Observable implements Algorit
}
/**
* @param point
* Zu einer vertikalen Gerade werden kMinus Segmente erzeugt und geprüft ob eine bessere Lösung
* als SigmaMin vorliegt.
* @param point x-Koordinate zur Konstruktion der vertikalen Gerade
*/
public void upperBound(double point) {
@ -234,8 +245,8 @@ public class LeastMedianOfSquaresEstimator extends Observable implements Algorit
}
/**
* @param pslab
* @return
* Die Methode prüft ob das übergebene Intervall die untere Schranke einer potenziellen Lösung erfüllt.
* @param pslab übergebene Intervall
*/
public void lowerBound(Interval pslab) {
@ -368,110 +379,71 @@ public class LeastMedianOfSquaresEstimator extends Observable implements Algorit
}
/**
* Im Allgemeinen werden keine Getter und Setter Methoden benötigt aber sie sind nützlich bei den
* JUnit Testfällen.
* @return Anzahl der Geraden
*/
public LinkedList<Line> getSet() {
return set;
}
public void setSet(LinkedList<Line> set) {
this.set = set;
}
public ArrayList<Point> getIntersections() {
return intersections;
}
public void setIntersections(ArrayList<Point> intersections) {
this.intersections = intersections;
}
public int getN() {
return n;
}
/**
* @param n Anzahl der Geraden
*/
public void setN(int n) {
this.n = n;
}
public double getQuantileError() {
return quantileError;
}
/**
* @param quantileError Parameter quantile Fehler
*/
public void setQuantileError(double quantileError) {
this.quantileError = quantileError;
}
public int getkPlus() {
return kPlus;
}
public void setkPlus(int kPlus) {
this.kPlus = kPlus;
}
public int getkMinus() {
return kMinus;
}
/**
* @param kMinus kMinus index
*/
public void setkMinus(int kMinus) {
this.kMinus = kMinus;
}
public Interval getSubSlabU1() {
return subSlabU1;
}
public void setSubSlabU1(Interval subSlabU1) {
this.subSlabU1 = subSlabU1;
}
public Interval getSubSlabU2() {
return subSlabU2;
}
public void setSubSlabU2(Interval subSlabU2) {
this.subSlabU2 = subSlabU2;
}
/**
* @return duale Streifen Sigma_min
*/
public Line getSigmaMin() {
return sigmaMin;
}
/**
* @param sigmaMin duale Streifen Sigma_min
*/
public void setSigmaMin(Line sigmaMin) {
this.sigmaMin = sigmaMin;
}
public double getHeightsigmaMin() {
return heightsigmaMin;
}
/**
* @param heightsigmaMin höhe von Sigma_min
*/
public void setHeightsigmaMin(double heightsigmaMin) {
this.heightsigmaMin = heightsigmaMin;
}
public double getIntersectionsPoint() {
return intersectionsPoint;
}
public void setIntersectionsPoint(double intersectionsPoint) {
this.intersectionsPoint = intersectionsPoint;
}
public Double getConstant() {
return constant;
}
/**
* @param constant Parameter Konstante
*/
public void setConstant(Double constant) {
this.constant = constant;
}
/**
* @return Steigung
*/
public Double getSlope() {
return slope;
}
/**
* @return y-Achsenabschnitt
*/
public Double getyInterception() {
return yInterception;
}

View File

@ -54,7 +54,11 @@ public class RepeatedMedianEstimator extends Observable implements Algorithm {
private Double slope;
private Double yInterception;
/**
* Konstruktor
* @param set Liste der Geraden
* @param presenter Presenter (Beobachter)
*/
public RepeatedMedianEstimator(LinkedList<Line> set, Presenter presenter) {
this.set = set;
this.presenter = presenter;
@ -78,12 +82,21 @@ public class RepeatedMedianEstimator extends Observable implements Algorithm {
linePairs = new HashMap<>();
}
/**
* Konstruktor
* @param set Liste der Geraden
*/
public RepeatedMedianEstimator(LinkedList<Line> set) {
this(set, null);
}
/**
* Führt den Algortihmus zur Berechnung des RM-Schätzers durch.
*
* Paper:
* Matousek, Jiri, D. M. Mount und N. S. Netanyahu
* Efficient Randomized Algorithms for the Repeated Median Line Estimator. 1998
* Algorithmica 20.2, S. 136150
*/
public void run() {
@ -97,8 +110,8 @@ public class RepeatedMedianEstimator extends Observable implements Algorithm {
r = Math.ceil(Math.pow(n, beta));
ArrayList<Line> lines = RandomSampler.run(linesInCenterSlab, r, linesInCenterSlab.size());
//For each Sampled Line, compute its median intersection abscissa
//Für jede Gerade aus der Stichprobe wird der Schnittpunkt mit der medianen
//x-Koordinate bestimmt
ArrayList<Double> medianIntersectionAbscissas = new ArrayList<>();
for (Line l : lines) {
Double abscissa = estimateMedianIntersectionAbscissas(l);
@ -106,26 +119,20 @@ public class RepeatedMedianEstimator extends Observable implements Algorithm {
medianIntersectionAbscissas.add(abscissa);
}
//rank of the repeated median in C
//Rang vom RM-Wert in C
k = Math.max(1, Math.min(set.size(), (Math.ceil(n * 0.5) - linesInLeftSlab.size())));
//compute k_lo and k_hi
//berechne k_lo und k_hi
computeSlabBorders();
// if (medianIntersectionAbscissas.size() < kLow || medianIntersectionAbscissas.size()<kHigh || kLow < 0 || kHigh<0 )
// System.err.print("#medianIntersectionAbscissa: "+medianIntersectionAbscissas.size()+"\t\t klow: "+kLow+" kHigh: "+kHigh+"\n\n");
//Employ fast selection algorithm to determine the Elements Theta_lo and Theta_hi
//Berechne die Elemente mit dem Rang Theta_lo und Theta_hi
thetaLow = FastElementSelector.randomizedSelect(medianIntersectionAbscissas, kLow);
thetaHigh = FastElementSelector.randomizedSelect(medianIntersectionAbscissas, kHigh);
//For each dual Line in C count the number of intersection abscissas that lie
//in each of the intervals.
//Für jede Gerade in C wird die Anzahl der Schnittpunkte die im Intervall liegen hochgezählt
countNumberOfIntersectionsAbscissas();
//Based on this 3 counts, determine which of the subintervals contains the repeated median
//and contract to this subiinterval.
//verkleinere das Intervall
contractIntervals();
}
@ -133,38 +140,19 @@ public class RepeatedMedianEstimator extends Observable implements Algorithm {
System.out.println("Zeit: "+ ((end-start)/1000));
}
/**
* @param set
* @param r
* @return
*/
public ArrayList<Line> sampleLines(ArrayList<Line> set, Double r) {
ArrayList<Line> sampledLines = new ArrayList<>();
for (int i = 0; i < r; i++) {
sampledLines.add(set.get(ThreadLocalRandom.current().nextInt(0, linesInCenterSlab.size())));
}
return sampledLines;
}
/**
* @param sampledLine
* @return
* Berechnet die mediane x-Koordinate über den Schnittpunkten.
*
* @param sampledLine Stichprobe von Geraden
* @return mediane x-Koordinate über den Schnittpunkten
*/
public Double estimateMedianIntersectionAbscissas(Line sampledLine) {
Integer index = Integer.parseInt(sampledLine.getId());
ArrayList<Double> intersections = new ArrayList<>();
double intersection;
IntersectionCounter intersectionCounter = new IntersectionCounter();
intersections = intersectionCounter.calculateIntersectionAbscissas(linesInCenterSlab, sampledLine);
ArrayList<Double> intersections = intersectionCounter.calculateIntersectionAbscissas(linesInCenterSlab, sampledLine);
//Collections.sort(intersections);
//double ki = Math.ceil((n - 1) / 2) - countLeftSlab.get(index);
//double i = (Math.ceil((Math.sqrt(n) * ki) / countCenterSlab.get(index)));
double ki = Math.ceil((n - 1) / 2) - FastElementSelector.randomizedSelect(countLeftSlab, index);
double i = (Math.ceil((Math.sqrt(n) * ki) / FastElementSelector.randomizedSelect(countCenterSlab, index)));
int accessIndex;
@ -175,36 +163,25 @@ public class RepeatedMedianEstimator extends Observable implements Algorithm {
else
accessIndex = (int) i;
//System.out.println(accessIndex);
//return intersections.get(accessIndex);
return FastElementSelector.randomizedSelect(intersections, accessIndex);
}
/**
*
* Berechnet die potenziell neuen Intervallgrenzen.
*/
public void computeSlabBorders() {
kLow = Math
.max(1, Math.floor(
((r * k) / (linesInCenterSlab.size()))
- ((3 * Math.sqrt(r)) / (2))
)
);
kHigh = Math
.min(r, Math.floor(
((r * k) / (linesInCenterSlab.size()))
+ ((3 * Math.sqrt(r)) / (2))
)
);
kLow = Math.max(1, Math.floor(((r * k) / (linesInCenterSlab.size()))
- ((3 * Math.sqrt(r)) / (2))));
kHigh = Math.min(r, Math.floor(((r * k) / (linesInCenterSlab.size()))
+ ((3 * Math.sqrt(r)) / (2))));
}
/**
*
* Berechnet die Anzahl der Schnittpunkte pro Bereich. Insgesammt gibt es drei Bereiche:
* Im Intervall => (a,b], vor dem Intervall => (a', a], hinter dem Intervall => (b, b'].
*/
public void countNumberOfIntersectionsAbscissas() {
for (Line line : linesInCenterSlab) {
ArrayList<Double> intersections = intersectionAbscissas.get(line);
Integer index = Integer.parseInt(line.getId());
@ -222,7 +199,6 @@ public class RepeatedMedianEstimator extends Observable implements Algorithm {
}
}
//System.out.println("Linie: "+line.getId()+"\tLeft: "+left+"\t Center: "+center+"\t Right: "+right);
countLeftSlab.set(index, (double) left);
countCenterSlab.set(index, (double) center);
countRightSlab.set(index, (double) right);
@ -231,7 +207,8 @@ public class RepeatedMedianEstimator extends Observable implements Algorithm {
}
/**
*
* Verkleinert das aktuelle Intervall. Eines der drei Bereiche wird als neues Intervall gewählt.
* Auf diesem Intervall werden dann in der nächsten Iteration wieder drei Bereiche bestimmt.
*/
public void contractIntervals() {
for (int i = 0; i < linesInCenterSlab.size(); i++) {
@ -249,21 +226,6 @@ public class RepeatedMedianEstimator extends Observable implements Algorithm {
linesInRightSlab.add(linesInCenterSlab.get(i));
linesInCenterSlab.remove(i);
}
// if (medianIntersections.get(linesInCenterSlab.get(i)) != null) {
// if (medianIntersections.get(linesInCenterSlab.get(i)) <= thetaLow) {
// linesInLeftSlab.add(linesInCenterSlab.get(i));
// linesInCenterSlab.remove(i);
// countLeftSlab.set(i, countLeftSlab.get(i) + 1);
// countCenterSlab.set(i, countCenterSlab.get(i) - 1);
// } else if (medianIntersections.get(linesInCenterSlab.get(i)) > thetaHigh) {
// linesInRightSlab.add(linesInCenterSlab.get(i));
// linesInCenterSlab.remove(i);
// countRightSlab.set(i, countRightSlab.get(i) + 1);
// countCenterSlab.set(i, countCenterSlab.get(i) - 1);
// }
// }
// }
//
}
//wähle C als C
@ -305,163 +267,37 @@ public class RepeatedMedianEstimator extends Observable implements Algorithm {
/*******************************************************************************************************************
* Getter und Setter Methoden
******************************************************************************************************************/
public LinkedList<Line> getSet() {
return set;
}
public void setSet(LinkedList<Line> set) {
this.set = set;
}
public HashMap<Line, ArrayList<Line>> getLinePairs() {
return linePairs;
}
public void setLinePairs(HashMap<Line, ArrayList<Line>> linePairs) {
this.linePairs = linePairs;
}
public HashMap<Line, Double> getMedianIntersections() {
return medianIntersections;
}
public void setMedianIntersections(HashMap<Line, Double> medianIntersections) {
this.medianIntersections = medianIntersections;
}
public HashMap<Line, ArrayList<Double>> getIntersectionAbscissas() {
return intersectionAbscissas;
}
public void setIntersectionAbscissas(
HashMap<Line, ArrayList<Double>> intersectionAbscissas) {
this.intersectionAbscissas = intersectionAbscissas;
}
public Interval getInterval() {
return interval;
}
public void setInterval(Interval interval) {
this.interval = interval;
}
public ArrayList<Double> getCountLeftSlab() {
return countLeftSlab;
}
public void setCountLeftSlab(ArrayList<Double> countLeftSlab) {
this.countLeftSlab = countLeftSlab;
}
public ArrayList<Double> getCountCenterSlab() {
return countCenterSlab;
}
public void setCountCenterSlab(ArrayList<Double> countCenterSlab) {
this.countCenterSlab = countCenterSlab;
}
public ArrayList<Double> getCountRightSlab() {
return countRightSlab;
}
public void setCountRightSlab(ArrayList<Double> countRightSlab) {
this.countRightSlab = countRightSlab;
}
public ArrayList<Line> getLinesInLeftSlab() {
return linesInLeftSlab;
}
public void setLinesInLeftSlab(ArrayList<Line> linesInLeftSlab) {
this.linesInLeftSlab = linesInLeftSlab;
}
public ArrayList<Line> getLinesInCenterSlab() {
return linesInCenterSlab;
}
public void setLinesInCenterSlab(ArrayList<Line> linesInCenterSlab) {
this.linesInCenterSlab = linesInCenterSlab;
}
public ArrayList<Line> getLinesInRightSlab() {
return linesInRightSlab;
}
public void setLinesInRightSlab(ArrayList<Line> linesInRightSlab) {
this.linesInRightSlab = linesInRightSlab;
}
public Double getR() {
return r;
}
public void setR(Double r) {
this.r = r;
}
/**
* @return Anzahl der Geraden
*/
public Integer getN() {
return n;
}
/**
* @param n Anzahl der Geraden
*/
public void setN(Integer n) {
this.n = n;
}
public Double getK() {
return k;
}
public void setK(Double k) {
this.k = k;
}
public Double getkLow() {
return kLow;
}
public void setkLow(Double kLow) {
this.kLow = kLow;
}
public Double getkHigh() {
return kHigh;
}
public void setkHigh(Double kHigh) {
this.kHigh = kHigh;
}
public Double getBeta() {
return beta;
}
/**
* @param beta Parameter Beta
*/
public void setBeta(Double beta) {
this.beta = beta;
}
public Double getThetaLow() {
return thetaLow;
}
public void setThetaLow(Double thetaLow) {
this.thetaLow = thetaLow;
}
public Double getThetaHigh() {
return thetaHigh;
}
public void setThetaHigh(Double thetaHigh) {
this.thetaHigh = thetaHigh;
}
/**
* @return Steigung
*/
public Double getSlope() {
return slope;
}
/**
* @return y-Achsenabschnitt
*/
public Double getyInterception() {
return yInterception;
}

View File

@ -44,7 +44,12 @@ public class TheilSenEstimator extends Observable implements Algorithm {
private Double slope;
private Double yInterception;
/**
* Konstruktor
* @param setOfLines Liste der Geraden
* @param setOfIntersections Liste der Schnittpunkte
* @param presenter Presenter (Beobachter)
*/
public TheilSenEstimator(LinkedList<Line> setOfLines, ArrayList<Point> setOfIntersections, Presenter presenter) {
this.presenter = presenter;
this.setOfLines = new ArrayList<>(setOfLines);
@ -60,6 +65,11 @@ public class TheilSenEstimator extends Observable implements Algorithm {
this.k = (int) (N / 2);
}
/**
* Konstruktor
* @param setOfLines Liste der Geraden
* @param setOfIntersections Liste der Schnittpunkte
*/
public TheilSenEstimator(LinkedList<Line> setOfLines, ArrayList<Point> setOfIntersections) {
this(setOfLines, setOfIntersections, null);
}
@ -224,11 +234,16 @@ public class TheilSenEstimator extends Observable implements Algorithm {
}
}
/**
* @return Steigung
*/
public Double getSlope() {
return slope;
}
/**
* @return y-Achsenabschnitt
*/
public Double getyInterception() {
return yInterception;
}

View File

@ -22,13 +22,19 @@ public class NaivLeastMedianOfSquaresEstimator implements Algorithm {
private Integer n;
private Double ds, b, m;
/**
* Konstruktor
* @param lines Liste des Geraden
*/
public NaivLeastMedianOfSquaresEstimator(LinkedList<Line> lines) {
for (Line l : lines) {
set.add(new Point(l.getM(), l.getB()));
}
}
/**
* Crude Algorithmus zum berechnen des LSM-Schätzers.
*/
private void crudeAlg() {
ds = Double.MAX_VALUE;
b = 0d;
@ -55,7 +61,6 @@ public class NaivLeastMedianOfSquaresEstimator implements Algorithm {
ds = dijk;
b = alpha;
m = beta;
// System.out.printf("Distanz: %6.2f\tAlpha: %6.2f\tBeta: %6.2f",ds,b,m);
}
triple.clear();
}
@ -65,7 +70,12 @@ public class NaivLeastMedianOfSquaresEstimator implements Algorithm {
System.out.println("Zeit: "+ ((end-start)/1000));
}
/**
* Berechnet die Gerade mit dem medianen Fehler
* @param a y-Achsenabschnitt
* @param b Steigung
* @return medianer Fehler
*/
private Double f(Double a, Double b) {
ArrayList<Double> res = new ArrayList<>();
for (Point p : set) {
@ -84,10 +94,16 @@ public class NaivLeastMedianOfSquaresEstimator implements Algorithm {
}
/**
* @return y-Achsenabschnitt
*/
public Double getB() {
return b * -1;
}
/**
* @return Steigung
*/
public Double getM() {
return m * -1;
}

View File

@ -25,6 +25,10 @@ public class NaivRepeatedMedianEstimator implements Algorithm {
private Double medianX;
private Double medianY;
/**
* Konstruktor
* @param lines Liste der Geraden
*/
public NaivRepeatedMedianEstimator(LinkedList<Line> lines) {
this.lines = lines;
slopesPerLine = new HashMap<>();
@ -50,18 +54,17 @@ public class NaivRepeatedMedianEstimator implements Algorithm {
}
}
//calculate all slopes for each line
Point ret;
for (int i = 0; i < lines.size(); i++) {
for (int j = i + 1; j < lines.size(); j++) {
ret = calculateSlope(lines.get(i), lines.get(j));
ret = calculateLine(lines.get(i), lines.get(j));
slopesPerLine.get(lines.get(i).getId()).add(ret.getX());
interceptPerLine.get(lines.get(i).getId()).add(ret.getY());
}
}
//calculate median of slopes for each line
//berechne mediane Steigung
for (String l : slopesPerLine.keySet()) {
ArrayList<Double> list = slopesPerLine.get(l);
int size = list.size() / 2;
@ -71,7 +74,7 @@ public class NaivRepeatedMedianEstimator implements Algorithm {
}
}
//calculate median of slopes for each line
//berechne medianen y-Achsenabschnitt
for (String l : interceptPerLine.keySet()) {
ArrayList<Double> list = interceptPerLine.get(l);
int size = list.size() / 2;
@ -92,22 +95,28 @@ public class NaivRepeatedMedianEstimator implements Algorithm {
}
private Point calculateSlope(Line lineA, Line lineB) {
/**
* Berechnet die Geraden zwischen zwei Punkten im dualen Raum.
* @param startPoint Gerade 1 => Startpunkt mit den Koordianten (m,b)
* @param endPoint Gerade 2 => Endpunkt mit den Koordianten (m', b')
* @return
*/
private Point calculateLine(Line startPoint, Line endPoint) {
Double xi;
Double xj;
Double yi;
Double yj;
if (lineB.getM() > lineA.getM()) {
xi = lineA.getM();
yi = lineA.getB();
xj = lineB.getM();
yj = lineB.getB();
if (endPoint.getM() > startPoint.getM()) {
xi = startPoint.getM();
yi = startPoint.getB();
xj = endPoint.getM();
yj = endPoint.getB();
} else {
xj = lineA.getM();
yj = lineA.getB();
xi = lineB.getM();
yi = lineB.getB();
xj = startPoint.getM();
yj = startPoint.getB();
xi = endPoint.getM();
yi = endPoint.getB();
}
@ -116,10 +125,16 @@ public class NaivRepeatedMedianEstimator implements Algorithm {
return new Point(m, b);
}
/**
* @return Steigung
*/
public Double getM() {
return medianX * -1;
}
/**
* @return y-Achsenabschnitt
*/
public Double getB() {
return medianY * -1;
}

View File

@ -21,6 +21,10 @@ public class NaivTheilSenEstimator implements Algorithm {
private Double slope;
private Double yInterception;
/**
* Konstruktor
* @param lines Liste der Geraden
*/
public NaivTheilSenEstimator(LinkedList<Line> lines) {
this.lines = lines;
this.slope = 0d;
@ -69,11 +73,16 @@ public class NaivTheilSenEstimator implements Algorithm {
}
/**
* @return Steigung
*/
public Double getM() {
return slope * -1;
}
/**
* @return y-Achsenabschnitt
*/
public Double getB() {
return yInterception * -1;
}