I am quite a newbie in using the apache library for a simple linear regress. Task: I want to calculate the slope.
I have two linear lists, i.e., x-list and y-list. Y list values are the series of number. I am populating x-list by fetching value from a hashmap.
However, when I am trying to apply simpleRegression utility of apache library I am facing below difficulty:
Here is my code:
while(i< segmentI)
{
xList.add(Double.parseDouble(timeStamp.get(i)));
yList.add(Double.parseDouble("1"));
i++;
}
for(int m=0; i< segmentI; i++)
{
simpleRegression.addData(new double[][]{
{xList.get(m),yList.get(m)}
});
}
Doubt: Is there any way can I create new double[][] before passing it to simpleRegression. Also, new double[][]-it is a matrix then what would be the value of [0,1], [0,2]... so on because we don't have anything like that in single ArrayList.
Anything in this regard will be helpful.