由买买提看人间百态

topics

全部话题 - 话题: pinv
(共0页)
c******g
发帖数: 63
1
来自主题: Computation版 - 请教Matlab中pinv出现NaN的问题
用了一个x = pinv(A) * b 解线性方程组,之前从来没出过错,今天run一个case时发
现错误,其中A是满秩的,inv(A)是存在的,但pinv(A)所有值均为NaN,非常诡异(居
然尼玛还有inv存在,pinv不存在的时刻,逆天啊。。。)。Google了一下,没找到合
适的解答,有人居然说用x = A \ b,我试了没用,A \ b中照理讲对A只是做了inv,而
不是pinv。
请高手指教!谢谢!
j********3
发帖数: 560
2
我原来用sparse来生成大矩阵,做奇异值分解的时候要用svds命令,但是svds本身调用
了zeros函数,这时程序提示
"Product of dimensions is greater than maximum integer."
或者有时候就是"out of memory"。请问碰到这种情况应该怎么办呢?
我最初的目的是要求解线性方程组,但是所要求解的线性方程组的系数矩阵接近奇异,
在版上求教之后得各位大虾指点,使用pinv函数得到了较好的结果。但是之后当所要处
理的系数矩阵增大(至大约2000×2000)时,程序提示"out of memory"。后使用
sparse命令代替zeros命令生成矩阵,但是却无法使用pinv,因为pinv本身调用的是svd
函数做奇异值分解,而对于sparse方式存储的矩阵,要使用svds命令。于是我就自己写
code用svds命令做奇异值分解,但是发现svds本身也用到了zeros来生成零矩阵,这样
,我就没有办法再进行下去了,因为我总不能将我要用的matlab自带函数都重新写一遍
。再次来版上求助,多谢各位大虾了。
j********3
发帖数: 560
3
来自主题: Computation版 - 请教一个matlab问题
请问对于一个用sparse方式存储的接近奇异的矩阵,该如何求它的逆矩阵呢?如果不是
用sparse方式存储,可以用pinv命令来求,但是pinv命令对sparse方式存储的矩阵是无
效的。多谢了!
s***t
发帖数: 195
4
it's kind of strange to me that with 1GB ram, you can't handle
pinv of a 2000x2000. i just tried my laptop. 0.98G ram, no problem
pinv a 2000x2000.
x*x
发帖数: 46
5

basically ppl use SVD to do pseudoinverse.
1. Let B = pinv(A), where pinv(A) is the pseudoinverse of A, m x n matrix.
i.e., ABA = A
2. SVD (Singual Value Decomposition)
Let A = USV', where U & V are orthogonal matrices (U'U=I) and S is
a diagonal matrix.
3. -1
B = V S U'
so what u need is a SVD algorithm. U can get it from
" target="_blank" class="a2">http://www.geocities.com/xiaomaoxiong2000/lin-alg-cpp.hqx
it's been packed in HQX format. use some tools to unpack it first.
q******o
发帖数: 2503
6
来自主题: Statistics版 - 贡献一个电面经验
物理背景,野路子几年编程经验,少许统计知识,面一个DS职位
问time series里面stationary vs no-stationary,讲到moving average的时候问的
问三个output,几百个input parameter,什么方法priotize三个output,这个完全不
懂,据说用的optimization????
问了pinv()和regular inv, 因为提到我在matlab里用过pinv,纯基本线代
s*c
发帖数: 897
7
来自主题: PhotoGear版 - 问个matlab问题
如果X,Y列矢量,但元素个数不一样,A是变换矩阵。X=AY
如果已知X,要求Y,应该怎么算?
1. Y=(A'*A)\A'*X
2. Y=pinv(A')*X
两种结果似乎不同
T******r
发帖数: 2937
8
pinv?
j********3
发帖数: 560
9
谢谢!试了pinv,它能给出更好的结果,但是还是不够精确。应该怎么办呢?
b**a
发帖数: 1375
10
来自主题: Programming版 - 急问:VS2008里如何调用DLL
要使用GSL的计算库
把libgsl.dll放在了对应的目录下.
如下程序
typedef double (*pgsl_cdf_gamma_Pinv)(const double P, const double a
, const double b);
HINSTANCE hDLL;
hDLL=LoadLibraryW((LPCWSTR)"libgsl.dll");
if(hDLL==NULL){
cout<<"dll not found";
return 0;
}
pgsl_cdf_gamma_Pinv GammaInv;
GammaInv=(pgsl_cdf_gamma_Pinv)GetProcAddress(hDLL,"gsl_cdf_gamma_
Pinv");
cout< 总是提示找不到dll,
请大牛指教, 拜谢了.
G*****7
发帖数: 1759
11
来自主题: Programming版 - C++ 做线性代数,方便使用的库?
this is called least square problem
AX=Y -> A'AX=A'Y -> X= inverse(A'A)A'Y -> in matlab X = pinv(A)*Y.

子。
c*******e
发帖数: 8624
12
来自主题: Computation版 - 怎么解这个方程组阿
do an svd decomposition
in matlab, let x = pinv(A)*b
c*******e
发帖数: 8624
13
来自主题: Computation版 - 怎么解这个方程组阿
not sure about the 0 to 1 thing, hehe

do an svd decomposition
in matlab, let x = pinv(A)*b
h****d
发帖数: 1305
14
来自主题: Computation版 - 请教Matlab中矩阵求逆问题
try pinv()
s*******g
发帖数: 483
15
pinv() in matlab will solve the problem
it adds a diagonal identity matrix multiplied with a very small factor to
improve numerical stability
if you want to solve linear system, you can transfer it trivially to an
optimization problem and use conjugate gradient which is supposed to be
robust
k*****c
发帖数: 1670
16
来自主题: Computation版 - 请教Matlab中pinv出现NaN的问题
贴你的code 看看。
k**********g
发帖数: 989
17
来自主题: Computation版 - 请教Matlab中pinv出现NaN的问题
Please try to print the following values:
[u, s, v] = svd(A)
any(isnan(A))
any(~isfinite(A))
norm(A, Inf)
and see if there's any unusual result
l*****k
发帖数: 1059
18
我想你要的是"Moore-Penrose pseudoinverse of a matrix"
matlab里叫 pinv.
The Moore-Penrose pseudoinverse is a matrix B of the same dimensions as A'
satisfying four conditions: A*B*A = A
B*A*B = B
A*B is Hermitian
B*A is Hermitian
B********e
发帖数: 10014
19
来自主题: Mathematics版 - 用matlab如何避免出现奇异矩阵啊?
是矩阵近奇异inv才有问题,不是因为人家inv把你的矩阵搞奇异了
因果关系要搞清楚,呵呵,这个连我这个民科都知道
应用里既然矩阵是奇异的,根据情况可以取伪逆(当然你自己得知道影响不影响应用)。
取伪逆在matlab里可以用pinv,或者左右除 \,/
(共0页)