Changeset e9e4854 in tol
- Timestamp:
- Apr 15, 2011, 10:02:11 AM (16 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- fcb7cd1
- Parents:
- 84be16b
- Location:
- tol
- Files:
-
- 3 edited
-
btol/bmodel/estim.cpp (modified) (3 diffs)
-
stdlib/gui/html/_htmlmethods.tol (modified) (2 diffs)
-
stdlib/gui/html/_htmlutil.tol (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
tol/btol/bmodel/estim.cpp
r84be16b re9e4854 900 900 } 901 901 902 902 /* 903 903 //-------------------------------------------------------------------- 904 904 DeclareContensClass(BPol, BPolTemporary, BPolAutoReg); … … 926 926 } 927 927 928 928 /* 929 929 //-------------------------------------------------------------------- 930 930 DeclareContensClass(BSet, BSetTemporary, BSetAutoRegInt); … … 952 952 ); 953 953 } 954 954 */ 955 955 956 956 -
tol/stdlib/gui/html/_htmlmethods.tol
r84be16b re9e4854 376 376 377 377 ////////////////////////////////////////////////////////////////////////////// 378 Text HtmlLinReg(Set series)379 380 // PURPOSE: Creates an HTML text width a linear regression report of series381 //382 //////////////////////////////////////////////////////////////////////////////383 {384 Real n = Card(series);385 If386 (387 n<2,388 {389 WriteLn("Error: Son necesarias al menos dos series para calcular "+390 "la regresión lineal.");391 "Número de series = " + IntText(n)392 },393 {394 HtmlLinearRegression(series, Periodicity(series[1]))395 }396 )397 };398 399 400 //////////////////////////////////////////////////////////////////////////////401 378 Text HtmlAutoReg(Set series, 402 379 Real periodicidad, … … 592 569 @SeriesMethodStruct("Componentes" , Copy(HtmlSeriesComponents), Empty); 593 570 594 Set LinRegMet =595 @SeriesMethodStruct("Regresión lineal" , Copy(HtmlLinReg), Empty);596 597 571 598 572 ////////////////////////////////////////////////////////////////////////////// -
tol/stdlib/gui/html/_htmlutil.tol
r84be16b re9e4854 235 235 236 236 237 238 //////////////////////////////////////////////////////////////////////////////239 Text HtmlLinearRegression(Set ser, Real period)240 241 // PURPOSE: Creates an HTML text width a linear regression report of series242 //243 //////////////////////////////////////////////////////////////////////////////244 {245 Text old = PutEditor("");246 247 Text tmpDir = Replace(TmpDir,"\\","/");248 249 Text rand = FormatReal(Rand(0,99999999),"%0.lf");250 251 Text outputName = Identify(ser[1]);252 253 Serie output = ser[1];254 255 Text CreaInputExpresion(Real n, Real k)256 {257 Text name = Identify(ser[n]);258 Text expr = "(B^"+k+"):("+name+");";259 expr260 };261 Set ARIEst = AutoRegInt(output, period);262 Polyn DIF = ARIEst[1];263 Polyn AR = ARIEst[2];264 Polyn ARI = DIF*AR;265 Real degree = Degree(ARI)-1;266 267 Set inputBackNames = For268 (269 1,270 Card(ser),271 Set s(Real n)272 {273 If274 (275 n==1,276 For(1, degree, Text(Real k) { CreaInputExpresion(n,k) } ),277 For(0, 2, Text(Real k) { CreaInputExpresion(n,k) } )278 )279 }280 );281 Set idSet = SetConcat(inputBackNames);282 Set input = EvalSet(idSet, Serie (Text expr) { Eval(expr) } );283 284 Real n = Card(input);285 286 Set lr = LinearRegression287 (288 output,289 input290 );291 292 293 Set param = lr[2];294 Set ParInf =295 {296 Set For297 (298 1,n,299 Set linePar(Real i)300 {301 Text id = idSet[i];302 Set p1 = param[i];303 Set p2 = SetOfReal(p1[2],p1[3],p1[4],p1[5]);304 [[id]] + p2305 }306 )307 };308 309 Set ExprInf =310 {311 Set For312 (313 1,n,314 Text lineExpr(Real i)315 {316 Real j = n-i+1;317 Text id = idSet[j];318 Set p1 = param[j];319 Real coef = p1[2];320 Real aCoef = Abs(coef);321 Text sig = If(coef>0, "+", "-");322 NL + " " + sig + aCoef + "*" + id323 }324 )325 };326 327 Real outStd = StDsS(output);328 Set info = lr[3];329 Real err = info[5];330 Real sw = info[6]*2;331 Text expression = "Est" + outputName + " = " +332 Text (SetSum( ExprInf)) +333 NL + " + Gaussian(0," + err +")";334 335 Text InfoFile =336 {337 Text txt =338 "Concepto;" + "Valor" + ";" + NL +339 "Fecha inicial;" + info[ 1] + ";" + NL +340 "Fecha final;" + info[ 2] + ";" + NL +341 "Número de datos;" + info[ 3] + ";" + NL +342 "Número de variables;" + info[ 4] + ";" + NL +343 "Error estandar de "+outputName+";" + outStd + ";" + NL +344 "Error estandar de los residuos;" + err + ";" + NL +345 "Inform. Swartz;" + sw + ";" + NL +346 "F de Snedecor;" + info[10] + ";" + NL +347 "Alfa;" + info[11] + ";" + NL;348 WriteFile(tmpDir + "/Info"+rand+".txt", txt)349 };350 351 Text ParFile =352 {353 Text pFile = tmpDir + "/Par" + rand + ".txt";354 Set Table(SetOfSet(ParInf),pFile);355 Text t1 = ReadFile(pFile);356 Text t2 = Replace(t1, Quotes, "");357 Text head = "Nombre; Valor; Desv. Típ.; t de Student; 1-Alfa;"+NL;358 WriteFile(pFile,head+t2)359 };360 361 Serie residuals = lr[1];362 Serie prevHist = output - residuals;363 364 Set seriesReport = [[output,prevHist]];365 366 Text aiaHtml = "";367 Set aia = AIA(residuals+0, 1/ARI);368 Real If(Card(aia),369 {370 Text AIAFile = tmpDir + "/AIA" + rand + ".txt";371 Set Table([[aia]],AIAFile);372 Text373 (374 aiaHtml :=375 " <LI>" + HtmlTitle("Análisis de Intervención Automático",3,TitCol)+376 HtmlTable(AIAFile)+ BR377 );378 Real SystemDelete(AIAFile)379 });380 381 Text report =382 "<OL>" +383 " <LI>" + HtmlTitle("Gráfico de previsión",3,TitCol)+384 HtmlBdtChart(seriesReport) + BR +385 " <LI>" + HtmlTitle("Información",3,TitCol)+386 HtmlTable(InfoFile)+ BR +387 " <LI>" + HtmlTitle("Parámetros",3,TitCol)+388 HtmlTable(ParFile)+ BR +389 aiaHtml +390 " <LI>" + HtmlTitle("Correlaciones de los parámetros",3,TitCol)+391 HtmlMatrixTable(lr[5],idSet,idSet,"Correlación") + BR +392 " <LI>" + HtmlTitle("Gráfico de error de la previsión",3,TitCol)+393 HtmlBdtChart([[residuals]]) + BR +394 " <LI>" + HtmlTitle("Autocorrelaciones de los residuos", 3, Blue) +395 HtmlAutoCorReport([[residuals]]) + BR +396 " <LI>" + HtmlTitle("Tabla de previsión histórica",3,TitCol)+397 HtmlBdtTable([[output,prevHist,residuals]]) +398 "</OL>";399 400 401 Real SystemDelete(InfoFile);402 Real SystemDelete(ParFile);403 404 405 Text PutEditor(old);406 report407 };408 409 410 237 ////////////////////////////////////////////////////////////////////////////// 411 238 Text HtmlAutoRegression(Serie z,
Note: See TracChangeset
for help on using the changeset viewer.
