简体   繁体   English

适用于iPhone / iPad的线性回归库或代码段?

[英]Linear regression library or code snippet for iPhone/iPad?

I would like to find the line that best fits n cartesian points. 我想找到最适合n笛卡尔点的线。

Is there a package or library that will help me on iPhone - something in C or objective-C? 是否有可以在iPhone上对我有所帮助的软件包或库-使用C或Objective-C的东西?

You can write a quick code to do that. 您可以编写一个快速的代码来做到这一点。 The least-squares solution to the problem is b = (G^(T)G)^(-1)G^(T)m, where b is the vector of coefficients of the linear fit, m is the vector of all y values and G is the kernel matrix of dimension (length(m),2) and each row of G is (1, x) where x is the x value corresponding to ay value. 该问题的最小二乘解是b =(G ^(T)G)^(-1)G ^(T)m,其中b是线性拟合系数的向量,m是所有y的向量G是维度(length(m),2)的核矩阵,G的每一行是(1,x),其中x是与ay值相对应的x值。 G^T is the transpose of G. G ^ T是G的转置。

The transpose and inversion can be done by using LAPACK library (or any other linear algebra library of your choice) or by taking the appropriate code from a Numerical Recipes book. 可以通过使用LAPACK库(或您选择的任何其他线性代数库)或从“数字食谱”书中获取适当的代码来完成转置和求逆。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM