Class Regression

java.lang.Object
cloud.opencode.base.math.stats.Regression

public final class Regression extends Object
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:
  • Method Details

    • linear

      public static Regression.LinearModel linear(double[] x, double[] y)
      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.LinearModel containing slope, intercept, and R-squared / 包含斜率、截距和 R 平方的线性模型
      Throws:
      IllegalArgumentException - if arrays are null, empty, different lengths, or have fewer than 2 elements