Changeset 43cd166 in tol


Ignore:
Timestamp:
Sep 19, 2012, 8:49:43 AM (14 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
8973d5c
Parents:
04e6eaf
Message:

Reducing arguments and fixing descriptions of Bartlett distribution related functions

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@5084 be4846ae-f051-483a-831f-b64e7d08527f

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol/btol/bmodel/estim.cpp

    r04e6eaf r43cd166  
    14421442  const BMat& acf,
    14431443  int T,
    1444   int n,
    14451444  int s)
    14461445//--------------------------------------------------------------------
    14471446{
    14481447  static double _05log2pi = 0.5*log(2*3.14159265358979323846);
     1448  int n = acf.Rows();
    14491449  int res;
    14501450  BMat rho, rho_, dif, cov, L, eps;
    … …  
    14601460
    14611461  res = TolLapack::dpotrf(CblasLower,cov,L);
    1462   if(!res) { return(BDat::NegInf()); }
     1462  if(res) { return(BDat::NegInf()); }
    14631463  res = TolBlas::dtrsm(CblasLeft,CblasLower,CblasNoTrans,CblasNonUnit,alpha,
    14641464                           L,dif,eps);
    1465   if(!res) { return(BDat::NegInf()); }
     1465  if(res) { return(BDat::NegInf()); }
    14661466  const BDat* eps_i = eps.Data().Buffer();
    14671467  BDat eps_sumSqr = 0;
    … …  
    14761476
    14771477//--------------------------------------------------------------------
    1478 static BDat ARMAACFBartlettLLH_Sampling(
     1478static BDat ARMAACFBartlettLLH_Commuted(
    14791479  const BPol& ar,
    14801480  const BPol& ma,
    14811481  const BMat& acf,
    14821482  int T,
    1483   int n,
    1484   int s,
    14851483  const BMat& L)
    14861484//--------------------------------------------------------------------
    14871485{
    14881486  static double _05log2pi = 0.5*log(2*3.14159265358979323846);
     1487  int n = acf.Rows();
    14891488  int res;
    14901489  BMat rho, dif, eps;
    … …  
    15131512//--------------------------------------------------------------------
    15141513DeclareContensClass(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)",
     1514DefExtOpr(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])",
    15181517  I2("Calculates the log-likelihood of asymptotic distribution of sample "
    15191518     "autocorrelation acf of an ARMA noise z of size T and equations "
    … …  
    15321531  BMat& acf = Mat(Arg(3));
    15331532  int T = (int)Real(Arg(4));
     1533  int s = T*4;
     1534  if(Arg(5)) { s = (int)Real(Arg(5)); }
    15341535  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);
    15371537}
    15381538
    … …  
    15411541DeclareContensClass(BMat, BMatTemporary, BMatARMAACFBartlettLLHRandStationary);
    15421542DefExtOpr(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 "
    15471547     "autocorrelation of orders from 1 to n of an ARMA noise of size T."
    15481548     "Generates stationary polynomials AR and MA of degrees p and q "
    15491549     "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 "
    15511551     "de las autocorrelaciones muestrales de órdenes 1 a n de un ruido "
    15521552     "ARMA de tamaño T.\n"
    … …  
    15621562  BMat& acf = Mat(Arg(3));
    15631563  int T = (int)Real(Arg(4));
    1564   int sampleSize = (int)Real(Arg(5));
     1564  int N = (int)Real(Arg(5));
    15651565  bool exact = (int)Real(Arg(6));
    15661566  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);
    15701571  int k;
    15711572  int res;
    15721573  BPol ar, ma;
    15731574  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
    15751585  {
    15761586    _covACF_Bartlett(cov,acf,n,T,s);
    15771587    res = TolLapack::dpotrf(CblasLower,cov,L);
    15781588    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    }
    15791595  };
    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     else
    1589     {
    1590       contens_(k,0) = ARMAACFBartlettLLH_Sampling(ar,ma,acf,T,n,s,L);
    1591     }
    1592   }
    15931596}
    15941597
Note: See TracChangeset for help on using the changeset viewer.