# Visualización de los datos
# Configuración de la figura para múltiples gráficos
plt.figure(figsize= (14 , 10 ))
# Mapa de calor para la Matriz de Correlaciones
plt.subplot(2 , 2 , 1 )
sns.heatmap(corr_matrix, annot= True , cmap= 'coolwarm' , vmin=- 1 , vmax= 1 )
plt.title("Mapa de Calor de la Matriz de Correlaciones" )
# Diagrama de caja para ver la distribución de las variables
plt.subplot(2 , 2 , 2 )
data.boxplot()
plt.title("Diagrama de Caja de las Variables" )
# Matriz de dispersión para ver relaciones entre variables
plt.subplot(2 , 2 , (3 , 4 ))
sns.pairplot(data, kind= "scatter" , plot_kws= {'alpha' : 0.5 , 's' : 30 , 'edgecolor' : "none" })
plt.suptitle("Matriz de Dispersión" )
plt.tight_layout()
plt.show()
Warning: package 'tidyverse' was built under R version 4.4.2
Warning: package 'readr' was built under R version 4.4.2
Warning: package 'forcats' was built under R version 4.4.2
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.5
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.5.1 ✔ tibble 3.2.1
✔ lubridate 1.9.3 ✔ tidyr 1.3.1
✔ purrr 1.0.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
Warning: package 'MVN' was built under R version 4.4.2
# Leer los datos del archivo 'accion.txt'
data <- read.table ("accion.txt" , sep= " \t " , header= TRUE )
head (data)
V1 V2 V3
1 3.4 89.7 30.2
2 5.1 55.7 9.9
3 4.5 52.3 11.5
4 3.5 47.0 11.2
5 5.9 42.7 7.0
6 5.1 30.6 6.9
# Vector de Medias
means <- colMeans (data)
print ("Vector de Medias:" )
V1 V2 V3
9.420588 69.526471 9.096765
# Vector de Medianas
medians <- apply (data, 2 , median)
print (" \n Vector de Medianas:" )
[1] "\nVector de Medianas:"
# Matriz de Covarianzas
cov_matrix <- cov (data)
# Asimetría y Kurtosis Multivariante usando el paquete MVN
mvn_result <- mvn (data, mvnTest = "mardia" )
print (" \n Asimetría Multivariante:" )
[1] "\nAsimetría Multivariante:"
print (mvn_result$ multivariateNormality)
Test Statistic p value Result
1 Mardia Skewness 103.908270901864 8.97317329453402e-18 NO
2 Mardia Kurtosis 9.67716560797701 0 NO
3 MVN <NA> <NA> NO
# Visualización de los datos
# Mapa de calor para la Matriz de Correlaciones
corrplot:: corrplot (corr_matrix, method= "color" , type= "upper" , order= "hclust" ,
addCoef.col = "black" , tl.col= "black" , tl.srt= 45 )
# Gráficos de densidad para cada variable
ggplot (data, aes (x = V1)) +
geom_density (fill= "lightblue" , alpha= 0.5 ) +
geom_vline (aes (xintercept= mean (V1)), color= "red" , linetype= "dashed" , size= 1 ) +
labs (title= "Gráfico de Densidad de V1" , x= "V1" , y= "Densidad" ) +
theme_minimal ()
Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.
ggplot (data, aes (x = V2)) +
geom_density (fill= "lightgreen" , alpha= 0.5 ) +
geom_vline (aes (xintercept= mean (V2)), color= "red" , linetype= "dashed" , size= 1 ) +
labs (title= "Gráfico de Densidad de V2" , x= "V2" , y= "Densidad" ) +
theme_minimal ()
ggplot (data, aes (x = V3)) +
geom_density (fill= "pink" , alpha= 0.5 ) +
geom_vline (aes (xintercept= mean (V3)), color= "red" , linetype= "dashed" , size= 1 ) +
labs (title= "Gráfico de Densidad de V3" , x= "V3" , y= "Densidad" ) +
theme_minimal ()
Warning: package 'StatMatch' was built under R version 4.4.2
Cargando paquete requerido: proxy
Warning: package 'proxy' was built under R version 4.4.2
Adjuntando el paquete: 'proxy'
The following objects are masked from 'package:stats':
as.dist, dist
The following object is masked from 'package:base':
as.matrix
Cargando paquete requerido: survey
Warning: package 'survey' was built under R version 4.4.2
Cargando paquete requerido: grid
Cargando paquete requerido: Matrix
Adjuntando el paquete: 'Matrix'
The following objects are masked from 'package:tidyr':
expand, pack, unpack
Cargando paquete requerido: survival
Adjuntando el paquete: 'survey'
The following object is masked from 'package:graphics':
dotchart
Cargando paquete requerido: lpSolve
Warning: package 'lpSolve' was built under R version 4.4.2
# Cargar los datos (asumiendo que están en un archivo 'accion.txt')
data <- read.table ("accion.txt" , header = TRUE , sep = " \t " )
# Calcular la matriz de distancias de Mahalanobis
mahalanobis_distances <- mahalanobis.dist (data)
# Ver la matriz de distancias
print (mahalanobis_distances)
1 2 3 4 5 6 7
1 0.000000 5.2312186 4.8436222 5.0642219 5.8394140 6.0124310 4.9128363
2 5.231219 0.0000000 0.5264729 0.4828412 1.0509648 1.6852098 0.6944454
3 4.843622 0.5264729 0.0000000 0.2914764 1.1130146 1.5856376 0.9252238
4 5.064222 0.4828412 0.2914764 0.0000000 0.9967267 1.4772803 0.9730540
5 5.839414 1.0509648 1.1130146 0.9967267 0.0000000 0.7076841 1.7453974
6 6.012431 1.6852098 1.5856376 1.4772803 0.7076841 0.0000000 2.3665641
7 4.912836 0.6944454 0.9252238 0.9730540 1.7453974 2.3665641 0.0000000
8 5.288351 0.3084751 0.4537155 0.3557078 0.7800401 1.3836834 0.9843198
9 4.178634 1.1258501 0.7082068 0.8909876 1.7922352 2.1529142 1.0953049
10 4.529466 1.1151661 0.5948599 0.7192756 1.3739088 1.5946589 1.4267690
11 6.241928 1.4092932 1.5291086 1.4009523 0.4198502 0.6843480 2.0959264
12 4.384826 2.0523697 1.5567863 1.6809049 1.8963508 1.7511991 2.4160427
13 4.887614 0.5930170 0.1768763 0.3775730 1.0050462 1.4595049 1.0629937
14 5.587549 0.9760447 0.9251359 0.8484057 0.2627396 0.7336863 1.6580262
15 4.049084 1.5138999 1.0022369 1.2155269 1.8117293 1.9864164 1.6891484
16 5.602526 0.6475861 1.1423814 1.1265260 1.3392807 2.0444220 0.8474181
17 5.525150 0.5152710 0.8256676 0.8145408 0.7661953 1.4528005 1.1230686
18 4.754559 0.5050829 0.4614731 0.5792802 1.4557346 2.0057530 0.4867818
19 4.922227 1.3757312 1.6298841 1.7469582 2.3441171 3.0069975 0.8467692
20 5.227661 2.0944836 2.1525885 2.3627306 2.3096247 2.7580734 2.2253097
21 4.996723 2.3311354 2.3178216 2.5528793 2.5488313 2.9459716 2.4336316
22 5.477622 1.8831470 2.0231299 2.1985082 2.0822282 2.5814823 2.0535217
23 4.954093 2.5740706 2.5019672 2.7435239 2.6935176 3.0099647 2.7202293
24 5.164867 2.1998000 2.1864152 2.4051162 2.2961293 2.6622275 2.3967897
25 5.279144 1.9268349 2.1128311 2.2975260 2.4130602 2.9937887 1.8736500
26 5.387955 1.9822263 2.1664817 2.3472274 2.3891386 2.9517004 1.9862234
27 5.050717 2.1171147 2.1726365 2.3960712 2.4529349 2.9307347 2.1585580
28 5.189090 2.7737477 2.6787921 2.9046431 2.7214869 2.9442738 3.0120160
29 5.255613 2.0799993 2.1919932 2.3953001 2.4093786 2.9161139 2.1307347
30 5.167088 2.1894378 2.1694821 2.3873797 2.2677080 2.6246304 2.3989711
31 5.617795 1.5540727 1.9577776 2.0193596 2.3361019 3.0371072 1.2669259
32 5.848141 0.7336411 1.0737410 0.9822075 0.6302312 1.3333939 1.3565299
33 5.518315 1.7275933 1.8799809 2.0422620 1.8916949 2.3992057 1.9457944
34 6.798220 5.0206769 4.7178646 4.8080255 4.2722966 3.7673117 5.5682975
8 9 10 11 12 13 14
1 5.2883507 4.1786342 4.5294657 6.2419283 4.3848261 4.8876135 5.5875487
2 0.3084751 1.1258501 1.1151661 1.4092932 2.0523697 0.5930170 0.9760447
3 0.4537155 0.7082068 0.5948599 1.5291086 1.5567863 0.1768763 0.9251359
4 0.3557078 0.8909876 0.7192756 1.4009523 1.6809049 0.3775730 0.8484057
5 0.7800401 1.7922352 1.3739088 0.4198502 1.8963508 1.0050462 0.2627396
6 1.3836834 2.1529142 1.5946589 0.6843480 1.7511991 1.4595049 0.7336863
7 0.9843198 1.0953049 1.4267690 2.0959264 2.4160427 1.0629937 1.6580262
8 0.0000000 1.1515065 0.9705487 1.1677313 1.8436939 0.4470403 0.6791642
9 1.1515065 0.0000000 0.6213925 2.2119841 1.4900442 0.8091584 1.5773432
10 0.9705487 0.6213925 0.0000000 1.7812346 1.0286165 0.5791655 1.1314934
11 1.1677313 2.2119841 1.7812346 0.0000000 2.2069533 1.4223062 0.6586322
12 1.8436939 1.4900442 1.0286165 2.2069533 0.0000000 1.4623035 1.6480452
13 0.4470403 0.8091584 0.5791655 1.4223062 1.4623035 0.0000000 0.7977308
14 0.6791642 1.5773432 1.1314934 0.6586322 1.6480452 0.7977308 0.0000000
15 1.4163213 0.7038070 0.5594268 2.2084230 0.8558395 0.9721707 1.5537777
16 0.8622923 1.6750144 1.7344330 1.5724170 2.6170207 1.1767734 1.3603758
17 0.4633530 1.4987202 1.3421692 1.0599451 2.1043981 0.7719040 0.7527490
18 0.6834135 0.7016459 0.9428653 1.8496661 1.9330316 0.6124886 1.3134654
19 1.6646679 1.7124956 2.1109638 2.6475931 2.9957037 1.7216868 2.2747284
20 2.1365562 2.4294003 2.4422142 2.4802639 2.7544212 2.0658483 2.2290594
21 2.3626122 2.5085395 2.5334562 2.7387667 2.7397104 2.2283193 2.4401673
22 1.9339805 2.3917170 2.3857601 2.2260540 2.7978455 1.9406500 2.0372474
23 2.5698876 2.6671608 2.6420527 2.8726851 2.7013260 2.3966889 2.5714244
24 2.1953287 2.4513143 2.3988231 2.4609159 2.5762166 2.0782381 2.1974053
25 2.0703306 2.3708419 2.5250597 2.6090200 3.0761229 2.0808303 2.3584818
26 2.1041506 2.4580745 2.5713504 2.5629403 3.0840928 2.1209852 2.3425048
27 2.1925329 2.3836194 2.4672904 2.6540685 2.8226475 2.1048483 2.3601178
28 2.7225087 2.8906842 2.7723864 2.8556268 2.6974348 2.5511127 2.6080557
29 2.1659355 2.4563664 2.5339411 2.5878608 2.9425063 2.1274144 2.3405217
30 2.1782659 2.4387202 2.3748280 2.4312061 2.5400231 2.0583334 2.1677455
31 1.8211209 2.2529680 2.5168085 2.5412667 3.3866413 2.0149566 2.3421784
32 0.6391455 1.7717374 1.5576539 0.8229120 2.2837535 1.0207415 0.7354197
33 1.7661679 2.2903394 2.2557651 2.0322786 2.6901261 1.7931672 1.8541341
34 4.7570820 4.9301607 4.4169017 4.2244277 3.5613442 4.5519794 4.1813847
15 16 17 18 19 20 21
1 4.0490839 5.6025255 5.5251504 4.7545594 4.9222273 5.2276606 4.9967228
2 1.5138999 0.6475861 0.5152710 0.5050829 1.3757312 2.0944836 2.3311354
3 1.0022369 1.1423814 0.8256676 0.4614731 1.6298841 2.1525885 2.3178216
4 1.2155269 1.1265260 0.8145408 0.5792802 1.7469582 2.3627306 2.5528793
5 1.8117293 1.3392807 0.7661953 1.4557346 2.3441171 2.3096247 2.5488313
6 1.9864164 2.0444220 1.4528005 2.0057530 3.0069975 2.7580734 2.9459716
7 1.6891484 0.8474181 1.1230686 0.4867818 0.8467692 2.2253097 2.4336316
8 1.4163213 0.8622923 0.4633530 0.6834135 1.6646679 2.1365562 2.3626122
9 0.7038070 1.6750144 1.4987202 0.7016459 1.7124956 2.4294003 2.5085395
10 0.5594268 1.7344330 1.3421692 0.9428653 2.1109638 2.4422142 2.5334562
11 2.2084230 1.5724170 1.0599451 1.8496661 2.6475931 2.4802639 2.7387667
12 0.8558395 2.6170207 2.1043981 1.9330316 2.9957037 2.7544212 2.7397104
13 0.9721707 1.1767734 0.7719040 0.6124886 1.7216868 2.0658483 2.2283193
14 1.5537777 1.3603758 0.7527490 1.3134654 2.2747284 2.2290594 2.4401673
15 0.0000000 2.0658059 1.7038616 1.2377835 2.2197439 2.3554443 2.3640396
16 2.0658059 0.0000000 0.6316343 0.9896986 1.1396065 1.9092439 2.2130104
17 1.7038616 0.6316343 0.0000000 0.9571854 1.5971930 1.8226648 2.0947825
18 1.2377835 0.9896986 0.9571854 0.0000000 1.2267920 2.1609480 2.3372163
19 2.2197439 1.1396065 1.5971930 1.2267920 0.0000000 1.9688516 2.1714746
20 2.3554443 1.9092439 1.8226648 2.1609480 1.9688516 0.0000000 0.3756732
21 2.3640396 2.2130104 2.0947825 2.3372163 2.1714746 0.3756732 0.0000000
22 2.3887234 1.6196768 1.5691840 2.0235036 1.8227592 0.3871829 0.7623579
23 2.4236167 2.5166751 2.3254106 2.5720443 2.5157869 0.7120844 0.3840808
24 2.2722156 2.1018855 1.9096507 2.2615116 2.2342149 0.3634948 0.3376098
25 2.5093822 1.5866668 1.7535143 1.9717049 1.4013158 0.7395846 0.9961462
26 2.5596839 1.6396872 1.7635559 2.0593455 1.5587412 0.6224997 0.9130283
27 2.3524386 1.9265940 1.9062270 2.1287422 1.8218740 0.2832141 0.3976430
28 2.5638994 2.7476628 2.4727516 2.8169397 2.8896786 1.0196831 0.7913025
29 2.4683536 1.8225877 1.8434176 2.1354436 1.7697042 0.3167623 0.5832539
30 2.2490067 2.1021168 1.8951374 2.2544624 2.2538207 0.4037619 0.3802488
31 2.7031120 1.0221939 1.5912364 1.6387567 0.7321339 1.9187439 2.2084747
32 1.9690088 0.7499770 0.3415074 1.2260567 1.8404488 2.0414557 2.3348560
33 2.2947553 1.4720921 1.3895516 1.9004432 1.7845841 0.5404033 0.9035433
34 4.2854531 5.3314695 4.7291136 5.1374384 5.9508134 4.5568890 4.4522916
22 23 24 25 26 27 28
1 5.4776224 4.9540926 5.16486700 5.2791438 5.3879553 5.0507166 5.1890900
2 1.8831470 2.5740706 2.19980002 1.9268349 1.9822263 2.1171147 2.7737477
3 2.0231299 2.5019672 2.18641520 2.1128311 2.1664817 2.1726365 2.6787921
4 2.1985082 2.7435239 2.40511621 2.2975260 2.3472274 2.3960712 2.9046431
5 2.0822282 2.6935176 2.29612934 2.4130602 2.3891386 2.4529349 2.7214869
6 2.5814823 3.0099647 2.66222747 2.9937887 2.9517004 2.9307347 2.9442738
7 2.0535217 2.7202293 2.39678969 1.8736500 1.9862234 2.1585580 3.0120160
8 1.9339805 2.5698876 2.19532874 2.0703306 2.1041506 2.1925329 2.7225087
9 2.3917170 2.6671608 2.45131426 2.3708419 2.4580745 2.3836194 2.8906842
10 2.3857601 2.6420527 2.39882311 2.5250597 2.5713504 2.4672904 2.7723864
11 2.2260540 2.8726851 2.46091593 2.6090200 2.5629403 2.6540685 2.8556268
12 2.7978455 2.7013260 2.57621655 3.0761229 3.0840928 2.8226475 2.6974348
13 1.9406500 2.3966889 2.07823808 2.0808303 2.1209852 2.1048483 2.5511127
14 2.0372474 2.5714244 2.19740527 2.3584818 2.3425048 2.3601178 2.6080557
15 2.3887234 2.4236167 2.27221556 2.5093822 2.5596839 2.3524386 2.5638994
16 1.6196768 2.5166751 2.10188552 1.5866668 1.6396872 1.9265940 2.7476628
17 1.5691840 2.3254106 1.90965068 1.7535143 1.7635559 1.9062270 2.4727516
18 2.0235036 2.5720443 2.26151155 1.9717049 2.0593455 2.1287422 2.8169397
19 1.8227592 2.5157869 2.23421486 1.4013158 1.5587412 1.8218740 2.8896786
20 0.3871829 0.7120844 0.36349483 0.7395846 0.6224997 0.2832141 1.0196831
21 0.7623579 0.3840808 0.33760982 0.9961462 0.9130283 0.3976430 0.7913025
22 0.0000000 1.0779390 0.65655916 0.6393982 0.4959627 0.5521636 1.3169785
23 1.0779390 0.0000000 0.46549958 1.3799345 1.2908697 0.7814493 0.4586262
24 0.6565592 0.4654996 0.00000000 1.0951310 0.9842999 0.5692946 0.6893805
25 0.6393982 1.3799345 1.09513101 0.0000000 0.1819090 0.6015763 1.7469498
26 0.4959627 1.2908697 0.98429992 0.1819090 0.0000000 0.5396588 1.6320225
27 0.5521636 0.7814493 0.56929461 0.6015763 0.5396588 0.0000000 1.1730761
28 1.3169785 0.4586262 0.68938047 1.7469498 1.6320225 1.1730761 0.0000000
29 0.4035886 0.9594626 0.67698069 0.4444154 0.3315156 0.2386080 1.3089114
30 0.6778839 0.4761024 0.04978823 1.1321916 1.0215480 0.6131504 0.6714518
31 1.6656107 2.5822440 2.23364595 1.2689112 1.3856584 1.8242383 2.9217040
32 1.7541925 2.5591834 2.12536263 1.9766916 1.9705028 2.1506688 2.6711477
33 0.1954976 1.1962166 0.74688209 0.7414166 0.6208730 0.7105070 1.4011228
34 4.6700279 4.1634118 4.21135985 5.2448269 5.1339661 4.7665907 3.7637084
29 30 31 32 33 34
1 5.2556132 5.16708840 5.6177951 5.8481407 5.5183151 6.798220
2 2.0799993 2.18943775 1.5540727 0.7336411 1.7275933 5.020677
3 2.1919932 2.16948210 1.9577776 1.0737410 1.8799809 4.717865
4 2.3953001 2.38737971 2.0193596 0.9822075 2.0422620 4.808025
5 2.4093786 2.26770803 2.3361019 0.6302312 1.8916949 4.272297
6 2.9161139 2.62463044 3.0371072 1.3333939 2.3992057 3.767312
7 2.1307347 2.39897112 1.2669259 1.3565299 1.9457944 5.568297
8 2.1659355 2.17826590 1.8211209 0.6391455 1.7661679 4.757082
9 2.4563664 2.43872024 2.2529680 1.7717374 2.2903394 4.930161
10 2.5339411 2.37482799 2.5168085 1.5576539 2.2557651 4.416902
11 2.5878608 2.43120606 2.5412667 0.8229120 2.0322786 4.224428
12 2.9425063 2.54002307 3.3866413 2.2837535 2.6901261 3.561344
13 2.1274144 2.05833338 2.0149566 1.0207415 1.7931672 4.551979
14 2.3405217 2.16774546 2.3421784 0.7354197 1.8541341 4.181385
15 2.4683536 2.24900671 2.7031120 1.9690088 2.2947553 4.285453
16 1.8225877 2.10211681 1.0221939 0.7499770 1.4720921 5.331470
17 1.8434176 1.89513741 1.5912364 0.3415074 1.3895516 4.729114
18 2.1354436 2.25446244 1.6387567 1.2260567 1.9004432 5.137438
19 1.7697042 2.25382067 0.7321339 1.8404488 1.7845841 5.950813
20 0.3167623 0.40376187 1.9187439 2.0414557 0.5404033 4.556889
21 0.5832539 0.38024876 2.2084747 2.3348560 0.9035433 4.452292
22 0.4035886 0.67788393 1.6656107 1.7541925 0.1954976 4.670028
23 0.9594626 0.47610242 2.5822440 2.5591834 1.1962166 4.163412
24 0.6769807 0.04978823 2.2336460 2.1253626 0.7468821 4.211360
25 0.4444154 1.13219159 1.2689112 1.9766916 0.7414166 5.244827
26 0.3315156 1.02154804 1.3856584 1.9705028 0.6208730 5.133966
27 0.2386080 0.61315038 1.8242383 2.1506688 0.7105070 4.766591
28 1.3089114 0.67145178 2.9217040 2.6711477 1.4011228 3.763708
29 0.0000000 0.71875966 1.6826257 2.0650201 0.5804383 4.871288
30 0.7187597 0.00000000 2.2564110 2.1090762 0.7567546 4.164969
31 1.6826257 2.25641098 0.0000000 1.7348675 1.6201247 6.054861
32 2.0650201 2.10907618 1.7348675 0.0000000 1.5650456 4.758010
33 0.5804383 0.75675464 1.6201247 1.5650456 0.0000000 4.612925
34 4.8712878 4.16496910 6.0548611 4.7580102 4.6129247 0.000000
# Cargar los datos
data <- read.table ("accion.txt" , header = TRUE , sep = " \t " )
# Calcular las distancias euclidianas
euclidean_distances <- dist (data, method = "euclidean" )
# Mostrar las distancias
print (euclidean_distances)
1 2 3 4 5 6 7
2 39.6355901
3 41.8289374 3.8052595
4 46.7364954 8.9409172 5.4018515
5 52.4737077 13.3435378 10.6943911 6.4722485
6 63.5499017 25.2786471 22.1903132 17.0296800 12.1268298
7 31.3063891 8.9190807 12.1041315 17.4450566 22.2625246 34.1569905
8 43.8703772 4.7106263 2.3558438 4.5617979 8.7441409 20.5781437 13.5852862
9 38.5535991 5.3235327 4.0422766 8.1914590 14.2642911 25.1175238 10.5057127
10 47.1699057 10.6667708 6.9036222 2.3874673 7.3273460 16.4496201 18.7906892
11 55.8090494 16.5435788 14.0516903 9.7678043 3.3823069 9.5571962 25.4444493
12 52.0923219 15.8773423 12.2004098 7.2076348 7.2732386 11.8667603 24.1756075
13 41.9859500 3.4785054 0.7874008 5.6356011 10.5228323 22.1822001 12.0370262
14 50.9533120 11.9724684 9.1923882 5.0139805 1.5652476 13.3637570 20.8837257
15 40.1583117 5.3768020 2.9444864 6.7149088 12.5880896 23.4380033 11.8878089
16 32.9759003 10.5275828 14.2558760 19.4599589 23.1503780 35.2740698 4.9719212
17 38.9775576 3.8742741 7.4411021 12.2126983 15.4706173 27.5916654 7.9536155
18 36.0839299 3.6290495 6.2297673 11.5702204 16.6703329 28.3890824 5.9110067
19 20.4244951 28.7482173 32.1735917 37.5475698 41.8350332 53.9239279 20.1715146
20 28.1183214 42.4106119 46.0015217 51.3180280 54.7489726 66.8014221 34.5544498
21 28.8190909 45.8983660 49.4592762 54.7959853 58.3092617 70.3628453 37.9311218
22 27.7668868 38.2578097 41.8829321 47.1696937 50.4964355 62.5443043 30.5668121
23 29.1617901 46.0109770 49.5666218 54.8978142 58.3647154 70.4007102 38.1006562
24 27.5515880 39.5789085 43.1681596 48.4721570 51.8414892 63.8769129 31.8411683
25 28.1200996 45.4482123 49.0238717 54.3654302 57.9731835 70.0614730 37.3685697
26 28.9160855 45.5376767 49.1300315 54.4586081 57.9776681 70.0537651 37.5439742
27 28.3326667 45.6725300 49.2355563 54.5782008 58.1490327 70.2200114 37.6405367
28 29.4248195 42.8980186 46.4766608 51.7665915 55.0309913 67.0236525 35.2492553
29 29.0370453 45.7555461 49.3397406 54.6696442 58.1730178 70.2398747 37.7828003
30 27.3850324 38.5963729 42.1872019 47.4870509 50.8418135 62.8748757 30.8925557
31 23.4595396 32.3049532 35.8827256 41.2195342 45.0659517 57.1909084 24.1051862
32 43.2714687 4.3058100 5.6089215 8.7338422 10.9530818 23.0722777 12.2053267
33 27.3790066 33.7489259 37.3891696 42.6550114 45.9292935 57.9760295 26.2137369
34 61.8873986 23.9295654 21.7111976 18.1270544 12.3925825 10.7765533 32.4137641
8 9 10 11 12 13 14
2
3
4
5
6
7
8
9 6.3882705
10 6.6037868 8.8306285
11 12.0341182 17.6462461 10.3561576
12 11.4743192 14.1862610 5.5145263 8.7647019
13 1.9824228 4.6151923 7.2539644 13.8509927 12.4173266
14 7.3218850 12.7239931 6.0033324 4.9325450 6.8854920 9.0410176
15 5.1419841 2.1470911 7.3000000 15.9580701 12.5211821 3.4597688 11.0276924
16 15.0705010 13.9129436 21.1567956 26.0395853 26.3229938 13.9359248 21.9456146
17 7.6720271 8.8707384 14.0872283 18.3842324 18.9915771 6.9130312 14.2720006
18 7.9284299 5.0009999 12.8860390 19.9494361 18.2701943 6.2377881 15.2292482
19 33.4468235 30.4772046 38.9122089 44.7960936 44.2136857 32.0140594 40.5605720
20 46.9490149 44.8546542 52.8321872 57.3972996 57.8989637 45.7014223 53.6171614
21 50.4552277 48.2080906 56.2702408 60.9804067 61.3432148 49.1727567 57.1617005
22 42.7678618 40.8737079 48.7319197 53.1173230 53.7855929 41.5651296 49.3838030
23 50.5499753 48.3440793 56.3685196 61.0209800 61.4115624 49.2711883 57.2217616
24 44.0901350 42.0923984 49.9908992 54.4780690 55.0203599 42.8535879 50.7141992
25 50.0408833 47.7202263 55.8546328 60.6729759 60.9966393 48.7573584 56.8188349
26 50.1097795 47.8967640 55.9690986 60.6459397 61.0885423 48.8497697 56.8388951
27 50.2486816 47.9474713 56.0530106 60.8390500 61.1579104 48.9597794 56.9949121
28 47.3728825 45.4380897 53.2787012 57.6233460 58.2512661 46.1469392 53.9193843
29 50.3195787 48.1103939 56.1707219 60.8373241 61.2707108 49.0551730 57.0335866
30 43.1011601 41.1336845 49.0095909 53.4764434 54.0323052 41.8690817 49.7157923
31 36.9494249 34.5469246 42.7264555 47.8725391 47.9727006 35.6523492 43.8747080
32 4.4011362 8.9409172 10.8729021 13.7771550 15.2823428 4.9030603 9.8620485
33 38.2355855 36.4862988 44.2426265 48.5470905 49.2798133 37.0579276 44.8219812
34 19.8587034 25.1614805 18.1689323 9.9990050 15.0023365 21.3603862 13.4954103
15 16 17 18 19 20 21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 14.8094564
17 8.9297256 7.7006493
18 6.1497967 8.9230040 5.2306787
19 31.8441517 18.7843020 26.4138221 26.0463049
20 45.9370221 31.9870286 39.4320935 40.1966417 15.5267511
21 49.3154134 35.5090129 42.9728984 43.6076828 18.5294360 3.6578682
22 41.9195658 27.8030574 35.2120718 36.1481673 12.3450395 4.3497126 8.0062476
23 49.4224645 35.6356563 43.0597260 43.7453998 18.8438319 3.8013156 0.8062258
24 43.1270217 29.1749893 36.5611816 37.4197809 13.3869339 3.0083218 6.5566760
25 48.8946827 35.0332699 42.5801597 43.1113674 17.7048016 3.7815341 2.0099751
26 49.0423287 35.1002849 42.6156075 43.2574849 18.0449439 3.4727511 1.6673332
27 49.0869636 35.2761959 42.7809537 43.3503172 18.0914344 3.6193922 0.9055385
28 46.4287626 32.5249135 39.8302649 40.7800196 16.8029759 2.3280893 4.1785165
29 49.2383996 35.3301571 42.8235916 43.4798804 18.3333030 3.5028560 1.0630146
30 42.1572058 28.1955670 35.5686660 36.4539435 12.6546434 4.0024992 7.5564542
31 35.8041897 21.9431083 29.6057427 29.9041803 5.0388491 11.0358507 14.2677959
32 8.1712912 12.2625446 4.6421978 7.7788174 31.0267626 43.8586365 47.4240445
33 37.4923992 23.2937760 30.6623548 31.7190794 9.4578010 8.8820043 12.5175876
34 23.1357753 32.3828983 25.0062012 27.2242190 50.6977919 62.0235931 65.5586920
22 23 24 25 26 27 28
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 8.1000000
24 1.8027756 6.5681047
25 7.8421936 2.8089144 6.6895441
26 7.6328239 2.3769729 6.4660653 0.9273618
27 7.9082236 1.7058722 6.5612499 1.1401754 1.1224972
28 5.0852729 3.8483763 3.5227830 5.2402290 4.6904158 4.6238512
29 7.7839579 1.7492856 6.5069194 1.3000000 0.6403124 0.8062258 4.4283180
30 1.2884099 7.5637292 1.0049876 7.6459139 7.4458042 7.5485098 4.4090815
31 7.6544105 14.5924638 8.9230040 13.4152898 13.6341483 13.8423264 12.3955637
32 39.6047977 47.4983158 40.9725518 47.0510361 47.0610242 47.2467988 44.2047509
33 4.5705580 12.5928551 6.0448325 12.2837291 12.1536003 12.3971771 9.3653617
34 57.8030285 65.4856633 59.0311621 65.5281474 65.4124155 65.5434520 61.9016971
29 30 31 32 33
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 7.5026662
31 13.9556440 8.2176639
32 47.2674306 39.9762429 34.1328288
33 12.3247718 5.0783856 5.3272882 35.0406906
34 65.5228060 58.0295451 53.4388445 20.7956269 53.3047850
#install.packages("proxy")
library (proxy)
# Calcular distancias euclidianas con proxy
euclidean_distances_proxy <- dist (data, method = "Euclidean" , diag = TRUE , upper = TRUE )
# Mostrar las distancias
print (euclidean_distances_proxy)
1 2 3 4 5 6 7
1 0.0000000 39.6355901 41.8289374 46.7364954 52.4737077 63.5499017 31.3063891
2 39.6355901 0.0000000 3.8052595 8.9409172 13.3435378 25.2786471 8.9190807
3 41.8289374 3.8052595 0.0000000 5.4018515 10.6943911 22.1903132 12.1041315
4 46.7364954 8.9409172 5.4018515 0.0000000 6.4722485 17.0296800 17.4450566
5 52.4737077 13.3435378 10.6943911 6.4722485 0.0000000 12.1268298 22.2625246
6 63.5499017 25.2786471 22.1903132 17.0296800 12.1268298 0.0000000 34.1569905
7 31.3063891 8.9190807 12.1041315 17.4450566 22.2625246 34.1569905 0.0000000
8 43.8703772 4.7106263 2.3558438 4.5617979 8.7441409 20.5781437 13.5852862
9 38.5535991 5.3235327 4.0422766 8.1914590 14.2642911 25.1175238 10.5057127
10 47.1699057 10.6667708 6.9036222 2.3874673 7.3273460 16.4496201 18.7906892
11 55.8090494 16.5435788 14.0516903 9.7678043 3.3823069 9.5571962 25.4444493
12 52.0923219 15.8773423 12.2004098 7.2076348 7.2732386 11.8667603 24.1756075
13 41.9859500 3.4785054 0.7874008 5.6356011 10.5228323 22.1822001 12.0370262
14 50.9533120 11.9724684 9.1923882 5.0139805 1.5652476 13.3637570 20.8837257
15 40.1583117 5.3768020 2.9444864 6.7149088 12.5880896 23.4380033 11.8878089
16 32.9759003 10.5275828 14.2558760 19.4599589 23.1503780 35.2740698 4.9719212
17 38.9775576 3.8742741 7.4411021 12.2126983 15.4706173 27.5916654 7.9536155
18 36.0839299 3.6290495 6.2297673 11.5702204 16.6703329 28.3890824 5.9110067
19 20.4244951 28.7482173 32.1735917 37.5475698 41.8350332 53.9239279 20.1715146
20 28.1183214 42.4106119 46.0015217 51.3180280 54.7489726 66.8014221 34.5544498
21 28.8190909 45.8983660 49.4592762 54.7959853 58.3092617 70.3628453 37.9311218
22 27.7668868 38.2578097 41.8829321 47.1696937 50.4964355 62.5443043 30.5668121
23 29.1617901 46.0109770 49.5666218 54.8978142 58.3647154 70.4007102 38.1006562
24 27.5515880 39.5789085 43.1681596 48.4721570 51.8414892 63.8769129 31.8411683
25 28.1200996 45.4482123 49.0238717 54.3654302 57.9731835 70.0614730 37.3685697
26 28.9160855 45.5376767 49.1300315 54.4586081 57.9776681 70.0537651 37.5439742
27 28.3326667 45.6725300 49.2355563 54.5782008 58.1490327 70.2200114 37.6405367
28 29.4248195 42.8980186 46.4766608 51.7665915 55.0309913 67.0236525 35.2492553
29 29.0370453 45.7555461 49.3397406 54.6696442 58.1730178 70.2398747 37.7828003
30 27.3850324 38.5963729 42.1872019 47.4870509 50.8418135 62.8748757 30.8925557
31 23.4595396 32.3049532 35.8827256 41.2195342 45.0659517 57.1909084 24.1051862
32 43.2714687 4.3058100 5.6089215 8.7338422 10.9530818 23.0722777 12.2053267
33 27.3790066 33.7489259 37.3891696 42.6550114 45.9292935 57.9760295 26.2137369
34 61.8873986 23.9295654 21.7111976 18.1270544 12.3925825 10.7765533 32.4137641
8 9 10 11 12 13 14
1 43.8703772 38.5535991 47.1699057 55.8090494 52.0923219 41.9859500 50.9533120
2 4.7106263 5.3235327 10.6667708 16.5435788 15.8773423 3.4785054 11.9724684
3 2.3558438 4.0422766 6.9036222 14.0516903 12.2004098 0.7874008 9.1923882
4 4.5617979 8.1914590 2.3874673 9.7678043 7.2076348 5.6356011 5.0139805
5 8.7441409 14.2642911 7.3273460 3.3823069 7.2732386 10.5228323 1.5652476
6 20.5781437 25.1175238 16.4496201 9.5571962 11.8667603 22.1822001 13.3637570
7 13.5852862 10.5057127 18.7906892 25.4444493 24.1756075 12.0370262 20.8837257
8 0.0000000 6.3882705 6.6037868 12.0341182 11.4743192 1.9824228 7.3218850
9 6.3882705 0.0000000 8.8306285 17.6462461 14.1862610 4.6151923 12.7239931
10 6.6037868 8.8306285 0.0000000 10.3561576 5.5145263 7.2539644 6.0033324
11 12.0341182 17.6462461 10.3561576 0.0000000 8.7647019 13.8509927 4.9325450
12 11.4743192 14.1862610 5.5145263 8.7647019 0.0000000 12.4173266 6.8854920
13 1.9824228 4.6151923 7.2539644 13.8509927 12.4173266 0.0000000 9.0410176
14 7.3218850 12.7239931 6.0033324 4.9325450 6.8854920 9.0410176 0.0000000
15 5.1419841 2.1470911 7.3000000 15.9580701 12.5211821 3.4597688 11.0276924
16 15.0705010 13.9129436 21.1567956 26.0395853 26.3229938 13.9359248 21.9456146
17 7.6720271 8.8707384 14.0872283 18.3842324 18.9915771 6.9130312 14.2720006
18 7.9284299 5.0009999 12.8860390 19.9494361 18.2701943 6.2377881 15.2292482
19 33.4468235 30.4772046 38.9122089 44.7960936 44.2136857 32.0140594 40.5605720
20 46.9490149 44.8546542 52.8321872 57.3972996 57.8989637 45.7014223 53.6171614
21 50.4552277 48.2080906 56.2702408 60.9804067 61.3432148 49.1727567 57.1617005
22 42.7678618 40.8737079 48.7319197 53.1173230 53.7855929 41.5651296 49.3838030
23 50.5499753 48.3440793 56.3685196 61.0209800 61.4115624 49.2711883 57.2217616
24 44.0901350 42.0923984 49.9908992 54.4780690 55.0203599 42.8535879 50.7141992
25 50.0408833 47.7202263 55.8546328 60.6729759 60.9966393 48.7573584 56.8188349
26 50.1097795 47.8967640 55.9690986 60.6459397 61.0885423 48.8497697 56.8388951
27 50.2486816 47.9474713 56.0530106 60.8390500 61.1579104 48.9597794 56.9949121
28 47.3728825 45.4380897 53.2787012 57.6233460 58.2512661 46.1469392 53.9193843
29 50.3195787 48.1103939 56.1707219 60.8373241 61.2707108 49.0551730 57.0335866
30 43.1011601 41.1336845 49.0095909 53.4764434 54.0323052 41.8690817 49.7157923
31 36.9494249 34.5469246 42.7264555 47.8725391 47.9727006 35.6523492 43.8747080
32 4.4011362 8.9409172 10.8729021 13.7771550 15.2823428 4.9030603 9.8620485
33 38.2355855 36.4862988 44.2426265 48.5470905 49.2798133 37.0579276 44.8219812
34 19.8587034 25.1614805 18.1689323 9.9990050 15.0023365 21.3603862 13.4954103
15 16 17 18 19 20 21
1 40.1583117 32.9759003 38.9775576 36.0839299 20.4244951 28.1183214 28.8190909
2 5.3768020 10.5275828 3.8742741 3.6290495 28.7482173 42.4106119 45.8983660
3 2.9444864 14.2558760 7.4411021 6.2297673 32.1735917 46.0015217 49.4592762
4 6.7149088 19.4599589 12.2126983 11.5702204 37.5475698 51.3180280 54.7959853
5 12.5880896 23.1503780 15.4706173 16.6703329 41.8350332 54.7489726 58.3092617
6 23.4380033 35.2740698 27.5916654 28.3890824 53.9239279 66.8014221 70.3628453
7 11.8878089 4.9719212 7.9536155 5.9110067 20.1715146 34.5544498 37.9311218
8 5.1419841 15.0705010 7.6720271 7.9284299 33.4468235 46.9490149 50.4552277
9 2.1470911 13.9129436 8.8707384 5.0009999 30.4772046 44.8546542 48.2080906
10 7.3000000 21.1567956 14.0872283 12.8860390 38.9122089 52.8321872 56.2702408
11 15.9580701 26.0395853 18.3842324 19.9494361 44.7960936 57.3972996 60.9804067
12 12.5211821 26.3229938 18.9915771 18.2701943 44.2136857 57.8989637 61.3432148
13 3.4597688 13.9359248 6.9130312 6.2377881 32.0140594 45.7014223 49.1727567
14 11.0276924 21.9456146 14.2720006 15.2292482 40.5605720 53.6171614 57.1617005
15 0.0000000 14.8094564 8.9297256 6.1497967 31.8441517 45.9370221 49.3154134
16 14.8094564 0.0000000 7.7006493 8.9230040 18.7843020 31.9870286 35.5090129
17 8.9297256 7.7006493 0.0000000 5.2306787 26.4138221 39.4320935 42.9728984
18 6.1497967 8.9230040 5.2306787 0.0000000 26.0463049 40.1966417 43.6076828
19 31.8441517 18.7843020 26.4138221 26.0463049 0.0000000 15.5267511 18.5294360
20 45.9370221 31.9870286 39.4320935 40.1966417 15.5267511 0.0000000 3.6578682
21 49.3154134 35.5090129 42.9728984 43.6076828 18.5294360 3.6578682 0.0000000
22 41.9195658 27.8030574 35.2120718 36.1481673 12.3450395 4.3497126 8.0062476
23 49.4224645 35.6356563 43.0597260 43.7453998 18.8438319 3.8013156 0.8062258
24 43.1270217 29.1749893 36.5611816 37.4197809 13.3869339 3.0083218 6.5566760
25 48.8946827 35.0332699 42.5801597 43.1113674 17.7048016 3.7815341 2.0099751
26 49.0423287 35.1002849 42.6156075 43.2574849 18.0449439 3.4727511 1.6673332
27 49.0869636 35.2761959 42.7809537 43.3503172 18.0914344 3.6193922 0.9055385
28 46.4287626 32.5249135 39.8302649 40.7800196 16.8029759 2.3280893 4.1785165
29 49.2383996 35.3301571 42.8235916 43.4798804 18.3333030 3.5028560 1.0630146
30 42.1572058 28.1955670 35.5686660 36.4539435 12.6546434 4.0024992 7.5564542
31 35.8041897 21.9431083 29.6057427 29.9041803 5.0388491 11.0358507 14.2677959
32 8.1712912 12.2625446 4.6421978 7.7788174 31.0267626 43.8586365 47.4240445
33 37.4923992 23.2937760 30.6623548 31.7190794 9.4578010 8.8820043 12.5175876
34 23.1357753 32.3828983 25.0062012 27.2242190 50.6977919 62.0235931 65.5586920
22 23 24 25 26 27 28
1 27.7668868 29.1617901 27.5515880 28.1200996 28.9160855 28.3326667 29.4248195
2 38.2578097 46.0109770 39.5789085 45.4482123 45.5376767 45.6725300 42.8980186
3 41.8829321 49.5666218 43.1681596 49.0238717 49.1300315 49.2355563 46.4766608
4 47.1696937 54.8978142 48.4721570 54.3654302 54.4586081 54.5782008 51.7665915
5 50.4964355 58.3647154 51.8414892 57.9731835 57.9776681 58.1490327 55.0309913
6 62.5443043 70.4007102 63.8769129 70.0614730 70.0537651 70.2200114 67.0236525
7 30.5668121 38.1006562 31.8411683 37.3685697 37.5439742 37.6405367 35.2492553
8 42.7678618 50.5499753 44.0901350 50.0408833 50.1097795 50.2486816 47.3728825
9 40.8737079 48.3440793 42.0923984 47.7202263 47.8967640 47.9474713 45.4380897
10 48.7319197 56.3685196 49.9908992 55.8546328 55.9690986 56.0530106 53.2787012
11 53.1173230 61.0209800 54.4780690 60.6729759 60.6459397 60.8390500 57.6233460
12 53.7855929 61.4115624 55.0203599 60.9966393 61.0885423 61.1579104 58.2512661
13 41.5651296 49.2711883 42.8535879 48.7573584 48.8497697 48.9597794 46.1469392
14 49.3838030 57.2217616 50.7141992 56.8188349 56.8388951 56.9949121 53.9193843
15 41.9195658 49.4224645 43.1270217 48.8946827 49.0423287 49.0869636 46.4287626
16 27.8030574 35.6356563 29.1749893 35.0332699 35.1002849 35.2761959 32.5249135
17 35.2120718 43.0597260 36.5611816 42.5801597 42.6156075 42.7809537 39.8302649
18 36.1481673 43.7453998 37.4197809 43.1113674 43.2574849 43.3503172 40.7800196
19 12.3450395 18.8438319 13.3869339 17.7048016 18.0449439 18.0914344 16.8029759
20 4.3497126 3.8013156 3.0083218 3.7815341 3.4727511 3.6193922 2.3280893
21 8.0062476 0.8062258 6.5566760 2.0099751 1.6673332 0.9055385 4.1785165
22 0.0000000 8.1000000 1.8027756 7.8421936 7.6328239 7.9082236 5.0852729
23 8.1000000 0.0000000 6.5681047 2.8089144 2.3769729 1.7058722 3.8483763
24 1.8027756 6.5681047 0.0000000 6.6895441 6.4660653 6.5612499 3.5227830
25 7.8421936 2.8089144 6.6895441 0.0000000 0.9273618 1.1401754 5.2402290
26 7.6328239 2.3769729 6.4660653 0.9273618 0.0000000 1.1224972 4.6904158
27 7.9082236 1.7058722 6.5612499 1.1401754 1.1224972 0.0000000 4.6238512
28 5.0852729 3.8483763 3.5227830 5.2402290 4.6904158 4.6238512 0.0000000
29 7.7839579 1.7492856 6.5069194 1.3000000 0.6403124 0.8062258 4.4283180
30 1.2884099 7.5637292 1.0049876 7.6459139 7.4458042 7.5485098 4.4090815
31 7.6544105 14.5924638 8.9230040 13.4152898 13.6341483 13.8423264 12.3955637
32 39.6047977 47.4983158 40.9725518 47.0510361 47.0610242 47.2467988 44.2047509
33 4.5705580 12.5928551 6.0448325 12.2837291 12.1536003 12.3971771 9.3653617
34 57.8030285 65.4856633 59.0311621 65.5281474 65.4124155 65.5434520 61.9016971
29 30 31 32 33 34
1 29.0370453 27.3850324 23.4595396 43.2714687 27.3790066 61.8873986
2 45.7555461 38.5963729 32.3049532 4.3058100 33.7489259 23.9295654
3 49.3397406 42.1872019 35.8827256 5.6089215 37.3891696 21.7111976
4 54.6696442 47.4870509 41.2195342 8.7338422 42.6550114 18.1270544
5 58.1730178 50.8418135 45.0659517 10.9530818 45.9292935 12.3925825
6 70.2398747 62.8748757 57.1909084 23.0722777 57.9760295 10.7765533
7 37.7828003 30.8925557 24.1051862 12.2053267 26.2137369 32.4137641
8 50.3195787 43.1011601 36.9494249 4.4011362 38.2355855 19.8587034
9 48.1103939 41.1336845 34.5469246 8.9409172 36.4862988 25.1614805
10 56.1707219 49.0095909 42.7264555 10.8729021 44.2426265 18.1689323
11 60.8373241 53.4764434 47.8725391 13.7771550 48.5470905 9.9990050
12 61.2707108 54.0323052 47.9727006 15.2823428 49.2798133 15.0023365
13 49.0551730 41.8690817 35.6523492 4.9030603 37.0579276 21.3603862
14 57.0335866 49.7157923 43.8747080 9.8620485 44.8219812 13.4954103
15 49.2383996 42.1572058 35.8041897 8.1712912 37.4923992 23.1357753
16 35.3301571 28.1955670 21.9431083 12.2625446 23.2937760 32.3828983
17 42.8235916 35.5686660 29.6057427 4.6421978 30.6623548 25.0062012
18 43.4798804 36.4539435 29.9041803 7.7788174 31.7190794 27.2242190
19 18.3333030 12.6546434 5.0388491 31.0267626 9.4578010 50.6977919
20 3.5028560 4.0024992 11.0358507 43.8586365 8.8820043 62.0235931
21 1.0630146 7.5564542 14.2677959 47.4240445 12.5175876 65.5586920
22 7.7839579 1.2884099 7.6544105 39.6047977 4.5705580 57.8030285
23 1.7492856 7.5637292 14.5924638 47.4983158 12.5928551 65.4856633
24 6.5069194 1.0049876 8.9230040 40.9725518 6.0448325 59.0311621
25 1.3000000 7.6459139 13.4152898 47.0510361 12.2837291 65.5281474
26 0.6403124 7.4458042 13.6341483 47.0610242 12.1536003 65.4124155
27 0.8062258 7.5485098 13.8423264 47.2467988 12.3971771 65.5434520
28 4.4283180 4.4090815 12.3955637 44.2047509 9.3653617 61.9016971
29 0.0000000 7.5026662 13.9556440 47.2674306 12.3247718 65.5228060
30 7.5026662 0.0000000 8.2176639 39.9762429 5.0783856 58.0295451
31 13.9556440 8.2176639 0.0000000 34.1328288 5.3272882 53.4388445
32 47.2674306 39.9762429 34.1328288 0.0000000 35.0406906 20.7956269
33 12.3247718 5.0783856 5.3272882 35.0406906 0.0000000 53.3047850
34 65.5228060 58.0295451 53.4388445 20.7956269 53.3047850 0.0000000
import pandas as pd
import numpy as np
from scipy.spatial import distance
# Cargar los datos
data = pd.read_csv('accion.txt' , sep= ' \t ' )
# Calcular la matriz de covarianzas
cov_matrix = np.cov(data.T)
# Calcular la inversa de la matriz de covarianzas
inv_cov_matrix = np.linalg.inv(cov_matrix)
# Calcular la media de cada variable
mean_data = data.mean().values
# Calcular la matriz de distancias de Mahalanobis
mahalanobis_matrix = distance.cdist(data, data, 'mahalanobis' , VI= inv_cov_matrix)
print ("Matriz de distancias de Mahalanobis:" )
Matriz de distancias de Mahalanobis:
print (mahalanobis_matrix)
[[0. 5.23121856 4.84362218 ... 5.8481407 5.51831508 6.79821955]
[5.23121856 0. 0.52647286 ... 0.73364113 1.72759331 5.02067693]
[4.84362218 0.52647286 0. ... 1.07374101 1.87998086 4.7178646 ]
...
[5.8481407 0.73364113 1.07374101 ... 0. 1.56504562 4.75801024]
[5.51831508 1.72759331 1.87998086 ... 1.56504562 0. 4.61292473]
[6.79821955 5.02067693 4.7178646 ... 4.75801024 4.61292473 0. ]]
import pandas as pd
from scipy.spatial import distance
# Cargar los datos (asumiendo que ya está cargado como 'data')
# Calcular la matriz de distancias euclidianas
euclidean_matrix = distance.cdist(data, data, 'euclidean' )
print ("Matriz de distancias euclidianas:" )
Matriz de distancias euclidianas:
[[ 0. 39.63559007 41.82893735 ... 43.27146866 27.37900656
61.88739856]
[39.63559007 0. 3.80525952 ... 4.30581003 33.74892591
23.9295654 ]
[41.82893735 3.80525952 0. ... 5.60892146 37.38916955
21.71119757]
...
[43.27146866 4.30581003 5.60892146 ... 0. 35.04069063
20.79562694]
[27.37900656 33.74892591 37.38916955 ... 35.04069063 0.
53.30478496]
[61.88739856 23.9295654 21.71119757 ... 20.79562694 53.30478496
0. ]]