Skip to content
Snippets Groups Projects
Commit 1cf4e6d6 authored by Eilert Tunheim's avatar Eilert Tunheim
Browse files

Functional confidence interval shadow, but looks awful

parent 4b1ba270
No related branches found
No related tags found
No related merge requests found
......@@ -30,7 +30,7 @@ public final class Constants {
public static int NUMBER_OF_SECONDS_LIVE_DATA = 60;
// Confidence interval
public static final double CONFIDENCE_INTERVAL = 0.95;
public static final double CONFIDENCE_INTERVAL = 0.80;
// Non linear regression
public static final double ADJUST_REGRESSION = 5.0;
......
......@@ -11,6 +11,7 @@ import org.apache.commons.math3.distribution.TDistribution;
import org.apache.commons.math3.exception.MathIllegalArgumentException;
import org.apache.commons.math3.stat.descriptive.SummaryStatistics;
import org.apache.commons.math3.stat.regression.SimpleRegression;
import org.checkerframework.checker.units.qual.A;
import org.jblas.DoubleMatrix;
import org.jblas.Solve;
......@@ -84,7 +85,7 @@ public class LineChartFunctionality {
private static Map<Integer, ArrayList<Double>> statistics(Map<Integer, ArrayList<Double>> multiMap){
private static Map<Integer, ArrayList<Double>> statistics(Map<Integer, ArrayList<Double>> multiMap, boolean CIShadow){
//System.out.println("\n\nMultimap: \n");
for (Map.Entry<Integer, ArrayList<Double>> entry : multiMap.entrySet()) {
......@@ -104,10 +105,17 @@ public class LineChartFunctionality {
//System.out.println(String.format("Mean: %f", stats.getMean()));
double lower = stats.getMean() - ci;
double upper = stats.getMean() + ci;
//System.out.println(String.format("Confidence Interval "+CONFIDENCE_INTERVAL*100+"%%: %f, %f", lower, upper));
System.out.println(String.format("Confidence Interval "+Constants.CONFIDENCE_INTERVAL*100+"%%: %f, %f", lower, upper));
// Deletes entries if they are out of bounds with the confidence interval
entry.getValue().removeIf(value -> Double.compare(value, lower) < 0 || Double.compare(value, upper) > 0);
if(CIShadow){
ArrayList<Double> lowerUpperBounds = new ArrayList<>();
lowerUpperBounds.add(lower);
lowerUpperBounds.add(upper);
multiMap.replace(entry.getKey(), lowerUpperBounds);
}
//}
}
return multiMap;
......@@ -166,12 +174,13 @@ public class LineChartFunctionality {
// Finds the end datapoint at the end of each graph
int numberOfGraphs = 0;
ArrayList<Double> dataArraylistXAxis = new ArrayList<>();
ArrayList<Double> dataArraylistYAxis = new ArrayList<>();
//ArrayList<Double> confidenceIntervalShadowArrayList = new ArrayList<>();
Map<Integer, ArrayList<Double>> endOfGraphPointsXAxis = new HashMap<>();
Map<Integer, ArrayList<Double>> endOfGraphPointsYAxis = new HashMap<>();
//Map<Integer, ArrayList<Double>> confidenceIntervalShadowMap = new HashMap<>();
for (int i = 0; i < multiMap.size(); i++) {
ArrayList<Double> list = multiMap.get(i);
for (int j = 0; j < list.size(); j++) {
......@@ -200,8 +209,8 @@ public class LineChartFunctionality {
System.out.println(endOfGraphPointsXAxis);
System.out.println(endOfGraphPointsYAxis);
Map<Integer, ArrayList<Double>> endOfGraphPointsConfidenceXAxis = statistics(endOfGraphPointsXAxis);
Map<Integer, ArrayList<Double>> endOfGraphPointsConfidenceYaxis = statistics(endOfGraphPointsYAxis);
Map<Integer, ArrayList<Double>> endOfGraphPointsConfidenceXAxis = statistics(endOfGraphPointsXAxis,false);
Map<Integer, ArrayList<Double>> endOfGraphPointsConfidenceYaxis = statistics(endOfGraphPointsYAxis,false);
System.out.println("X-axis:"+ endOfGraphPointsConfidenceXAxis);
System.out.println("X-axis size: "+ endOfGraphPointsConfidenceXAxis.size());
......@@ -237,7 +246,7 @@ public class LineChartFunctionality {
// Stores the data from the confidence interval in a new map
Map<Integer, ArrayList<Double>> confidenceIntervalData = statistics(multiMap);
Map<Integer, ArrayList<Double>> confidenceIntervalData = statistics(multiMap,false);
//getNonLinearRegression(confidenceIntervalData);
......@@ -266,6 +275,13 @@ public class LineChartFunctionality {
}
}
Map<Integer, ArrayList<Double>> confidenceIntervalShadow = statistics(multiMap,true);
for ( Map.Entry<Integer, ArrayList<Double>> entry : confidenceIntervalShadow.entrySet()) {
for (int i = 0; i < entry.getValue().size(); i++) {
Double doubleData = entry.getValue().get(i);
getRegressionSeriesConfidenceInterval().getData().add(new XYChart.Data<String, Number>(String.valueOf(entry.getKey()), doubleData.intValue()));
}
}
System.out.println(data.length);
//System.out.println(data[12][1]);
......@@ -624,13 +640,13 @@ public class LineChartFunctionality {
}
public static void updateLineChart(XYChart.Series<String, Number> series) {
lineChart.getData().add(series);
getLineChart().getData().add(series);
series.getNode().setId("dataGraphs");
lineChart.getStylesheets().add(LineChartFunctionality.class.getResource("/com.application/GUI/graphStyles.css").toExternalForm());
getLineChart().getStylesheets().add(LineChartFunctionality.class.getResource("/com.application/GUI/graphStyles.css").toExternalForm());
}
public static void clearLineChart() {
lineChart.getData().clear();
getLineChart().getData().clear();
//lineChart.getData().
}
}
......@@ -322,16 +322,13 @@ public class Main extends Application {
liveDataBox.setSelected(true);
liveDataBox.setOnAction(event -> {
if(liveDataBox.isSelected()){
System.out.println("Pressed");
LineChartFunctionality.setPrintLiveData(true);
LineChartFunctionality.printGraphs();
} else {
System.out.println("not pressed");
LineChartFunctionality.setPrintLiveData(false);
LineChartFunctionality.printGraphs();
}
});
Label regressionText = new Label("View Regression");
......@@ -339,16 +336,13 @@ public class Main extends Application {
regressionBox.setSelected(true);
regressionBox.setOnAction(event -> {
if(regressionBox.isSelected()){
System.out.println("Pressed");
LineChartFunctionality.setPrintRegression(true);
LineChartFunctionality.printGraphs();
} else {
System.out.println("not pressed");
LineChartFunctionality.setPrintRegression(false);
LineChartFunctionality.printGraphs();
}
});
Label regressionConfidenceIntervalText = new Label("View Regression Shadow");
......@@ -356,12 +350,9 @@ public class Main extends Application {
regressionConfidenceIntervalBox.setSelected(true);
regressionConfidenceIntervalBox.setOnAction(event -> {
if(regressionConfidenceIntervalBox.isSelected()){
System.out.println("Pressed");
LineChartFunctionality.setPrintRegressionConfidenceInterval(true);
LineChartFunctionality.printGraphs();
} else {
System.out.println("not pressed");
LineChartFunctionality.setPrintRegressionConfidenceInterval(false);
LineChartFunctionality.printGraphs();
}
......@@ -372,12 +363,9 @@ public class Main extends Application {
previousBox.setSelected(true);
previousBox.setOnAction(event -> {
if(previousBox.isSelected()){
System.out.println("Pressed");
LineChartFunctionality.setPrintPreviousData(true);
LineChartFunctionality.printGraphs();
} else {
System.out.println("not pressed");
LineChartFunctionality.setPrintPreviousData(false);
LineChartFunctionality.printGraphs();
}
......
......@@ -20,7 +20,7 @@
.default-color0.chart-line-symbol{-fx-background-color: red,red;}
.default-color1.chart-line-symbol{-fx-background-color: green,green;}
.default-color2.chart-line-symbol{-fx-background-color: black,black;}
.default-color2.chart-line-symbol{-fx-background-color: black,white;}
.default-color3.chart-line-symbol{-fx-background-color: rgba(0,168,355,0.3),white;}
.default-color4.chart-line-symbol{-fx-background-color: rgba(0,168,355,0.3),white;}
.default-color5.chart-line-symbol{-fx-background-color: rgba(0,168,355,0.3),white;}
......
......@@ -20,7 +20,7 @@
.default-color0.chart-line-symbol{-fx-background-color: red,red;}
.default-color1.chart-line-symbol{-fx-background-color: green,green;}
.default-color2.chart-line-symbol{-fx-background-color: black,black;}
.default-color2.chart-line-symbol{-fx-background-color: black,white;}
.default-color3.chart-line-symbol{-fx-background-color: rgba(0,168,355,0.3),white;}
.default-color4.chart-line-symbol{-fx-background-color: rgba(0,168,355,0.3),white;}
.default-color5.chart-line-symbol{-fx-background-color: rgba(0,168,355,0.3),white;}
......
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment