iPhone的Accelerate Framework中是否有用于计算点阵列的线性回归的函数?

|                                                                                                                   关闭。这个问题需要更加集中。它当前不接受答案。                                                      
已邀请:
        假设您已经知道模型的参数,则可以使用矩阵向量乘法来实现。线性回归是样本矩阵X与模型参数的向量Theta的内积。
// Simple scenario for linear regression: Y = theta0 + theta1*X
int rows = 4;
int cols = 2;
double theta[] = {5.0, 2.0};
double x[] = {1.0, 10.0, 
              1.0, 20.0, 
              1.0, 30.0, 
              1.0, 40.0};
double y[rows];

// This is matrix-matrix multiplication function, 
// but vector is just a matrix with one row/column. 
vDSP_mmulD(x, 1, theta, 1, y, 1, rows, 1, cols);

NSLog(@\"[%f, %f, %f, %f]\", y[0], y[1], y[2], y[3]);

[25.000000, 45.000000, 65.000000, 85.000000]
有关更多详细信息,请阅读Wikipedia上的线性回归简介。     

要回复问题请先登录注册