|
|
@@ -86,22 +86,22 @@ public class PolynomialRegression extends Regression {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public String getFunction() {
|
|
|
+ public String getFunction(int scale) {
|
|
|
if (!this.isHasData()) {
|
|
|
return "未构造数据";
|
|
|
}
|
|
|
final double[] parameters = this.getParameters();
|
|
|
StringBuilder function = new StringBuilder("y = ");
|
|
|
for (int i = 0; i < parameters.length; i++) {
|
|
|
- function.append(parameters[i]);
|
|
|
- for (int j = 0; j < i; j++) {
|
|
|
- function.append(" x ");
|
|
|
- if (j != (i - 1)) {
|
|
|
- function.append("*");
|
|
|
+ function.append(Double.parseDouble(String.format("%." + scale + "f", parameters[i])));
|
|
|
+// for (int j = 0; j < i; j++) {
|
|
|
+ function.append("x");
|
|
|
+ if (i - 1 > 0) {
|
|
|
+ function.append(String.format("<sup>%d</sup>",i));
|
|
|
}
|
|
|
- }
|
|
|
+// }
|
|
|
if (i != (parameters.length - 1)) {
|
|
|
- function.append(" + ");
|
|
|
+ function.append(parameters[i+1]>0?"+":"");
|
|
|
}
|
|
|
|
|
|
}
|