From 80d132516ef78c3ffdccd8e7a9265eae0a868bdc Mon Sep 17 00:00:00 2001 From: Armin Wolf Date: Sun, 15 Oct 2017 15:21:53 +0200 Subject: [PATCH] JavaDoc erweitert. --- .../YOrderLineComparatorBegin.java | 11 - .../Comparators/YOrderLineComparatorEnd.java | 11 - .../LeastMedianOfSquaresEstimator.java | 146 ++++------ .../advanced/RepeatedMedianEstimator.java | 264 ++++-------------- .../advanced/TheilSenEstimator.java | 19 +- .../NaivLeastMedianOfSquaresEstimator.java | 22 +- .../naiv/NaivRepeatedMedianEstimator.java | 43 ++- .../naiv/NaivTheilSenEstimator.java | 11 +- 8 files changed, 184 insertions(+), 343 deletions(-) diff --git a/LinearRegressionTool/src/main/java/presenter/algorithms/Comparators/YOrderLineComparatorBegin.java b/LinearRegressionTool/src/main/java/presenter/algorithms/Comparators/YOrderLineComparatorBegin.java index e6999ce..7662344 100644 --- a/LinearRegressionTool/src/main/java/presenter/algorithms/Comparators/YOrderLineComparatorBegin.java +++ b/LinearRegressionTool/src/main/java/presenter/algorithms/Comparators/YOrderLineComparatorBegin.java @@ -15,17 +15,6 @@ public class YOrderLineComparatorBegin implements Comparator { @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()); } } \ No newline at end of file diff --git a/LinearRegressionTool/src/main/java/presenter/algorithms/Comparators/YOrderLineComparatorEnd.java b/LinearRegressionTool/src/main/java/presenter/algorithms/Comparators/YOrderLineComparatorEnd.java index 704231f..64276b1 100644 --- a/LinearRegressionTool/src/main/java/presenter/algorithms/Comparators/YOrderLineComparatorEnd.java +++ b/LinearRegressionTool/src/main/java/presenter/algorithms/Comparators/YOrderLineComparatorEnd.java @@ -15,17 +15,6 @@ public class YOrderLineComparatorEnd implements Comparator { @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()); } } diff --git a/LinearRegressionTool/src/main/java/presenter/algorithms/advanced/LeastMedianOfSquaresEstimator.java b/LinearRegressionTool/src/main/java/presenter/algorithms/advanced/LeastMedianOfSquaresEstimator.java index 095291e..8e5e77b 100644 --- a/LinearRegressionTool/src/main/java/presenter/algorithms/advanced/LeastMedianOfSquaresEstimator.java +++ b/LinearRegressionTool/src/main/java/presenter/algorithms/advanced/LeastMedianOfSquaresEstimator.java @@ -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 set, ArrayList 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 set, ArrayList 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. 2461–2486 */ 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 getSet() { - return set; - } - - public void setSet(LinkedList set) { - this.set = set; - } - - public ArrayList getIntersections() { - return intersections; - } - - public void setIntersections(ArrayList 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; } diff --git a/LinearRegressionTool/src/main/java/presenter/algorithms/advanced/RepeatedMedianEstimator.java b/LinearRegressionTool/src/main/java/presenter/algorithms/advanced/RepeatedMedianEstimator.java index 5c19759..67c7957 100644 --- a/LinearRegressionTool/src/main/java/presenter/algorithms/advanced/RepeatedMedianEstimator.java +++ b/LinearRegressionTool/src/main/java/presenter/algorithms/advanced/RepeatedMedianEstimator.java @@ -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 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 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. 136–150 */ public void run() { @@ -97,8 +110,8 @@ public class RepeatedMedianEstimator extends Observable implements Algorithm { r = Math.ceil(Math.pow(n, beta)); ArrayList 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 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() sampleLines(ArrayList set, Double r) { - - ArrayList 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 intersections = new ArrayList<>(); - double intersection; - IntersectionCounter intersectionCounter = new IntersectionCounter(); - intersections = intersectionCounter.calculateIntersectionAbscissas(linesInCenterSlab, sampledLine); + ArrayList 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 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 getSet() { - return set; - } - - public void setSet(LinkedList set) { - this.set = set; - } - - public HashMap> getLinePairs() { - return linePairs; - } - - public void setLinePairs(HashMap> linePairs) { - this.linePairs = linePairs; - } - - public HashMap getMedianIntersections() { - return medianIntersections; - } - - public void setMedianIntersections(HashMap medianIntersections) { - this.medianIntersections = medianIntersections; - } - - public HashMap> getIntersectionAbscissas() { - return intersectionAbscissas; - } - - public void setIntersectionAbscissas( - HashMap> intersectionAbscissas) { - this.intersectionAbscissas = intersectionAbscissas; - } - - public Interval getInterval() { - return interval; - } - - public void setInterval(Interval interval) { - this.interval = interval; - } - - public ArrayList getCountLeftSlab() { - return countLeftSlab; - } - - public void setCountLeftSlab(ArrayList countLeftSlab) { - this.countLeftSlab = countLeftSlab; - } - - public ArrayList getCountCenterSlab() { - return countCenterSlab; - } - - public void setCountCenterSlab(ArrayList countCenterSlab) { - this.countCenterSlab = countCenterSlab; - } - - public ArrayList getCountRightSlab() { - return countRightSlab; - } - - public void setCountRightSlab(ArrayList countRightSlab) { - this.countRightSlab = countRightSlab; - } - - public ArrayList getLinesInLeftSlab() { - return linesInLeftSlab; - } - - public void setLinesInLeftSlab(ArrayList linesInLeftSlab) { - this.linesInLeftSlab = linesInLeftSlab; - } - - public ArrayList getLinesInCenterSlab() { - return linesInCenterSlab; - } - - public void setLinesInCenterSlab(ArrayList linesInCenterSlab) { - this.linesInCenterSlab = linesInCenterSlab; - } - - public ArrayList getLinesInRightSlab() { - return linesInRightSlab; - } - - public void setLinesInRightSlab(ArrayList 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; } diff --git a/LinearRegressionTool/src/main/java/presenter/algorithms/advanced/TheilSenEstimator.java b/LinearRegressionTool/src/main/java/presenter/algorithms/advanced/TheilSenEstimator.java index 260f562..910a0b0 100644 --- a/LinearRegressionTool/src/main/java/presenter/algorithms/advanced/TheilSenEstimator.java +++ b/LinearRegressionTool/src/main/java/presenter/algorithms/advanced/TheilSenEstimator.java @@ -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 setOfLines, ArrayList 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 setOfLines, ArrayList 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; } diff --git a/LinearRegressionTool/src/main/java/presenter/algorithms/naiv/NaivLeastMedianOfSquaresEstimator.java b/LinearRegressionTool/src/main/java/presenter/algorithms/naiv/NaivLeastMedianOfSquaresEstimator.java index 003e6f3..608a73c 100644 --- a/LinearRegressionTool/src/main/java/presenter/algorithms/naiv/NaivLeastMedianOfSquaresEstimator.java +++ b/LinearRegressionTool/src/main/java/presenter/algorithms/naiv/NaivLeastMedianOfSquaresEstimator.java @@ -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 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 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; } diff --git a/LinearRegressionTool/src/main/java/presenter/algorithms/naiv/NaivRepeatedMedianEstimator.java b/LinearRegressionTool/src/main/java/presenter/algorithms/naiv/NaivRepeatedMedianEstimator.java index 2746891..a7b698d 100644 --- a/LinearRegressionTool/src/main/java/presenter/algorithms/naiv/NaivRepeatedMedianEstimator.java +++ b/LinearRegressionTool/src/main/java/presenter/algorithms/naiv/NaivRepeatedMedianEstimator.java @@ -25,6 +25,10 @@ public class NaivRepeatedMedianEstimator implements Algorithm { private Double medianX; private Double medianY; + /** + * Konstruktor + * @param lines Liste der Geraden + */ public NaivRepeatedMedianEstimator(LinkedList 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 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 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; } diff --git a/LinearRegressionTool/src/main/java/presenter/algorithms/naiv/NaivTheilSenEstimator.java b/LinearRegressionTool/src/main/java/presenter/algorithms/naiv/NaivTheilSenEstimator.java index 7ef636e..ae81941 100644 --- a/LinearRegressionTool/src/main/java/presenter/algorithms/naiv/NaivTheilSenEstimator.java +++ b/LinearRegressionTool/src/main/java/presenter/algorithms/naiv/NaivTheilSenEstimator.java @@ -21,6 +21,10 @@ public class NaivTheilSenEstimator implements Algorithm { private Double slope; private Double yInterception; + /** + * Konstruktor + * @param lines Liste der Geraden + */ public NaivTheilSenEstimator(LinkedList 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; }