From 8c8eed67bcf907e74e9a86cd401a8c726f7f6a04 Mon Sep 17 00:00:00 2001 From: Jacob Fritsche Date: Wed, 26 Feb 2025 15:10:53 +0100 Subject: [PATCH] Tutorium 3 --- Tutorium_3.ipynb | 119 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 Tutorium_3.ipynb diff --git a/Tutorium_3.ipynb b/Tutorium_3.ipynb new file mode 100644 index 0000000..878769e --- /dev/null +++ b/Tutorium_3.ipynb @@ -0,0 +1,119 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "a8babbab-fd24-4375-b7fa-797d007b61c4", + "metadata": {}, + "outputs": [], + "source": [ + "pip install --upgrade pip" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4f47b87d-9127-4127-8230-9246a13f6699", + "metadata": {}, + "outputs": [], + "source": [ + "pip install scipy\n", + "pip install pandas" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "9e9759cd-705a-4a0f-83c7-ae08c84fb333", + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd\n", + "from scipy import stats" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "1edc82b4-4409-4250-9827-c9a217d788b4", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " Person Vorher Nachher\n", + "0 1 12 14\n", + "1 2 15 16\n", + "2 3 13 15\n", + "3 4 14 15\n", + "4 5 11 13\n", + "5 6 16 17\n", + "6 7 17 18\n", + "7 8 10 11\n", + "8 9 13 14\n", + "9 10 14 16\n" + ] + } + ], + "source": [ + "# Daten in ein Dictionary umwandeln\n", + "data = {\n", + " \"Person\": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],\n", + " \"Vorher\": [12, 15, 13, 14, 11, 16, 17, 10, 13, 14],\n", + " \"Nachher\": [14, 16, 15, 15, 13, 17, 18, 11, 14, 16]\n", + "}\n", + "\n", + "# Erstellen des DataFrames\n", + "df = pd.DataFrame(data)\n", + "\n", + "# Ausgabe des DataFrames\n", + "print(df)" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "6ca1af33-a8dd-4c83-a8cd-41671f010a2f", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "T-Statistik: -8.573214099741122\n", + "P-Wert: 6.3409243600676025e-06\n" + ] + } + ], + "source": [ + "t_statistic, p_value = stats.ttest_rel(df['Vorher'], df['Nachher'], alternative='less')\n", + "\n", + "# Ausgabe der Ergebnisse\n", + "print(f\"T-Statistik: {t_statistic}\")\n", + "print(f\"P-Wert: {p_value}\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.12" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}