Changeset 4efc00a in tol
- Timestamp:
- May 11, 2010, 2:58:02 PM (16 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- a868db9
- Parents:
- 5633d43
- Location:
- tol_pkg/BysVecLinReg
- Files:
-
- 1 added
- 3 edited
-
Multivariate.tol (modified) (3 diffs)
-
test/gen_multivariant_linear_regression.tol (modified) (2 diffs)
-
test/test_0003/test.tol (added)
-
tools.tol (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
tol_pkg/BysVecLinReg/Multivariate.tol
r5633d43 r4efc00a 73 73 //Choleski decomposition of VxIm as sparse explicit((d*m)x(d*m)) 74 74 VMatrix _.VxIm.Le = Rand(0,0,0,0); 75 75 76 //////////////////////////////////////////////////////////////////////////// 77 // Optional linear constraining equalities 78 // 79 // C * vec(A) = c 80 // 81 //Number of linear constraining equalities 82 Real _.r.C = 0; 83 //Coefficient matrix of linear constraining equalities 84 VMatrix _.C = Rand(0,0,0,0); 85 //Right vector of linear constraining equalities 86 VMatrix _.c = Rand(0,0,0,0); 87 //////////////////////////////////////////////////////////////////////////// 88 76 89 //////////////////////////////////////////////////////////////////////////// 77 90 Real check.dim(Text method, VMatrix M, Real nRow, Real nCol) … … 155 168 156 169 //////////////////////////////////////////////////////////////////////////// 170 Real set.linearConstrainingEquations(VMatrix C, VMatrix c) 171 //////////////////////////////////////////////////////////////////////////// 172 { 173 Real r = VRows(c); 174 If(Or(!check.dim("set.linearConstrainingEquations",C,r,_.m*_.d), 175 !check.dim("set.linearConstrainingEquations",c,r,1 )),False, 176 { 177 Real _.r.C := r; 178 VMatrix _.C := C; 179 VMatrix _.c := c; 180 True 181 }) 182 }; 183 184 //////////////////////////////////////////////////////////////////////////// 157 185 Real change.X(VMatrix X) 158 186 //////////////////////////////////////////////////////////////////////////// … … 251 279 252 280 //////////////////////////////////////////////////////////////////////////// 281 VMatrix gibbs.draw.vec.A.std(Real numSim) 282 //////////////////////////////////////////////////////////////////////////// 283 { 284 If(!_.r.C, Gaussian(_.d*_.m,1,0,1), 285 { 286 VMatrix C = Tra(_.IdxXLi*Tra(_.C))*_.VxIm.Le; 287 VMatrix c = _.c - _.C * _.vec.nu; 288 eqConstrainedStdGaussian(C,c) 289 }) 290 }; 291 292 //////////////////////////////////////////////////////////////////////////// 253 293 VMatrix gibbs.draw.vec.A(Real numSim) 254 294 //////////////////////////////////////////////////////////////////////////// 255 295 { 256 VMatrix e = Gaussian(_.d*_.m,1,0,1);296 VMatrix e = gibbs.draw.vec.A.std(numSim); 257 297 VMatrix e.1 = _.VxIm.Le*e; 258 298 VMatrix e.2 = Tra(Tra(e.1)*_.IdxXLi); -
tol_pkg/BysVecLinReg/test/gen_multivariant_linear_regression.tol
r5633d43 r4efc00a 10 10 WriteLn("Current Random Seed = "<<rndSeed); 11 11 12 Real d = IntRand(2,10); 13 Real m = IntRand(2,10); 14 Real N = IntRand(m*10,m*100); 12 Real If(!ObjectExist("Real","r.eq"), r.eq = 0, r.eq); 13 14 Real d = IntRand(r.eq+2,r.eq+10); 15 Real m = IntRand(r.eq+2,r.eq+10); 16 Real N = IntRand(m*5,m*30); 15 17 Real sampleLength = 5000; 16 18 … … 23 25 VMatrix Y = A*X+E; 24 26 27 VMatrix C = If(!r.eq,Rand(0,d*m,0,0), 28 Round(Rand(r.eq,d*m,-2.5,2.5,"Cholmod.R.Sparse",r.eq*2))); 29 VMatrix c = If(!r.eq,Rand(0,1,0,0), 30 C*BysVecLinReg::vmatrix2vec(A)); -
tol_pkg/BysVecLinReg/tools.tol
r5633d43 r4efc00a 43 43 VMatrix c.2 = c-c.1; 44 44 VMatrix e.2 = MinimumResidualsSolve(C.2,c.2); 45 //VMatrix C.2*e.2-c.2 46 e.2 45 VMatrix err = C.2*e.2-c.2; 46 Real errMax = VMatMax(Abs(err)); 47 If((n^3)+errMax^2 != n^3, 48 WriteLn("[BysVecLinReg::eqConstrainedStdGaussian] errMax="<<errMax,"W")); 49 Triplet(SetCol(p.1<<p.2) | Constant(n,1,1) | VMat2Mat(e.1 << e.2), n, 1) 50 //SetOfMatrix(Tra(p), Constant(n,1,1),VMat2Mat(e.1 << e.2)) 47 51 };
Note: See TracChangeset
for help on using the changeset viewer.
