diff --git a/stochastik-programmieren.ipynb b/stochastik-programmieren.ipynb index 27503571882ade0b8bf52c068b34938273aa196f..7dc2b256f55559521e8f1369dd9d65f7d32bc659 100644 --- a/stochastik-programmieren.ipynb +++ b/stochastik-programmieren.ipynb @@ -54,7 +54,7 @@ "output_type": "stream", "text": [ "Gerade Würfelaugen: {2, 4, 6}\n", - "Wahrscheinlichkeit für gerade Augenzahl: 1/2\n" + "Wahrscheinlichkeit für gerade Augenzahl: 1\n" ] } ], @@ -93,7 +93,7 @@ "random() method of random.Random instance\n", " random() -> x in the interval [0, 1).\n", "\n", - "0.5311158584902383\n", + "0.19357801680866282\n", "0.13436424411240122\n" ] } @@ -124,7 +124,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 4, "id": "62096c2f-6911-4c7a-b243-b8661e83ddb3", "metadata": {}, "outputs": [ @@ -132,7 +132,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "[1, 1, 4, 2, 2, 5, 3, 2, 3, 1, 3, 3, 2, 1, 6, 4, 2, 4, 5, 1, 1, 1, 5, 1, 5, 5, 4, 2, 6, 5, 4, 2, 4, 3, 4, 2, 4, 1, 2, 6, 6, 2, 6, 2, 6, 5, 3, 2, 1, 6, 1, 5, 6, 4, 2, 6, 6, 5, 4, 3, 3, 2, 5, 3, 2, 1, 4, 2, 3, 2, 6, 6, 1, 2, 2, 6, 5, 3, 2, 5, 6, 6, 3, 6, 5, 3, 6, 2, 5, 1, 2, 6, 2, 5, 4, 6, 3, 3, 2, 6]\n" + "[6, 5, 2, 3, 3, 4, 5, 1, 1, 6, 3, 5, 1, 3, 5, 2, 6, 6, 1, 1, 4, 6, 3, 2, 3, 1, 2, 3, 3, 2, 2, 2, 3, 2, 1, 6, 4, 4, 2, 6, 6, 1, 2, 5, 5, 6, 3, 5, 5, 2, 4, 6, 6, 4, 4, 1, 2, 5, 3, 2, 4, 5, 5, 3, 3, 4, 5, 4, 3, 3, 1, 1, 5, 6, 4, 3, 2, 4, 6, 5, 4, 6, 2, 4, 6, 4, 3, 2, 4, 6, 1, 5, 5, 6, 5, 5, 4, 4, 3, 1]\n" ] } ], @@ -149,101 +149,6 @@ "print(würfe)" ] }, - { - "cell_type": "code", - "execution_count": 17, - "id": "4e0195f2-cb57-4256-bc2a-18eb44c2f83b", - "metadata": { - "jupyter": { - "source_hidden": true - } - }, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "2e4e538749bd4a5ebcc6ec634762fd23", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "IntSlider(value=10)" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "90473d7109de424cb9f8daf466690c9c", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "Button(description='Würfel werfen', icon='dice', style=ButtonStyle(), tooltip='Anklicken um Würfelwürfe zu sim…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "8152dfae48c3489686a6bd7fc0cb4eea", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "Button(description='Seed reset auf 1', icon='dice-one', style=ButtonStyle(), tooltip='Anklicken um Random Seed…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "3d388dc7c06b41888b852c0e707cd1d7", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "Label(value='')" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "# Interaktiv: Benutzen Sie den Schieberegler und die Buttons!\n", - "# Der folgende Code ist nur zur interaktiven Interaktion da,\n", - "# wir lernen und üben in dieser Vorlesung nicht, wie man interaktive Elemente in Notebooks gestaltet.\n", - "import ipywidgets as widgets\n", - "from IPython.display import display\n", - "slider = widgets.IntSlider(value=10, max=100)\n", - "text = widgets.Label(value='')\n", - "wurfbutton = widgets.Button(\n", - " description='Würfel werfen',\n", - " tooltip='Anklicken um Würfelwürfe zu simulieren',\n", - " icon='dice'\n", - ")\n", - "seedbutton = widgets.Button(\n", - " description='Seed reset auf 1',\n", - " tooltip='Anklicken um Random Seed wieder auf 1 zu setzen',\n", - " icon='dice-one'\n", - ")\n", - "def roll_dice(_):\n", - " text.value = \" \".join([str(transform_unit_to_dice(r())) for _ in range(slider.value)])\n", - "wurfbutton.on_click(roll_dice)\n", - "def seed_reset(_):\n", - " random.seed(1)\n", - "seedbutton.on_click(seed_reset)\n", - "seed_reset(None)\n", - "display(slider, wurfbutton, seedbutton, text)" - ] - }, { "cell_type": "markdown", "id": "beac5e48-9b2d-410b-9ddd-a9898347d71b",