Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Bacheloroppgave_2022
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eilert Tunheim
Bacheloroppgave_2022
Commits
02b0aba6
Commit
02b0aba6
authored
3 years ago
by
Eilert Tunheim
Browse files
Options
Downloads
Patches
Plain Diff
Working linear regression
parent
7fd96b46
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/com/application/GUI/LineChartFunctionality.java
+35
-1
35 additions, 1 deletion
...main/java/com/application/GUI/LineChartFunctionality.java
target/classes/com/application/GUI/LineChartFunctionality.class
+0
-0
0 additions, 0 deletions
.../classes/com/application/GUI/LineChartFunctionality.class
with
35 additions
and
1 deletion
src/main/java/com/application/GUI/LineChartFunctionality.java
+
35
−
1
View file @
02b0aba6
...
...
@@ -8,6 +8,7 @@ import javafx.scene.chart.XYChart;
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
java.util.*
;
...
...
@@ -110,7 +111,6 @@ public class LineChartFunctionality {
multiMap
.
computeIfAbsent
(
index
,
k
->
new
ArrayList
<
Double
>());
multiMap
.
get
(
index
).
add
(
kwhValue
);
// Connect the data to a series
newSeries
.
getData
().
add
(
new
XYChart
.
Data
<
String
,
Number
>(
String
.
valueOf
(
index
),
kwhValue
));
index
+=
1
;
...
...
@@ -118,9 +118,43 @@ public class LineChartFunctionality {
updateLineChart
(
newSeries
);
}
// Stores the data from the confidence interval in a new map
Map
<
Integer
,
ArrayList
<
Double
>>
confidenceIntervalData
=
statistics
(
multiMap
);
// Checks the max size for the arraylists needed for the data array later
int
jMaxSize
=
0
;
for
(
int
i
=
0
;
i
<
confidenceIntervalData
.
size
();
i
++)
{
if
(
confidenceIntervalData
.
get
(
i
).
size
()
>
jMaxSize
){
jMaxSize
=
confidenceIntervalData
.
get
(
i
).
size
();
}
}
// Defines an array to be used for the regression
double
[][]
data
=
new
double
[
confidenceIntervalData
.
size
()][
jMaxSize
];
System
.
out
.
println
(
confidenceIntervalData
);
for
(
int
i
=
0
;
i
<
confidenceIntervalData
.
size
();
i
++)
{
ArrayList
<
Double
>
list
=
confidenceIntervalData
.
get
(
i
);
for
(
int
j
=
0
;
j
<
list
.
size
();
j
++)
{
data
[
i
][
j
]
+=
list
.
get
(
j
);
}
}
System
.
out
.
println
(
data
.
length
);
System
.
out
.
println
(
data
[
12
][
1
]);
SimpleRegression
simpleRegression
=
new
SimpleRegression
();
simpleRegression
.
addData
(
data
);
// and then you can predict the time at a given temperature value
System
.
out
.
println
(
"Predicted Time: "
+
simpleRegression
.
predict
(
35
));
// You can also get the slope and intercept from your data
System
.
out
.
println
(
"slope = "
+
simpleRegression
.
getSlope
());
System
.
out
.
println
(
"intercept = "
+
simpleRegression
.
getIntercept
());
//simpleRegression.add
return
getLineChart
();
}
...
...
This diff is collapsed.
Click to expand it.
target/classes/com/application/GUI/LineChartFunctionality.class
+
0
−
0
View file @
02b0aba6
No preview for this file type
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment