Changeset 77c938e in tol
- Timestamp:
- Mar 1, 2010, 4:34:48 PM (17 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 13f9a4e
- Parents:
- f77a89a
- Location:
- tol_pkg
- Files:
-
- 6 edited
-
MhCnstrLinRegArima/test/test_0001/test.tol (modified) (7 diffs)
-
MhCnstrLinRegArima/test/test_0001/test_bsr.tol (modified) (1 diff)
-
MhCnstrLinRegArima/test/test_0001/test_circle.tol (modified) (1 diff)
-
MulVarFunAprox/DesignC2.Monomial.Spheric.MeshFree.tol (modified) (3 diffs)
-
MulVarFunAprox/DesignC2.Spheric.tol (modified) (1 diff)
-
MulVarFunAprox/MulVarFunAprox.tol (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
tol_pkg/MhCnstrLinRegArima/test/test_0001/test.tol
rf77a89a r77c938e 32 32 Real MLHSteps = 0; 33 33 //Length of MCMC 34 Real SampleLength = 500; 34 Real Burnin = 500; 35 Real SampleLength = 2000; 35 36 36 37 ///////////////////////////////////////////////////////////////////////////// … … 38 39 ///////////////////////////////////////////////////////////////////////////// 39 40 //Number of variables of each observational node 40 Real n = 2 ;41 Real n = 200; 41 42 //Data length of each observational node 42 Real m = IntRand(100, 400);43 Real m = n*IntRand(2, 10)+IntRand(100,1000); 43 44 //Number of inequations 44 Real r = IntRand(0, 2*n);45 Real r = IntRand(0,4*n); 45 46 //Enables/disables full ARIMA components 46 Real enableARMA = IntRand( 0,1);47 Real enableARMA = IntRand(1,1); 47 48 //Seasonal periodicity 48 49 Real S = 7; … … 73 74 { 74 75 Real avr = Rand(-10, 10); 75 Real sig = Rand( 2, 4);76 Real sig = Rand(1, 2); 76 77 Gaussian(m,1,avr,sig) 77 78 })); … … 87 88 88 89 //Standard deviation 89 Real s = Rand(0.1,0. 4);90 Real s = Rand(0.1,0.2); 90 91 //Variance 91 92 Real s2 = s^2; … … 159 160 { 160 161 WriteLn("Initializing Markov Chain ..."); 162 Real t0 = Copy(Time); 161 163 Real mclra::_.gInitial := s/2; 162 164 Real mclra::initialize(b0_); 163 165 Matrix mcmc = Rand(0,mclra::_.n,0,0); 164 166 Matrix cache = Rand(0,mclra::_.n,0,0); 165 While(Rows(mcmc)< SampleLength,167 While(Rows(mcmc)<Burnin+SampleLength, 166 168 { 167 169 Real If(Rows(mcmc) < MLHSteps, … … 177 179 True 178 180 }); 181 Real t1 = Copy(Time); 182 Real ts = (t1-t0)/(Burnin+SampleLength); 183 WriteLn(" Time by simulation:"<<ts+" seconds"); 179 184 mcmc 180 185 }); 181 182 Set Include("test_circle.tol");183 Set Include("test_bsr.tol");184 185 //Chart circle on real target beta and MCMCŽs all together odd pairs against186 Matrix mcmc = circle | bsr.mcmc | Group("ConcatColumns",MCMC);187 186 188 187 Set gelman.diag = RCODA::gelman.diag(MCMC,{[[ … … 192 191 Real transform=FALSE, 193 192 Real autoburnin=TRUE]]}); 193 194 Set MCMC.b = EvalSet(MCMC,Matrix(Matrix mcmc) 195 { 196 SubRow(mcmc,Range(Burnin+1,Burnin+SampleLength,1)) 197 }); 198 Set gelman.diag.b = RCODA::gelman.diag(MCMC.b,{[[ 199 Real verbose=TRUE, 200 Real varByCol=TRUE, 201 Real confidence=0.95, 202 Real transform=FALSE, 203 Real autoburnin=TRUE]]}); 204 205 Set Include("test_bsr.tol"); 206 207 //Chart circle on real target beta and MCMCŽs all together odd pairs against 208 Matrix mcmc = Group("ConcatColumns",MCMC); 209 Matrix mcmc.b = Matrix If(n==2, 210 { 211 Set Include("test_circle.tol"); 212 circle | bsr.mcmc | Group("ConcatColumns",MCMC.b) 213 }, 214 { 215 Set Include("test_circle.tol"); 216 circle | bsr.mcmc | Group("ConcatColumns",MCMC.b) 217 }); 194 218 195 219 -
tol_pkg/MhCnstrLinRegArima/test/test_0001/test_bsr.tol
rf77a89a r77c938e 55 55 BysMcmc::@Config bsr.config = [[ 56 56 //MCMC dimensions 57 Real mcmc.burnin = 100;57 Real mcmc.burnin = Burnin; 58 58 Real mcmc.sampleLength = SampleLength; 59 59 Real mcmc.cacheLength = 100; 60 Real bsr.linBlk.MH.useAfterIter = 1 060 Real bsr.linBlk.MH.useAfterIter = 1/0 61 61 ]]; 62 62 -
tol_pkg/MhCnstrLinRegArima/test/test_0001/test_circle.tol
rf77a89a r77c938e 8 8 Real mclra::initialize(b); 9 9 Real realMaxLikelihood = mclra::_.log.P; 10 Real mclra::_.ratio := s/ 100;10 Real mclra::_.ratio := s/500; 11 11 Matrix circle = Group("ConcatRows", For(1,SampleLength, Matrix(Real numSim) 12 12 { -
tol_pkg/MulVarFunAprox/DesignC2.Monomial.Spheric.MeshFree.tol
rf77a89a r77c938e 52 52 ////////////////////////////////////////////////////////////////////////////// 53 53 { 54 Text _MID = "[@DesignC2.Monomial.Spheric. MeshFree::build.stress.points] ";54 Text _MID = "[@DesignC2.Monomial.Spheric.Delaunay2D::build.stress.points] "; 55 55 Real _.Z.maxNeighbour := If(prior.Z.order>=0,2,0); 56 56 If(!_.Z.maxNeighbour, … … 74 74 { 75 75 And( 76 LE(distance_[k], Constant(_. J,1,stress.maxDistance)),76 LE(distance_[k], Constant(_.H,1,stress.maxDistance)), 77 77 LT(Y1_[k],Y2_[k])) 78 78 }); … … 115 115 })}; 116 116 117 117 118 ////////////////////////////////////////////////////////////////////////////// 118 119 Real build.border.points(Real void) -
tol_pkg/MulVarFunAprox/DesignC2.Spheric.tol
rf77a89a r77c938e 72 72 SubRow(_.R,VCol2Set(Y.idx)) 73 73 }; 74 75 ////////////////////////////////////////////////////////////////////////////// 76 VMatrix build.obs(VMatrix X) 77 ////////////////////////////////////////////////////////////////////////////// 78 { 79 FunRn2R::@BaseC2.Eval.Function eval = 80 FunRn2R::@BaseC2.Eval.Function::New(get.base(0)); 81 MatQuery::@KNN.Neighbourhood ngbh = 82 _.ann::search(VMat2Mat(X),_.X.maxNeighbour); 83 Real m = VRows(X); 84 VMatrix dist = Mat2VMat(Sqrt(ngbh::_.distance2)); 85 VMatrix X.h = Mat2VMat(ngbh::_.neighbour); 86 VMatrix X.idx = DifEq(1/(1-B),Constant(m,1,1)); 87 VMatrix triplet.all = Group("ConcatRows", For(1,_.X.maxNeighbour,VMatrix(Real k) 88 { 89 VMatrix X.h.k = SubCol(X.h,[[k]]); 90 VMatrix dist.k = SubCol(dist,[[k]]); 91 VMatrix R = get.radius(X.h.k); 92 VMatrix tao = dist.k $/ R; 93 VMatrix lambda = (-tao^2+1)^4; 94 VMatrix match = LT(dist.k,R); 95 SubRow(X.idx | X.h.k | dist.k | tao| lambda, MatQuery::SelectMatch(match)) 96 })); 97 VMatrix x.idx = SubCol(triplet.all,[[1]]); 98 VMatrix y.idx = SubCol(triplet.all,[[2]]); 99 VMatrix xy.idx = x.idx | y.idx; 100 VMatrix lambda.col = SubCol(triplet.all,[[5]]); 101 VMatrix triplet.lambda = xy.idx | lambda.col; 102 VMatrix lambda = Triplet(VMat2Mat(triplet.lambda),m,_.H); 103 VMatrix sum.lambda = lambda*Constant(_.H,1,1); 104 VMatrix sum.lambda.inv = Convert(sum.lambda,"Blas.R.Dense")^-1; 105 VMatrix weight = Eye(m,m,0,sum.lambda.inv)*lambda; 106 VMatrix dif = 107 SubRow( X,VCol2Set(SubCol(triplet.all,[[1]]))) - 108 SubRow(_.Y,VCol2Set(SubCol(triplet.all,[[2]]))) ; 109 VMatrix P.row = Group("ConcatRows", For(1,_.K,VMatrix(Real k) 110 { 111 x.idx 112 })); 113 VMatrix P.y = Group("ConcatRows", For(1,_.K,VMatrix(Real k) 114 { 115 y.idx 116 })); 117 VMatrix YnCum = DifEq(1/(1-B),_.Yn); 118 VMatrix YnCumB = Sub(SetCol([[0]])<<YnCum,1,1,_.H,1); 119 VMatrix P.YnCum = SubRow(YnCum, VCol2Set(P.y)); 120 VMatrix P.YnCumB = SubRow(YnCumB,VCol2Set(P.y)); 121 VMatrix P.k = Group("ConcatRows", For(1,_.K,VMatrix(Real k) 122 { 123 y.idx*0+k 124 })); 125 VMatrix P.col = P.YnCumB + P.k; 126 VMatrix P.match = LE(P.col,P.YnCum); 127 Real eval::upgrade.cache(dif); 128 VMatrix P.ev = Group("ConcatRows", For(1,_.K,VMatrix(Real k) 129 { 130 lambda.col $* eval::evaluate.v(k,dif) 131 })); 132 Matrix P.triplet = VMat2Mat( 133 SubRow(P.row | P.col | P.ev, MatQuery::SelectMatch(P.match))); 134 VMatrix Px = Pack(Convert(Triplet(P.triplet, m, _.N),"Cholmod.R.Sparse")); 135 VMatrix Qx = Eye(m,m,0,sum.lambda.inv)*Px 136 }; 137 74 138 75 139 /////////////////////////////////////////////////////////////////////////// -
tol_pkg/MulVarFunAprox/MulVarFunAprox.tol
rf77a89a r77c938e 22 22 #Embed "DesignC2.Monomial.Spheric.Grid.tol"; 23 23 #Embed "DesignC2.Monomial.Spheric.MeshFree.tol"; 24 #Embed "DesignC2.Monomial.Spheric.Delaunay2D.tol"; 24 25 #Embed "ModelC2.tol" 25 26
Note: See TracChangeset
for help on using the changeset viewer.
