From 96c61e270ab33b0a14a5d6a68058511510e795df Mon Sep 17 00:00:00 2001 From: lab2077 Date: Sun, 2 Feb 2025 23:49:12 +0000 Subject: [PATCH 1/3] Proyecto Estadistica Descriptiva - Luis Alpizar --- .gitignore | 6 ++-- notebook/problems.ipynb | 73 +++++++++++++++++++++++++++++++++++------ 2 files changed, 65 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 03fc1690..8d193625 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,2 @@ - - -# Checkpoints will not be pushed. -.ipynb_checkpoints +.venv +.env diff --git a/notebook/problems.ipynb b/notebook/problems.ipynb index a253f320..b26e4e06 100644 --- a/notebook/problems.ipynb +++ b/notebook/problems.ipynb @@ -24,12 +24,55 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 19, "id": "34720ab6", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Distribucion Normal\n", + "Media: -0.0042\n", + "Mediana: 0.0204\n", + "Desviación estándar: 1.0014\n", + "Varianza: 1.0028\n", + "Mínimo: -2.5938\n", + "Máximo: 2.7605\n", + "None\n", + "\n", + "Distribucion Chi-Cuadrado\n", + "Media: 3.5563\n", + "Mediana: 2.8927\n", + "Desviación estándar: 2.5395\n", + "Varianza: 6.4492\n", + "Mínimo: 0.4556\n", + "Máximo: 11.3482\n", + "None\n" + ] + } + ], "source": [ - "# TODO" + "import numpy as np\n", + "\n", + "# Generación de datos con distribuciones\n", + "distribucion_normal = np.random.normal(size=100)\n", + "distribucion_chi_square = np.random.chisquare(df=3, size=100)\n", + "\n", + "# Cálculo de Medidas de tendencia \n", + "def medidas_estadisticas(datos):\n", + " #print(f\"\\nEstadísticas para {name}:\")\n", + " print(f\"Media: {np.mean(datos):.4f}\")\n", + " print(f\"Mediana: {np.median(datos):.4f}\")\n", + " print(f\"Desviación estándar: {np.std(datos):.4f}\")\n", + " print(f\"Varianza: {np.var(datos):.4f}\")\n", + " print(f\"Mínimo: {np.min(datos):.4f}\")\n", + " print(f\"Máximo: {np.max(datos):.4f}\")\n", + "\n", + "print(\"Distribucion Normal\")\n", + "print(medidas_estadisticas(distribucion_normal))\n", + "print(\"\\nDistribucion Chi-Cuadrado\")\n", + "print(medidas_estadisticas(distribucion_chi_square))" ] }, { @@ -48,21 +91,31 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 29, "id": "d590308e", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Desviación estándar: 2.2361\n" + ] + } + ], "source": [ - "# TODO" + "datos = [4, 2, 5, 8, 6]\n", + "# Cálculo de la desviación estándar\n", + "def desviacion_estándar(datos):\n", + " return np.std(datos, ddof=1) \n", + "\n", + "print(f\"Desviación estándar: {desviacion_estándar(datos):.4f}\")" ] } ], "metadata": { - "interpreter": { - "hash": "9248718ffe6ce6938b217e69dbcc175ea21f4c6b28a317e96c05334edae734bb" - }, "kernelspec": { - "display_name": "Python 3.9.12 ('ML-BOOTCAMP')", + "display_name": ".venv", "language": "python", "name": "python3" }, From fa1daba2fcc2a1c76a44590246643b056e69660e Mon Sep 17 00:00:00 2001 From: lab2077 Date: Thu, 6 Feb 2025 00:34:52 +0000 Subject: [PATCH 2/3] proyecto update --- notebook/problems.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notebook/problems.ipynb b/notebook/problems.ipynb index b26e4e06..f1e60fc2 100644 --- a/notebook/problems.ipynb +++ b/notebook/problems.ipynb @@ -109,7 +109,7 @@ "def desviacion_estándar(datos):\n", " return np.std(datos, ddof=1) \n", "\n", - "print(f\"Desviación estándar: {desviacion_estándar(datos):.4f}\")" + "print(f\"Desviación estándar: {desviacion_estándar(datos):.4f}\") " ] } ], From b0d25f812f70ecf33b5a646c9a3147a52c547dce Mon Sep 17 00:00:00 2001 From: lab2077 Date: Wed, 12 Feb 2025 01:00:22 +0000 Subject: [PATCH 3/3] Correcion Proyecto Estadistica Descriptiva - Luis Alpizar --- notebook/problems.ipynb | 57 ++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/notebook/problems.ipynb b/notebook/problems.ipynb index f1e60fc2..4ab23a3b 100644 --- a/notebook/problems.ipynb +++ b/notebook/problems.ipynb @@ -24,7 +24,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 2, "id": "34720ab6", "metadata": {}, "outputs": [ @@ -33,21 +33,21 @@ "output_type": "stream", "text": [ "Distribucion Normal\n", - "Media: -0.0042\n", - "Mediana: 0.0204\n", - "Desviación estándar: 1.0014\n", - "Varianza: 1.0028\n", - "Mínimo: -2.5938\n", - "Máximo: 2.7605\n", + "Media: -0.0633\n", + "Mediana: -0.0275\n", + "Desviación estándar: 0.9305\n", + "Varianza: 0.8659\n", + "Mínimo: -2.9169\n", + "Máximo: 2.0706\n", "None\n", "\n", "Distribucion Chi-Cuadrado\n", - "Media: 3.5563\n", - "Mediana: 2.8927\n", - "Desviación estándar: 2.5395\n", - "Varianza: 6.4492\n", - "Mínimo: 0.4556\n", - "Máximo: 11.3482\n", + "Media: 2.8621\n", + "Mediana: 2.0939\n", + "Desviación estándar: 2.4748\n", + "Varianza: 6.1247\n", + "Mínimo: 0.0704\n", + "Máximo: 13.2238\n", "None\n" ] } @@ -91,7 +91,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 5, "id": "d590308e", "metadata": {}, "outputs": [ @@ -99,17 +99,38 @@ "name": "stdout", "output_type": "stream", "text": [ - "Desviación estándar: 2.2361\n" + "Desviación estándar con funcion: 2.00\n", + "Desviación estándar con metodo np.std: 2.00\n" ] } ], "source": [ "datos = [4, 2, 5, 8, 6]\n", - "# Cálculo de la desviación estándar\n", + "\n", + "#Calculo de la media\n", + "def media(data):\n", + " n = len(data)\n", + " return sum(data)/n\n", + "\n", + "#Funcion para calcular Desviacion Estandar\n", + "def desviacion_std(data):\n", + " promedio = media(data)\n", + "\n", + " #Calculo de varianza\n", + " resta_al_cuadrado = [(x - promedio) ** 2 for x in datos]\n", + " varianza = sum(resta_al_cuadrado)/len(data)\n", + " \n", + " #Cálculo de la desviación estándar\n", + " desviacion = np.sqrt(varianza)\n", + "\n", + " return desviacion\n", + "\n", + "print(f\"Desviación estándar con funcion: {desviacion_std(datos):.2f}\") \n", + "\n", "def desviacion_estándar(datos):\n", - " return np.std(datos, ddof=1) \n", + " return np.std(datos, ddof=0) \n", "\n", - "print(f\"Desviación estándar: {desviacion_estándar(datos):.4f}\") " + "print(f\"Desviación estándar con metodo np.std: {desviacion_estándar(datos):.2f}\") " ] } ],