Está en la página 1de 5

Cdigo para el Diseo y Registro

de Software con la Tcnica de


prediccin de Series de Tiempo
basado en mtodos no lineales.
Definicin de las Funciones
alfa@x_, y_D := If@x y, x, 1D
arroba@x_, y_D := Table@alfa@x@@iDD, y@@jDDD, 8i, 1, Length@xD<, 8j, 1, Length@yD<D
maxmin@x_, y_D :=
Table@Max@Table@Min@x@@i, kDD, y@@k, jDDD, 8k, 1, Length@x@@1, AllDDD<DD,
8i, 1, Length@x@@All, 1DDD<, 8j, 1, Length@y@@1, AllDDD<D
maxmin1245@x_, y_D := Table@Max@Table@Min@x@@i, kDD, y@@kDDD, 8k, 1, Length@yD<DD,
8i, 1, Length@x@@All, 1DDD<D

Definicin del Universo de


Discurso (Intervalo amplio de
estudio). Valores de Entrada.
low = 130;
up = 400;

Longitud del soporte de los conjuntos difusos


l = 30;

Nmero de conjuntos difusos. !El nmero de intervalos debe ser un nmero entero!
n = 2 Abs@up - lowD l;

Extremos de los intervalos (soporte de los conjuntos difusos)


a = Table@low + Hk - 1L l 2, 8k, 1, n + 1, 1<D;

Generacin de los Conjuntos

CodigoSoftware.nb

Generacin de los Conjuntos


Difusos
h@ak_, ak1_D := Piecewise@882 Hak1 - akL H1 - akL, ak 1 Hak + ak1L 2<,
8- 2 Hak1 - akL H1 - ak1L, Hak + ak1L 2 1 ak1<<D &;
u = Table@h@a@@kDD, a@@k + 2DDD, 8k, 1, n - 1, 1<D;

Grfica de los Conjuntos Difusos

U = Table@Plot@u@@kDD@xD, 8x, low, up<, PlotRange AllD, 8k, 1, n - 1, 1<D;


Show@UD
1.0

0.8

0.6

0.4

0.2

200

250

300

350

400

Lectura de los Datos


datos =
ReadList@"C:\\Users\\William\\Documents\\Articulo Forecasting\\data2.txt"D;
prediction = datos;

Obtencion de las series de tiempo


difusa (F) y las Relaciones difusas
ptimas. Evaluacin de los datos
en los conjuntos difusos arriba
definidos

difusa (F) y las Relaciones difusas


ptimas. Evaluacin de los datos
en los conjuntos difusos arriba
definidos
CodigoSoftware.nb

F = Table@u@@jDD@datos@@iDDD, 8i, 1, Length@datosD<, 8j, 1, n - 1, 1<D;

For@k = Length@datosD, k 2, k --,


R = Table@arroba@F@@Length@datosD + 1 - i, AllDD, F@@Length@datosD - i, AllDDD,
8i, k, Length@datosD - 1<D;
matriz = Fold@maxmin, IdentityMatrix@n - 1D, RD;
temp1 = maxmin1245@ matriz, Transpose@8F@@Length@datosD + 1 - kDD<DD;
temp2 = Table@temp1@@iDD == F@@Length@datosD + 1 - kDD@@iDD, 8i, 1, n - 1, 1<D;
temp3 = Position@temp2, FalseD; If@Length@temp3D == 1, 8temp4 = temp3@@1DD,
temp5 = temp4@@1DD, alpha = Part@temp1, temp5D, o = Solve@u@@temp5DD@xD alpha, xD,
p = 8x . o@@1DD, x . o@@2DD<, y = 8Abs@datos@@Length@datosD + 1 - kDD - p@@1DDD,
Abs@datos@@Length@datosD + 1 - kDD - p@@2DDD<,
temp6 = Position@y, Min@yDD, temp7 = temp6@@1DD, temp8 = temp7@@1DD,
prediction@@Length@datosD + 2 - kDD = p@@temp8DD<,
prediction@@Length@datosD + 2 - kDD = prediction@@Length@datosD + 1 - kDDD
D

Salidas
datos

8158, 222, 248, 216, 226, 239, 206, 178, 169, 177, 290, 245, 318, 158, 274, 255, 191,
244, 149, 195, 247, 233, 156, 203, 182, 272, 256, 184, 299, 246, 184, 224, 316,
285, 251, 248, 222, 135, 337, 235, 225, 282, 302, 391, 261, 315, 231, 231, 263,
177, 270, 169, 172, 243, 278, 283, 200, 324, 266, 214, 240, 239, 224, 262, 200<
grafica1 = ListPlot@datos, Joined TrueD

350

300

250

200

150
10

20

30

40

50

60

CodigoSoftware.nb

prediction
8158, 158, 233, 233, 233, 233, 241, 211, 181, 181, 181, 289, 244, 244, 153, 273, 257,
197, 243, 152, 197, 243, 228, 153, 198, 198, 198, 257, 183, 302, 243, 183, 227,
317, 287, 257, 243, 227, 227, 330, 225, 230, 290, 290, 395, 255, 320, 225, 225,
255, 185, 275, 275, 165, 165, 270, 290, 195, 315, 275, 275, 245, 245, 230, 255<
grafica2 = ListPlot@prediction, Joined True, PlotStyle 8Red, Dashed<D
400

350

300

250

200

10

20

30

40

50

60

40

50

60

Show@grafica1, grafica2D

350

300

250

200

150
10

20

30

e = 1;
errores = Table@Abs@datos@@iDD - prediction@@iDDD, 8i, 1, Length@datosD<D

80, 64, 15, 17, 7, 6, 35, 33, 12, 4, 109, 44, 74, 86, 121, 18, 66, 47, 94, 43, 50, 10, 72,
50, 16, 74, 58, 73, 116, 56, 59, 41, 89, 32, 36, 9, 21, 92, 110, 95, 0, 52, 12, 101,
134, 60, 89, 6, 38, 78, 85, 106, 103, 78, 113, 13, 90, 129, 49, 61, 35, 6, 21, 32, 55<

CodigoSoftware.nb

Histogram@8errores<D

15

10

20

40

60

80

100

120

140

error = N@Sum@HAbs@datos@@iDD - prediction@@iDDDL ^ 2, 8i, e, Length@datosD<D


HLength@datosD - eLD
4495.06

Sqrt@N@errorDD
67.0452

Evaluacin Estadstica
PearsonCorrelationTest@datos, prediction, "TestDataTable"D
Statistic P-Value
Pearson Correlation 0.1085

0.389608

KolmogorovSmirnovTest@datos, predictionD
0.926647
Needs@"TimeSeries`TimeSeries`"D
StationaryQ@datosD
False
InvertibleQ@datosD
False

También podría gustarte