Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@


# Checkpoints will not be pushed.
.ipynb_checkpoints
.venv
.env
94 changes: 84 additions & 10 deletions notebook/problems.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,55 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"id": "34720ab6",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Distribucion Normal\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: 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"
]
}
],
"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))"
]
},
{
Expand All @@ -48,21 +91,52 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 5,
"id": "d590308e",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Desviación estándar con funcion: 2.00\n",
"Desviación estándar con metodo np.std: 2.00\n"
]
}
],
"source": [
"# TODO"
"datos = [4, 2, 5, 8, 6]\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=0) \n",
"\n",
"print(f\"Desviación estándar con metodo np.std: {desviacion_estándar(datos):.2f}\") "
]
}
],
"metadata": {
"interpreter": {
"hash": "9248718ffe6ce6938b217e69dbcc175ea21f4c6b28a317e96c05334edae734bb"
},
"kernelspec": {
"display_name": "Python 3.9.12 ('ML-BOOTCAMP')",
"display_name": ".venv",
"language": "python",
"name": "python3"
},
Expand Down