我参与了 Ax = b 类型系统的解析,其中 A 是稀疏方阵,x 是未知向量(我必须计算它),b 是除最后一个元素为 1 之外的全零向量。
矩阵A的最后一行用于归一化,因此用1来满足。
该系统的解是概率,因此必须遵守条件0。
为了求解该系统,使用Matlab命令x = A \ b;
。
该方法似乎运行良好,但有一种特殊情况,其中向量 x 也包含负值。向矩阵A的任意元素添加一个很小的值(10^-6),分辨率又满足条件。
我不是数学家,所以我不知道这是否是代码问题,或者矩阵 A 是否必须遵守某些属性以保证解都在 0 和 1 之间。
I'm involved in the resolution of a system of the type Ax = b
, where A is a square sparse matrix, x is the vector of the unknows (I have to compute it) and b is a vector of all zeros excpet for the last element which is a 1.
The last row of the matrix A is used for normalization, and so is fulfilled with ones.
The solutions of this system are probabilities and for this reason the condition 0<x(i)<1
must be respected.
In order to solve the system the Matlab command x = A \ b;
is used.
The method seems to work well, but there is a special case in wich the vector x also contains negative values. Adding a very small value (10^-6) to any element of the Matrix A, the resolution back to meet the conditions.
I'm not a mathematician, so I don't know if it's a code problem, or if the matrix A must respect some properties to guarantee that the solutions are all between 0 and 1.
发布评论
评论(1)
听起来你真正想要的是:最小化 ||Ax-b||受x>所有 x 均为 0。您可以使用函数 lsqlin 来做到这一点: http://www.mathworks.com /help/toolbox/optim/ug/lsqlin.html
其中“必须加到1”是线性等式约束,正性是线性不等式约束。
矩阵(非方形)中概率的相关问题是: http:// ieeexplore.ieee.org/xpl/freeabs_all.jsp?arnumber=5717139
Sounds like what you really want is: minimize ||Ax-b|| subject to x > 0 for all x. You can do that with function lsqlin : http://www.mathworks.com/help/toolbox/optim/ug/lsqlin.html
The 'must add to 1' is a linear equality constraint, positivity is a linear inequality constraint.
A related problem with probabilities in a matrix (not square) is this: http://ieeexplore.ieee.org/xpl/freeabs_all.jsp?arnumber=5717139