Changeset 43cd166 in tol for tol/btol/bmodel/estim.cpp
- Timestamp:
- Sep 19, 2012, 8:49:43 AM (14 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 8973d5c
- Parents:
- 04e6eaf
- File:
-
- 1 edited
-
tol/btol/bmodel/estim.cpp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol/btol/bmodel/estim.cpp
r04e6eaf r43cd166 1442 1442 const BMat& acf, 1443 1443 int T, 1444 int n,1445 1444 int s) 1446 1445 //-------------------------------------------------------------------- 1447 1446 { 1448 1447 static double _05log2pi = 0.5*log(2*3.14159265358979323846); 1448 int n = acf.Rows(); 1449 1449 int res; 1450 1450 BMat rho, rho_, dif, cov, L, eps; … … 1460 1460 1461 1461 res = TolLapack::dpotrf(CblasLower,cov,L); 1462 if( !res) { return(BDat::NegInf()); }1462 if(res) { return(BDat::NegInf()); } 1463 1463 res = TolBlas::dtrsm(CblasLeft,CblasLower,CblasNoTrans,CblasNonUnit,alpha, 1464 1464 L,dif,eps); 1465 if( !res) { return(BDat::NegInf()); }1465 if(res) { return(BDat::NegInf()); } 1466 1466 const BDat* eps_i = eps.Data().Buffer(); 1467 1467 BDat eps_sumSqr = 0; … … 1476 1476 1477 1477 //-------------------------------------------------------------------- 1478 static BDat ARMAACFBartlettLLH_ Sampling(1478 static BDat ARMAACFBartlettLLH_Commuted( 1479 1479 const BPol& ar, 1480 1480 const BPol& ma, 1481 1481 const BMat& acf, 1482 1482 int T, 1483 int n,1484 int s,1485 1483 const BMat& L) 1486 1484 //-------------------------------------------------------------------- 1487 1485 { 1488 1486 static double _05log2pi = 0.5*log(2*3.14159265358979323846); 1487 int n = acf.Rows(); 1489 1488 int res; 1490 1489 BMat rho, dif, eps; … … 1513 1512 //-------------------------------------------------------------------- 1514 1513 DeclareContensClass(BDat, BDatTemporary, BDatARMAACFBartlettLLH); 1515 DefExtOpr(1, BDatARMAACFBartlettLLH, "ARMA.ACF.Bartlett.LLH", 4, 4,1516 "Polyn Polyn Matrix Real ",1517 "(Polyn ar, Polyn ma, Matrix acf, Real T )",1514 DefExtOpr(1, BDatARMAACFBartlettLLH, "ARMA.ACF.Bartlett.LLH", 4, 5, 1515 "Polyn Polyn Matrix Real Real", 1516 "(Polyn ar, Polyn ma, Matrix acf, Real T [, Real truncating])", 1518 1517 I2("Calculates the log-likelihood of asymptotic distribution of sample " 1519 1518 "autocorrelation acf of an ARMA noise z of size T and equations " … … 1532 1531 BMat& acf = Mat(Arg(3)); 1533 1532 int T = (int)Real(Arg(4)); 1533 int s = T*4; 1534 if(Arg(5)) { s = (int)Real(Arg(5)); } 1534 1535 int n = acf.Data().Size(); 1535 int s = T*2; 1536 contens_ = ARMAACFBartlettLLH_Theorical(ar,ma,acf,T,n,s); 1536 contens_ = ARMAACFBartlettLLH_Theorical(ar,ma,acf,T,s); 1537 1537 } 1538 1538 … … 1541 1541 DeclareContensClass(BMat, BMatTemporary, BMatARMAACFBartlettLLHRandStationary); 1542 1542 DefExtOpr(1, BMatARMAACFBartlettLLHRandStationary, 1543 "ARMA.ACF.Bartlett.LLH.RandStationary", 6, 6,1544 "Real Real Matrix Real Real Real ",1545 "(Real p, Real q, Matrix acf, Real T, Real sampleSize, Real exact)",1546 I2("Draws the log-likelihood of asymptotic distribution of sample "1543 "ARMA.ACF.Bartlett.LLH.RandStationary", 6, 7, 1544 "Real Real Matrix Real Real Real Real", 1545 "(Real p, Real q, Matrix acf, Real T, Real N, Real exact [, Real truncating=N*4])", 1546 I2("Draws N times the log-likelihood of asymptotic distribution of sample " 1547 1547 "autocorrelation of orders from 1 to n of an ARMA noise of size T." 1548 1548 "Generates stationary polynomials AR and MA of degrees p and q " 1549 1549 "with uniform distributed modules of roots.", 1550 "Simula la log-verosimilitud de la distribución aintótica "1550 "Simula N veces la log-verosimilitud de la distribución aintótica " 1551 1551 "de las autocorrelaciones muestrales de órdenes 1 a n de un ruido " 1552 1552 "ARMA de tamaño T.\n" … … 1562 1562 BMat& acf = Mat(Arg(3)); 1563 1563 int T = (int)Real(Arg(4)); 1564 int sampleSize= (int)Real(Arg(5));1564 int N = (int)Real(Arg(5)); 1565 1565 bool exact = (int)Real(Arg(6)); 1566 1566 int n = acf.Data().Size(); 1567 int s = T*2; 1568 contens_.Alloc(sampleSize,1); 1569 contens_.GetData().Replicate(BDat::NegInf(),sampleSize); 1567 int s = T*4; 1568 if(Arg(7)) { s = (int)Real(Arg(7)); } 1569 contens_.Alloc(N,1); 1570 contens_.GetData().Replicate(BDat::NegInf(),N); 1570 1571 int k; 1571 1572 int res; 1572 1573 BPol ar, ma; 1573 1574 BMat cov, L; 1574 if(!exact) 1575 if(exact) 1576 { 1577 for(k=0; k<N; k++) 1578 { 1579 ar = RandStationary(p,1); 1580 ma = RandStationary(q,1); 1581 contens_(k,0) = ARMAACFBartlettLLH_Theorical(ar,ma,acf,T,s); 1582 } 1583 } 1584 else 1575 1585 { 1576 1586 _covACF_Bartlett(cov,acf,n,T,s); 1577 1587 res = TolLapack::dpotrf(CblasLower,cov,L); 1578 1588 if(res) { return; } 1589 for(k=0; k<N; k++) 1590 { 1591 ar = RandStationary(p,1); 1592 ma = RandStationary(q,1); 1593 contens_(k,0) = ARMAACFBartlettLLH_Commuted (ar,ma,acf,T,L); 1594 } 1579 1595 }; 1580 for(k=0; k<sampleSize; k++)1581 {1582 ar = RandStationary(p,1);1583 ma = RandStationary(q,1);1584 if(exact)1585 {1586 contens_(k,0) = ARMAACFBartlettLLH_Theorical(ar,ma,acf,T,n,s);1587 }1588 else1589 {1590 contens_(k,0) = ARMAACFBartlettLLH_Sampling(ar,ma,acf,T,n,s,L);1591 }1592 }1593 1596 } 1594 1597
Note: See TracChangeset
for help on using the changeset viewer.
