{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Lernfall 2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Seed setzen"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "np.random.seed(42)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Verteilungen erstellen und visualisieren"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 20452 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Normalverteilung erstellen\n",
    "normal_verteilung = np.random.normal(loc=0, scale=1, size=1000)\n",
    "\n",
    "# Histogramm erstellen\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "plt.hist(normal_verteilung, bins=30, density=True, alpha=0.6, color='g')\n",
    "plt.title('Histogramm der Normalverteilung')\n",
    "plt.xlabel('Wert')\n",
    "plt.ylabel('Häufigkeit')\n",
    "plt.grid(True)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 22924 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Stetige Gleichverteilung erstellen\n",
    "uniform_verteilung = np.random.uniform(low=0, high=1, size=1000)\n",
    "\n",
    "# Histogramm erstellen\n",
    "plt.hist(uniform_verteilung, bins=30, density=True, alpha=0.6, color='b')\n",
    "plt.title('Histogramm der Gleichverteilung')\n",
    "plt.xlabel('Wert')\n",
    "plt.ylabel('Häufigkeit')\n",
    "plt.grid(True)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 22640 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Diskrete Gleichverteilung\n",
    "diskrete_gleichverteilung = np.random.choice([1, 2, 3, 4, 5], size=1000, p=[0.2, 0.2, 0.2, 0.2, 0.2])\n",
    "\n",
    "# Balkendiagramm erstellen\n",
    "plt.hist(diskrete_gleichverteilung, bins=np.arange(1, 7)-0.5, density=True, alpha=0.6, color='r')\n",
    "plt.xticks([1, 2, 3, 4, 5])\n",
    "plt.title('Balkendiagramm der diskreten Gleichverteilung')\n",
    "plt.xlabel('Wert')\n",
    "plt.ylabel('Häufigkeit')\n",
    "plt.grid(True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 25212 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Diskrete Verteilung erstellen mit Wahrscheinlichkeitsvektor\n",
    "diskrete_verteilung = np.random.choice([1, 2, 3, 4, 5], size=1000, p=[0.1, 0.2, 0.3, 0.2, 0.2])\n",
    "\n",
    "# Balkendiagramm erstellen\n",
    "plt.hist(diskrete_verteilung, bins=np.arange(1, 7)-0.5, density=True, alpha=0.6, color='y')\n",
    "plt.xticks([1, 2, 3, 4, 5])\n",
    "plt.title('Balkendiagramm der diskreten Gleichverteilung')\n",
    "plt.xlabel('Wert')\n",
    "plt.ylabel('Häufigkeit')\n",
    "plt.grid(True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Je mehr man die Anzahl an Instanzen erhöht desto mehr nähern sich die IST-Wahrscheinlichkeiten den SOLL-Wahrscheinlichkeiten an"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "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"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
