Last active
November 28, 2019 16:45
-
-
Save nicoguaro/a96d48a9c0939d148fb7c7a6bc35edde to your computer and use it in GitHub Desktop.
Correlacion entre "inflación" y "número de derechos" a partir de los datos presentados en el siguiente Tweet: https://mobile.twitter.com/clarroulet/status/730931861384507392
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inflacion | numero de derechos | |
---|---|---|
6.0138 | 0.46416 | |
11.0544 | 2.4572 | |
12.994 | 0.6078 | |
13.9903 | 1.84 | |
15.0101 | 2.7067 | |
15.063 | 1.4534 | |
18.002 | 1.0252 | |
19.9824 | 1.1332 | |
20.942 | 0.5634 | |
23.008 | 1.3474 | |
25.947 | 2.9282 | |
26.016 | 0.3153 | |
27.106 | 0.6946 | |
28.06 | 0.9875 | |
28.911 | 1.1842 | |
30.91 | 3.6254 | |
30.946 | 0.30144 | |
31.055 | 3.1928 | |
31.942 | 2.3881 | |
32.017 | 6.322 | |
32.09 | 3.2847 | |
32.943 | 1.9893 | |
33.008 | 5.709 | |
33.04 | 4.3187 | |
33.066 | 0.9924 | |
33.95 | 0.20593 | |
34.919 | 8.303 | |
35.001 | 2.9432 | |
35.059 | 1.6254 | |
35.727 | 1.8111 | |
35.874 | 3.223 | |
35.916 | 0.6464 | |
36.064 | 2.897 | |
36.085 | 4.4284 | |
36.759 | 0.9994 | |
37.028 | 4.6766 | |
38.018 | 2.9438 | |
38.041 | 0.808 | |
38.085 | 6.003 | |
38.715 | 5.922 | |
38.84 | 1.053 | |
38.897 | 0.9552 | |
38.943 | 2.0153 | |
39.746 | 1.0333 | |
39.82 | 1.8871 | |
40.054 | 3.2904 | |
40.099 | 1.2039 | |
40.195 | 4.6775 | |
40.717 | 2.0339 | |
40.957 | 5.0301 | |
40.964 | 3.539 | |
43.024 | 1.0044 | |
43.075 | 0.8966 | |
43.916 | 9.497 | |
43.942 | 1.5458 | |
44.097 | 0.6923 | |
44.122 | 1.7254 | |
44.149 | 5.713 | |
44.879 | 4.1204 | |
44.985 | 8.634 | |
45.409 | 5.924 | |
45.783 | 0.7738 | |
45.81 | 1.0137 | |
45.864 | 4.3711 | |
45.918 | 1.1775 | |
46.87 | 0.9732 | |
47.813 | 3.3981 | |
47.841 | 1.2239 | |
47.859 | 11.444 | |
47.869 | 2.7021 | |
47.897 | 1.6664 | |
48.038 | 0.7686 | |
48.805 | 9.762 | |
48.948 | 0.19168 | |
48.969 | 7.058 | |
49.005 | 3.9117 | |
49.178 | 37.072 | |
49.7 | 7.798 | |
50.82 | 23.981 | |
51.934 | 0.9712 | |
52.087 | 3.9035 | |
52.763 | 2.1443 | |
53.001 | 5.2847 | |
53.26 | 0.45002 | |
53.401 | 0.9713 | |
54.123 | 9.814 | |
54.31 | 9.093 | |
54.684 | 4.1225 | |
54.877 | 4.545 | |
55.297 | 0.9691 | |
55.818 | 0.22991 | |
55.9 | 1.2525 | |
56.022 | 6.024 | |
56.265 | 8.704 | |
56.643 | 8.133 | |
56.792 | 1.0188 | |
56.875 | 0.35547 | |
57.197 | 6.813 | |
59.152 | 5.4045 | |
59.878 | 6.131 | |
59.992 | 0.9573 | |
61.021 | 5.756 | |
61.039 | 1.3733 | |
61.055 | 15.432 | |
61.236 | 1.1571 | |
61.958 | 18.273 | |
62.177 | 13.179 | |
62.76 | 3.0369 | |
62.794 | 4.1988 | |
63.058 | 2.6674 | |
63.951 | 2.3069 | |
64.129 | 7.93 | |
64.702 | 5.0791 | |
64.896 | 6.233 | |
65.033 | 10.271 | |
65.469 | 23.564 | |
65.767 | 0.47252 | |
65.777 | 0.23851 | |
67.338 | 0.7219 | |
67.932 | 6.012 | |
68.172 | 0.9919 | |
68.257 | 8.798 | |
68.936 | 7.509 | |
69.585 | 12.039 | |
69.725 | 4.6169 | |
69.974 | 1.0113 | |
70.882 | 1.0826 | |
71.908 | 3.1994 | |
71.992 | 6.968 | |
72.102 | 0.18203 | |
73.794 | 2.4559 | |
73.874 | 0.9831 | |
74.265 | 4.9919 | |
74.765 | 3.0116 | |
75.987 | 2.8589 | |
76.049 | 1.0081 | |
76.789 | 1.5763 | |
77.15 | 7.376 | |
77.285 | 5.959 | |
79.306 | 6.435 | |
79.899 | 7.3 | |
80.476 | 3.9792 | |
82 | 61.71 | |
82.118 | 2.9643 | |
86.342 | 0.9835 | |
87.566 | 2.0704 | |
87.978 | 5.722 | |
98.721 | 3.5948 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
Correlacion entre "inflación" y "número de derechos" a partir | |
de los datos presentados en el siguiente Tweet: | |
https://mobile.twitter.com/clarroulet/status/730931861384507392 | |
@author: Nicolás Guarín-Zapata | |
""" | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from scipy.stats import linregress | |
repo = "https://raw.githubusercontent.com/nicoguaro/matplotlib_styles/master" | |
style = repo + "/styles/minimalist.mplstyle" | |
plt.style.use(repo + style) | |
#%% Configuración gráficos | |
data = np.loadtxt("inflacion_vs_derechos.csv", skiprows=1, delimiter=",") | |
x, y = data.T | |
# Regresión lineal del logaritmo de las variables | |
slope, intercept, r_value, p_value, std_err = linregress(np.log10(x), | |
np.log10(y)) | |
#%% Graficación | |
plt.close("all") | |
# Escala lineal | |
plt.figure() | |
plt.plot(x, y, lw=0, marker="o") | |
plt.plot(x, 10**intercept*x**slope) | |
plt.text(20, 50, "$y = %.4f\, x^{%.4f} $" % (10**intercept, slope)) | |
plt.text(20, 45, "$R^2 = %.4f$" % (r_value**2)) | |
plt.xlabel("Número de derechos") | |
plt.ylabel("Inflación") | |
plt.savefig("inflacion_vs_derechos.png", dpi=600, bbox_inches="tight") | |
# Escala logarítmica | |
plt.figure() | |
plt.loglog(x, y, lw=0, marker="o") | |
plt.loglog(x, 10**intercept*x**slope) | |
plt.text(10, 20, "$y = %.4f\, x %.4f $" % (slope, intercept)) | |
plt.text(10, 10, "$R^2 = %.4f$" % (r_value**2)) | |
plt.xlabel("Número de derechos") | |
plt.ylabel("Inflación") | |
plt.savefig("inflacion_vs_derechos-log.png", dpi=600, bbox_inches="tight") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment