广播的lstsq(最小二乘)

时间:2017-03-01 14:24:21

标签: python numpy

我有一堆3x2矩阵,让我们说777个矩阵,以及大小为3的右侧。对于每个矩阵,我想知道最小平方的解决方案,所以我和#39;正在做

numpy.linalg.lstsq(A, b)

这有效,但速度很慢。我更愿意一次性计算所有解决方案,但是

numpy.linalg.linalg.LinAlgError: 3-dimensional array given. Array must be two-dimensional

我正在

numpy.linalg.lstsq

有关如何广播RewriteEngine On # If not www RewriteCond %{HTTP_HOST} !^www\. [NC] # rewrite to https and www RewriteRule ^ https://www.example.com%{REQUEST_URI} [R=301,L,NE] # If not HTTPS RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteCond %{HTTPS} off RewriteRule ^ https://www.example.com%{REQUEST_URI} [R=301,L,NE] 的任何提示?

1 个答案:

答案 0 :(得分:2)

可以利用//Create javascript arrays with the values and labels, replace this with code to read from the database/API/etc. var array_1_values = [100, 120, 180, 200, 90]; //these are the values of the first line var array_2_values = [20, 35, 65, 125, 245]; //these are the values of the second line var array_labels = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri']; //these are the labels that will appear at the bottom of the chart //create a prototype multi-dimensional array var data_chart1 = { labels: [], series: [ [], [] ] }; //populate the multi-dimensional array for (var i = 0; i < array_1_values.length; i += 1) { data_chart1.series[0].push(array_1_values[i]) data_chart1.series[1].push(array_2_values[i]) data_chart1.labels.push(array_labels[i]) } //set the size of chart 1 var options_chart1 = { width: '300px', height: '200px' }; //create chart 1 new Chartist.Line('#chart1', data_chart1, options_chart1); A = U \Sigma V^T的奇异值分解,

这一事实
A

x = V \Sigma^+ U^T b 的最小二乘解。 SVD is broadcasted in numpy。现在只需要稍微摆弄一下Ax = b即可完成任务:

einsum