ZHAWNotes/Notes/Semester 3/STS - Stochastik und Statistik/Diagrams.ipynb

193 lines
113 KiB
Text
Raw Permalink Normal View History

2023-01-19 23:01:37 +00:00
{
"cells": [
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\Manuel\\AppData\\Local\\Temp\\ipykernel_21784\\915643508.py:9: MatplotlibDeprecationWarning: The 'use_line_collection' parameter of stem() was deprecated in Matplotlib 3.6 and will be removed two minor releases later. If any parameter follows 'use_line_collection', they should be passed as keyword, not positionally.\n",
" plt.stem(A,f, linefmt='red',markerfmt='ro', use_line_collection=True)\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAnkAAAHWCAYAAAALq58HAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAACTqklEQVR4nOzdfVyN9/8H8Ncp1Ul3ojsSJXNPUQqNmMg0WwzNzVTDxuSuMZr7beRevnMT9h2xIffbd3OXlLmbu9yMYdiIqBjdUzp9fn/068zRKeecTk43r+fjcR46n/O5rut9fTrX1dvn+lyfSyKEECAiIiKiKkVP1wEQERERkfYxySMiIiKqgpjkEREREVVBTPKIiIiIqiAmeURERERVEJM8IiIioiqISR4RERFRFcQkj4iIiKgKYpJHREREVAUxyStn8fHxkEgkiI+P1+p6JRIJZs+erdV1lpd33nkHjo6OAIDZs2dDIpHg0aNHGq8vPz8fn3/+ORwcHKCnpwd/f38AZWsTiUSCkJAQjWN6UdE+atOmTZvQrFkzGBgYoFatWlpd94scHR3xzjvvaLx8eew7VQ23b9+GRCLBhg0btLpeR0dHBAUFaXWdVdHL7VRef5vK25kzZ9CpUyeYmJhAIpHgwoUL5bKdoKAgmJqaarx8RWlfJnkv2LBhAyQSifxVo0YN2NvbIygoCElJSa89nr1791a4RK60ZKio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5WUFAgOnXqJN544w15mbJxDzk5OcW2HR4
"text/plain": [
"<Figure size 640x480 with 3 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"A=np.arange(1,7,1) # Mögliche Ergebnisse\n",
"h=np.array([4, 3, 4, 0, 6, 3])\n",
"# Absolute Häufigkeiten\n",
"f = h/20 # relative Häufigkeiten\n",
"plt.figure(1)\n",
"plt.subplot(2,2,1)\n",
"plt.stem(A,f, linefmt='red',markerfmt='ro', use_line_collection=True)\n",
"plt.ylabel('Relative Häufigkeit')\n",
"plt.xlabel('Würfelergebnisse')\n",
"plt.title('Relative Häufigkeitsfunktion')\n",
"plt.subplot(2,2,3)\n",
"plt.bar(A,f, 0.4,color=\"red\")\n",
"plt.ylabel('Relative Häufigkeit')\n",
"plt.xlabel('Würfelergebnisse')\n",
"plt.title('Relative Häufigkeitsfunktion')\n",
"plt.tight_layout()\n",
"\n",
"A=np.array([1, 2, 3, 4, 5]) # Anzahl der Flugreisen\n",
"h=np.array([9, 8, 5, 7, 1]) # Absolute Häufigkeit\n",
"n=np.sum(h) # Grösse der Stichprobe\n",
"f=h/n # relative Häufigkeit\n",
"H=np.cumsum(h) # absolute Summenhäufigkeit\n",
"F=np.cumsum(f) # relative Summenhäufigkeit, kumulative Verteilungsfunktion (CDF)\n",
"# Anpassung der Arrays, damit der Plot schöner wird\n",
"A_p=np.concatenate((np.array([0]),A,np.array([6])),axis=0)\n",
"h_p=np.concatenate((np.array([0]),h,np.array([0])),axis=0)\n",
"H_p=np.concatenate((np.array([0]),H,np.array([n])),axis=0)\n",
"f_p=h_p/n\n",
"F_p=np.cumsum(f_p)\n",
"\n",
"plt.subplot(2,2,(2,4))\n",
"plt.step(A_p, F_p,where='post', color='red')\n",
"plt.title('Kumulative Verteilungsfunktion')\n",
"plt.xlabel('Anzahl Flugreisen')\n",
"plt.ylabel('Anteil')\n",
"plt.xlim(0,6)\n",
"plt.ylim(0,1)\n",
"plt.tight_layout()"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(0.0, 0.0014793333333333332)"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlEAAAHHCAYAAACfqw0dAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAABknElEQVR4nO3deVxUZfs/8M8MyLDJoCkMmCIqiikuYYyoiQuJSxlqoUiJ5p6aRlZSLtlXxdyXx9LU1HK33HIrQixTREVx11xQfExwZQZQ2eb+/eGP83hkwJkRYunzfr3OC+Y+17nPdc8B5uKcM/cohBACRERERGQWZWknQERERFQesYgiIiIisgCLKCIiIiILsIgiIiIisgCLKCIiIiILsIgiIiIisgCLKCIiIiILsIgiIiIisgCLKCIiIiILsIgiMtHrr7+O2rVrAwC++OILKBQK3LlzRxZTWLu5FAoFvvjiC+nxypUroVAocPXqVbP6adeuHRo3bvxcufzbFNcxLC/27dsHhUKBffv2lXYqROUOiygiI/KLlqNHj0ptY8eOxbx58wAAPXv2xA8//IDKlSuXUoZlV0hICBQKBT799NPSTuVfqajC+erVq1AoFJg1a9Zz72fatGnYunXrc/dDVJ6xiCIyUbt27RAcHAwAaNKkCd555x2oVKp/ZN/vvvsuHj58CA8Pj39kf5bS6/X4+eefUbt2baxbtw78aM6yr23btnj48CHatm1r1nYsoohYRBGVGQaDAY8ePTK6zsrKCra2tlAoFP9wVub56aefkJeXh++++w7Xr1/HH3/8Udop0TMolUrY2tpCqSw/LwdCCDx8+LC00yBiEUVkipMnT6J///6oU6cObG1t4erqigEDBhR630xaWhr69+8PZ2dnqNVqDBgwAA8ePJDFKBQKjBw5EmvWrEGjRo2gUqmwZ88eo/0Vdk/U7t27ERAQgMqVK8PJyQm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szo4dO5CTk2M0Zs+ePahUqRIGDx4stSmVygJnIADAzs5O+t6UY/h0H6NGjQIA7Nq1C8Djyz8GgwEhISGy50yj0cDLy6vAc2bKcSgutWvXRnR0dIFl9erVz9xWrVYDAH755ZcCl6CfJS8vD7/++iuCg4NRp04dqd3NzQ19+/bFn3/+Kf0O7NmzB/7+/mjWrJkUV7VqVYSFhRnt29PTE0FBQQXanzyuOp0Od+7cQUBAAK5cuSJdfsz30ksvwd/fX3qcf1asQ4cOqFWrVoF2Y8dm0KBB0vfOzs5o0KABHBwcEBISIrU3aNAAzs7OJXJsqWzh5TwiE9y7dw+TJ0/G+vXrcevWLdm6p/9QA5D9QQaAKlWqAHh8OcXJyUlqt/RU/+XLlwHApDmgXnzxxQKFVZUqVXDy5Enp8cWLF3Hu3DlUr17daB9Pj/lp586dw/Hjx9GvXz9cunRJam/Xrh0WLVoEvV4vG7cpAgIC0KtXL0yePBlz586V3h3Zt29f6ZLPtWvX4ObmJityAaBevXoF+jP3GHp5ecke161bF0qlUrpX5+LFixBCFIjLV6lSJdljU46DMffu3UN2drb02M7OTip0CuPg4IDAwMAC7abMM+bp6YmIiAjMmTMHa9aswauvvoru3bvjnXfeeeZ+b9++jQcPHkiX2p7UsGFDGAwGXL9+HY0aNcK1a9dkBU0+Y8cuPy9jDhw4gEmTJiEuLq5A0afT6WQ5P/17mb+uZs2aRtufvvxpa2tb4HdErVYbPbZqtdqky6dUvrGIIjJBSEgIDh48iI8//hjNmjWDo6MjDAYDOnfuDIPBUCDeysrKaD/iqbf8P/lfdEkxJReDwQAfHx/MmTPHaOzTLzJPyz/D8eGHH+LDDz8ssP6nn37CgAEDABQ8U5YvLy9P9lihUODHH3/
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"#Ausgaben für Transport\n",
"#stetig metrisches Merkmal und Klassierung der Daten\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from scipy.stats import norm\n",
"K=np.array([0, 100, 200, 500, 800,\n",
"1000, 2000]) # Klassengrenzen\n",
"h=np.array([0, 35, 182, 317, 84, 132,0]) # absolute Klassenhäufigkeiten\n",
"APDF=np.array([0, 35/100, 182/300, 317/300, 84/200, 132/1000, 0]) # absolute Säulenhöhen im Histogramm\n",
"PDF=APDF/np.sum(h) # Säulenhöhen der PDF im Histogramm\n",
"plt.figure(1)\n",
"plt.step(K,PDF,color='red',where='post')\n",
"plt.xlabel('Ausgaben in Franken')\n",
"plt.ylabel('Häufigkeitsverteilung - PDF')\n",
"plt.title('Jährliche Ausgaben - Histogramm')\n",
"plt.xlim(left=0)\n",
"plt.ylim(ymin=0)"
]
},
{
"cell_type": "code",
2023-01-20 00:25:07 +00:00
"execution_count": 20,
2023-01-19 23:01:37 +00:00
"metadata": {},
2023-01-20 00:25:07 +00:00
"outputs": [
{
"data": {
"text/plain": [
"Text(0.5, 1.0, 'CDF der Stichprobe')"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAigAAAGzCAYAAAAFROyYAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAABGsklEQVR4nO3deXwTZf4H8E+SNulFC0hvSlvkLEdBelhBC1isXCv8RBBYWw5RobhAV9F6AK5C0RUsKseiKCzKcrkgazkWKgVdQKRskVsrLUWhlywtTXom8/sjJW1sUpo0MJP083698no9M/OdyTdDab6d55lnZIIgCCAiIiKSELnYCRARERH9HgsUIiIikhwWKERERCQ5LFCIiIhIcligEBERkeSwQCEiIiLJYYFCREREksMChYiIiCSHBQoRERFJDgsUolZq/fr1kMlkyMvLEzuVZrE238GDB6N37953Jikr5eXlQSaT4d133xU7FSLJYoFCZEM///wznn32WXTu3BkuLi7w9PTEwIEDsWLFClRUVBjiQkJCIJPJIJP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hIaGmhxD4+npiffeew9PP/00IiMjMWnSJLRr1w6nTp2CRqNpcu6RprRv3x6DBg3C1KlTUVhYiLS0NHTp0gUzZsy47b7PPPMM/va3v2HKlCnIyspCSEgItm/fjv/85z9IS0trNKaoS5cuGDRoEGbOnImqqiqkpaXhnnvuwfz58w0xK1euxKBBg9CnTx/MmDEDnTt3RmFhIY4ePYpffvkFp06dsupzEkm
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
2023-01-19 23:01:37 +00:00
"source": [
"#Quantile (aus CDF)\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"X=np.array([4, 4, 0, 3, 5, 3, 1])\n",
"Xnum,absH =np.unique(X, return_counts=True)\n",
"relH=absH/np.size(X)\n",
"kumrelH =np.cumsum(relH)\n",
"plt.figure()\n",
"plt.step(Xnum,kumrelH,where='post',color='red')\n",
"plt.xlim(0, np.max(X)+1)\n",
"plt.ylim(0, 1)\n",
"plt.vlines(1,0,0.25,color='blue',linestyles='dashed',label='1.Quartil') #1.Quartil\n",
"plt.hlines(0.25,0,1,color='blue',linestyles='dashed')\n",
"plt.vlines(3,0,0.5,color='green',linestyles='dashed',label='2.Quartil') #Median\n",
"plt.hlines(0.5,0,3,color='green',linestyles='dashed')\n",
"plt.vlines(4,0,0.75,color='orange',linestyles='dashed',label='3.Quartil') #3.Quartil\n",
"plt.hlines(0.75,0,4,color='orange',linestyles='dashed')\n",
"plt.legend()\n",
"plt.title('CDF der Stichprobe')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "ZHAWNotes-Ak5ZQvuq",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
2023-01-20 00:25:07 +00:00
"version": "3.10.9 (tags/v3.10.9:1dd9be6, Dec 6 2022, 20:01:21) [MSC v.1934 64 bit (AMD64)]"
2023-01-19 23:01:37 +00:00
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "87f2d5b0071e13b61e3a14b462e646856b285d3e0a05b12e6d8f67f82f2e6023"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}