您可以使用calculateBeta()
(不幸的是,这是受保护的)
class Test {
public static void main(String[] args) {
System.out.println(new TestData());
}
}
所以你必须使用一个技巧......
import org.apache.commons.math3.stat.regression.OLSMultipleLinearRegression;
public class TestData extends OLSMultipleLinearRegression {
public TestData() {
double[] y = {5.6, 5.44, 4.57, 4.78, 4.25, 5.31, 5.24, 5.12, 4.58, 5.18};
double[][] x = {{3.17, 26.348}, {3.65, 24.198}, {3.28, 25.085}, {3.37, 22.461},
{2.57, 23.740}, {3.60, 24.786}, {3.50, 23.374}, {2.98, 23.725},
{2.54, 23.227}, {3.41, 26.920}};
this.newSampleData(y,x);
}
@Override
public String toString() {
return this.calculateBeta().toString();
}
}