WIP: LeastMedianOfSquaresEstimator - Mount et al - Algorithm #2
This commit is contained in:
parent
f3df50d86d
commit
ca72648c26
|
@ -1,5 +1,12 @@
|
|||
package Presenter.Algorithms;
|
||||
|
||||
import Model.Coordinates;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
/**
|
||||
* Implementierung verschiedener Algorithmen zur Berechnung von Ausgleichsgeraden.
|
||||
*
|
||||
|
@ -8,4 +15,115 @@ package Presenter.Algorithms;
|
|||
* @Date: 28.05.2017.
|
||||
*/
|
||||
public class LeastMedianOfSquaresEstimator extends Algorithm {
|
||||
|
||||
|
||||
private LinkedList<Coordinates> set = new LinkedList<>();
|
||||
private int n;
|
||||
private double quantile = 0.5;
|
||||
private double quantileError;
|
||||
private double qPlus;
|
||||
private double qMinus;
|
||||
private double kPlus;
|
||||
private double kMinus;
|
||||
private Set<Slab> slab;
|
||||
private Slab activeSlab;
|
||||
private Slab subSlabU1;
|
||||
private Slab subSlabU2;
|
||||
private double umin;
|
||||
private double umax;
|
||||
private double heightsigmaMin;
|
||||
private int numberOfIntersections;
|
||||
private final int constant = 1;
|
||||
private Coordinates kMinusBracelet;
|
||||
private double intersectionsPoint;
|
||||
|
||||
/**
|
||||
* Hilfsklasse um die Slabs zu verteilen, private Klasse da sonst nicht verwendett wird und somit eine
|
||||
* äußere Klasse überflüssig ist...
|
||||
*/
|
||||
private static class Slab {
|
||||
private double upper;
|
||||
private double lower;
|
||||
|
||||
public Slab(double lower, double upper) {
|
||||
this.upper = upper;
|
||||
this.lower = lower;
|
||||
}
|
||||
|
||||
public double getUpper() {
|
||||
return upper;
|
||||
}
|
||||
|
||||
public void setUpper(double upper) {
|
||||
this.upper = upper;
|
||||
}
|
||||
|
||||
public double getLower() {
|
||||
return lower;
|
||||
}
|
||||
|
||||
public void setLower(double lower) {
|
||||
this.lower = lower;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void approximateLMS(){
|
||||
//(1.) Let n <- |S|; q+ <- q; q- <- q+ * (1 - quantileError);....
|
||||
n = set.size();
|
||||
qPlus = quantile;
|
||||
qMinus = qPlus * (1 - quantileError);
|
||||
kMinus = Math.ceil(n * qMinus);
|
||||
kPlus = Math.ceil(n * qPlus);
|
||||
|
||||
//(2.) Let U <- (-inf, inf) be the initial active slab...
|
||||
slab = new TreeSet<>();
|
||||
slab.add(new Slab(Double.MAX_VALUE, Double.MIN_VALUE));
|
||||
heightsigmaMin = Double.MAX_VALUE;
|
||||
|
||||
//(3.) Apply the following steps as long as the exists active slabs
|
||||
for(Iterator<Slab> it = slab.iterator(); it.hasNext();){
|
||||
//(a.) Select any active Slab and calc. the inversions
|
||||
activeSlab = it.next();
|
||||
numberOfIntersections = countInversions(activeSlab);
|
||||
|
||||
//(b.) apply plane sweep
|
||||
if ( numberOfIntersections < (constant * n)){
|
||||
kMinusBracelet = planeSweep(activeSlab);
|
||||
} else {//(c.) otherwise....
|
||||
//get random intersections point...
|
||||
splitActiveSlab(intersectionsPoint);
|
||||
}
|
||||
//(d.) this may update sigma min
|
||||
upperBound(intersectionsPoint);
|
||||
|
||||
//(e.) for i={1,2}, call lower bound(Ui)
|
||||
lowerBound(subSlabU1);
|
||||
lowerBound(subSlabU2);
|
||||
}
|
||||
}
|
||||
|
||||
//Parameter anpassen
|
||||
public int countInversions(Slab slab){
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Coordinates planeSweep(Slab slab){
|
||||
return new Coordinates(.0, .0);
|
||||
}
|
||||
|
||||
public void splitActiveSlab(double point){
|
||||
subSlabU1 = new Slab(activeSlab.getLower(), point);
|
||||
subSlabU2 = new Slab(point, activeSlab.getUpper());
|
||||
}
|
||||
|
||||
public void upperBound(double point){
|
||||
|
||||
}
|
||||
|
||||
public void lowerBound(Slab slab){
|
||||
|
||||
// if Ui is active on return add it to the list of active slabs..!!!
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ public class MainFrame extends JFrame {
|
|||
arrangementDialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
|
||||
plotDialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
|
||||
|
||||
this.slider = new JSlider(JSlider.HORIZONTAL, 10, 100, 10);
|
||||
this.slider = new JSlider(JSlider.HORIZONTAL, 10, 300, 10);
|
||||
this.slider.addChangeListener(new ChangeListener() {
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
|
@ -123,7 +123,7 @@ public class MainFrame extends JFrame {
|
|||
public void run() {
|
||||
JSlider source = (JSlider) e.getSource();
|
||||
arrangement.setScale((double) source.getValue() / 10);
|
||||
int thicknes = 100 / source.getValue();
|
||||
int thicknes = 50 / source.getValue();
|
||||
if (thicknes == 0) {
|
||||
arrangement.setPointThicknes(1);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue