Class Regression
java.lang.Object
cloud.opencode.base.math.stats.Regression
Regression analysis utilities.
回归分析工具类
Provides least-squares linear regression with R-squared goodness-of-fit.
提供最小二乘线性回归及 R 平方拟合优度。
- Since:
- JDK 25, opencode-base-math V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordResult of a linear regression: y = slope * x + intercept. -
Method Summary
Modifier and TypeMethodDescriptionstatic Regression.LinearModellinear(double[] x, double[] y) Performs ordinary least-squares linear regression.
-
Method Details
-
linear
Performs ordinary least-squares linear regression. 执行普通最小二乘线性回归Fits the model y = slope * x + intercept that minimizes the sum of squared residuals.
拟合最小化残差平方和的模型 y = slope * x + intercept。
- Parameters:
x- the independent variable values / 自变量值y- the dependent variable values / 因变量值- Returns:
- a
Regression.LinearModelcontaining slope, intercept, and R-squared / 包含斜率、截距和 R 平方的线性模型 - Throws:
IllegalArgumentException- if arrays are null, empty, different lengths, or have fewer than 2 elements
-