apache的math库中的回归——regression（翻译）

Count string frequencies计算字符串的频率Using case-sensitive comparison, alpha sort order (natural comparator):大小写敏感，而且以字母顺序排序（默认比较器）

```Frequency f =newFrequency();
f.addValue("Z");System.out.println(f.getCount("one"));// displays 1System.out.println(f.getCumPct("Z"));  // displays 0.5System.out.println(f.getCumPct("Ot"));// displays 0.25
```

Using case-insensitive comparator:大小写不敏感

```Frequency f = new Frequency(String.CASE_INSENSITIVE_ORDER);
System.out.println(f.getCount("one"));  // displays 3
System.out.println(f.getCumPct("z"));  // displays 1```

1.5 Multiple linear regression 多元线性回归

OLSMultipleLinearRegression and GLSMultipleLinearRegression provide least squares regression to fit the linear model:

Y=X*b+u

where Y is an n-vector regressand, X is a [n,k] matrix whose k columns are called regressors, b is k-vector of regression parameters and u is an n-vector of error terms or residuals.

OLSMultipleLinearRegression provides Ordinary Least Squares Regression, and  implements Generalized Least Squares. See the javadoc for these classes for details on the algorithms and forumlas used.

OLSMultipleLinearRegression 和 GLSMultipleLinearRegression 提供最小方差线性回归模型：

Y=X*b+u

OLSMultipleLinearRegression 提供一个常见的最小方差回归，GLSMultipleLinearRegression

Data for OLS models can be loaded in a single double[] array, consisting of concatenated rows of data, each containing the regressand (Y) value, followed by regressor values; or using a double[][] array with rows corresponding to observations. GLS models also require a double[][] array representing the covariance matrix of the error terms.

OLS模型数据可以以一维double数组加载，数组以行数据串联，每行数据包含回归方程的独立自变量和 回归方程的因变量（Y)，或者二维double数组，相应的每行一组观察值。GLS模型也需要一个误差的协方差矩阵的二维的double[][]数组

Usage Notes:

• Data are validated when invoking any of the newSample, newX, newY or newCovariance methods and IllegalArgumentException is thrown when input data arrays do not have matching dimensions or do not contain sufficient data to estimate the model.
• By default, regression models are estimated with intercept terms. In the notation above, this implies that the X matrix contains an initial row identically equal to 1. X data supplied to the newX or newSample methods should not include this column - the data loading methods will create it automatically. To estimate a model without an intercept term, set the noIntercept property to true.

Here are some examples.

OLS regression

Instantiate an OLS regression object and load a dataset:
```OLSMultipleLinearRegression regression =newOLSMultipleLinearRegression();double[] y =newdouble[]{11.0,12.0,13.0,14.0,15.0,16.0};double[] x =newdouble[6][];
x[0]=newdouble[]{0,0,0,0,0};
x[1]=newdouble[]{2.0,0,0,0,0};
x[2]=newdouble[]{0,3.0,0,0,0};
x[3]=newdouble[]{0,0,4.0,0,0};
x[4]=newdouble[]{0,0,0,5.0,0};
x[5]=newdouble[]{0,0,0,0,6.0};
regression.newSample(y, x);
```
Get regression parameters and diagnostics:
```double[] beta = regression.estimateRegressionParameters();     //beta值

double[] residuals = regression.estimateResiduals();残余方差double[][] parametersVariance = regression.estimateRegressionParametersVariance();double regressandVariance = regression.estimateRegressandVariance();double rSquared = regression.calculateRSquared();//R回归方差double sigma = regression.estimateRegressionStandardError();//标准差
```
GLS regression

Instantiate a GLS regression object and load a dataset:
```GLSMultipleLinearRegression regression =newGLSMultipleLinearRegression();double[] y =newdouble[]{11.0,12.0,13.0,14.0,15.0,16.0};double[] x =newdouble[6][];
x[0]=newdouble[]{0,0,0,0,0};
x[1]=newdouble[]{2.0,0,0,0,0};
x[2]=newdouble[]{0,3.0,0,0,0};
x[3]=newdouble[]{0,0,4.0,0,0};
x[4]=newdouble[]{0,0,0,5.0,0};
x[5]=newdouble[]{0,0,0,0,6.0};
double[][] omega =newdouble[6][];
omega[0]=newdouble[]{1.1,0,0,0,0,0};
omega[1]=newdouble[]{0,2.2,0,0,0,0};
omega[2]=newdouble[]{0,0,3.3,0,0,0};
omega[3]=newdouble[]{0,0,0,4.4,0,0};
omega[4]=newdouble[]{0,0,0,0,5.5,0};
omega[5]=newdouble[]{0,0,0,0,0,6.6};
regression.newSampleData(y, x, omega); //GLS模型需要提供OMEGA```

1.7 Covariance and correlation协方差和相关性

The org.apache.commons.math3.stat.correlation package computes covariances and correlations for pairs of arrays or columns of a matrix. Covariance computes covariances, PearsonsCorrelation provides Pearson's Product-Moment correlation coefficients and SpearmansCorrelation computes Spearman's rank correlation.

apache的math库中的回归——regression（翻译）

• 0

开心

• 0

板砖

• 0

感动

• 0

有用

• 0

疑问

• 0

难过

• 0

无聊

• 0

震惊