172 lines
88 KiB
Plaintext
172 lines
88 KiB
Plaintext
|
{
|
||
|
"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+GRCLBhg0btLpeR0dHBAUFaXWdVdHL7VRef5vK25kzZ9CpUyeYmJhAIpHgwoUL5bKdoKAgmJqaarx8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0KFD4uHDh+Lu3btix44dwtraWhgZGYm7d+/K63bv3l20bt1aPHv2TF5WUFAgOnXqJN544w15mbJxDzk5OcW2HR4
|
||
|
"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++OILKBQK3LlzRxZT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7OTip0CuPg4IDAwMAC7abMM+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",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"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",
|
||
|
"version": "3.10.9"
|
||
|
},
|
||
|
"orig_nbformat": 4,
|
||
|
"vscode": {
|
||
|
"interpreter": {
|
||
|
"hash": "87f2d5b0071e13b61e3a14b462e646856b285d3e0a05b12e6d8f67f82f2e6023"
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 2
|
||
|
}
|