From 7caf329f2de59c677f2b8e6502feb1323cbb0a4f Mon Sep 17 00:00:00 2001 From: test Date: Sat, 14 May 2022 16:40:40 +0200 Subject: [PATCH] test statistic functions for all 3 tests --- bootstrap-t.ipynb | 98 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 77 insertions(+), 21 deletions(-) diff --git a/bootstrap-t.ipynb b/bootstrap-t.ipynb index c62c3ed..7535ea9 100644 --- a/bootstrap-t.ipynb +++ b/bootstrap-t.ipynb @@ -28,7 +28,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 120, "metadata": { "pycharm": { "name": "#%%\n" @@ -42,12 +42,13 @@ "from scipy.stats import sem\n", "from scipy.stats import t\n", "import matplotlib.pyplot as plt\n", - "from statistics import mean, stdev" + "from statistics import mean, stdev\n", + "from scipy.stats import ttest_ind, ttest_1samp, ttest_rel" ] }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 121, "metadata": { "pycharm": { "name": "#%%\n" @@ -64,7 +65,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 122, "outputs": [], "source": [ "def get_t_stat(data1, data2):\n", @@ -74,7 +75,6 @@ " sem2 = sem(data2)\n", "\n", " sed = sqrt(sem1**2.0 + sem2**2.0)\n", - " # To jest wzór chyba tylko dla jednego przypadku\n", " return (mean1 - mean2) / sed" ], "metadata": { @@ -86,15 +86,13 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 123, "outputs": [], "source": [ "def t_stat_single(sample, population_mean):\n", " \"\"\"Funkcja oblicza wartość statystyki testowej dla jednej próbki\"\"\"\n", - " sample_mean = mean(sample)\n", - " sample_std = stdev(sample)\n", " sample_size = len(sample)\n", - " return (sample_mean - population_mean) / (sample_std / sqrt(sample_size))" + " return (mean(sample) - population_mean) / (stdev(sample) / sqrt(sample_size))" ], "metadata": { "collapsed": false, @@ -105,11 +103,13 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 124, "outputs": [], "source": [ - "def t_stat_indept():\n", - " pass" + "def t_stat_indept(sample_1, sample_2):\n", + " \"\"\"Funkcja oblicza wartość statystyki testowej dla dwóch próbek niezależnych\"\"\"\n", + " # get_t_stat() jest ok już chyba dla równolicznych sampli o tej samej wariancji\n", + " return" ], "metadata": { "collapsed": false, @@ -120,11 +120,15 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 125, "outputs": [], "source": [ - "def t_stat_dep():\n", - " pass" + "def t_stat_dep(sample_1, sample_2):\n", + " \"\"\"Funkcja oblicza wartość statystyki testowej dla dwóch próbek zależnych\"\"\"\n", + " differences = [x_1 - x_2 for x_1, x_2 in zip(sample_1, sample_2)]\n", + " sample_size = len(sample_1)\n", + " mu = 0 # The constant = zero if we want to test whether the average of the difference is significantly different.\n", + " return (mean(differences) - mu) / (stdev(differences) / sqrt(sample_size))" ], "metadata": { "collapsed": false, @@ -135,7 +139,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 126, "metadata": { "pycharm": { "name": "#%%\n" @@ -158,7 +162,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 127, "outputs": [], "source": [ "def make_decision(data, columns, alpha=0.05):\n", @@ -182,12 +186,12 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 128, "outputs": [ { "data": { "text/plain": "
", - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD4CAYAAAAXUaZHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAQxElEQVR4nO3dfYxldX3H8fdHECxaBdyB0t1NZ6NoQk2rOKU01oeCUR6MS1tLoE3dKslGRYsPLS7YiEljsqiVatLSrEJZW4JQpIUWbUWKJU1kdUCeH2RFkF0XdgyKtiYq+u0f96zcDrO7M3Pm4e7P9yu5uef8fufc883Jnc+c+7vnnJuqQpLUlqctdwGSpIVnuEtSgwx3SWqQ4S5JDT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r6zap6LoM/sl/pupbtGJI8nkGwX1pV+//9H9o/3dI97p+uXPA4HjPhXlW3VtXTqmqyqiYZhMtJVfUgg49GeHX3ivQpwHeGnhotO7Pm2n4L2H/XwHbgnCRHJVkPnAB8/nDXd4j+kcGLqiR5BnAkg0/AW0lj2O8lwF1VtXuobSWN4+vAi7rlU4H9U0sr5vciydO6x8cBfwL8Vde1LM9D9yz1YuDOqvrgUNd2Bn9s6R6vHmpf2LkY96vGS/hq9GUMpix+xCDIz5vVfx+P3C0TBv+5yFeAW4Gpcdd/oHEAf9vVeUt30o8b2v5d3TjuprsDYtxf84zhSODvGPxhugk4dTmP4UA/U8DHgdfNsf2yG8c85+L5wI0M7irZCTy323ZZ/l7MM4bzGdxx8mVgC92775fxeXg+gymXW4Cbu68zgKcCOxj8gf0scOyo58KPH5CkBj1mpmUk6bHEcJekBhnuktQgw12SGmS4S1KDDHdJapDhLkkN+l9FDOaKE4lTmQAAAABJRU5ErkJggg==\n" }, "metadata": { "needs_background": "light" @@ -213,13 +217,65 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 129, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "t: 6.940510630195086, df: 998, cv: 1.6463818766348755, p: 7.02371494298859e-12\n", + "Statystyka testowa dla jednej próby:\n", + "1.414213562373095 - z naszej funkcji\n", + "1.414213562373095 - z gotowej biblioteki\n", + "\n", + "Statystyka testowa dla dwóch prób niezależnych:\n", + "-3.0 - z naszej funkcji\n", + "-3.0 - z gotowej biblioteki\n", + "\n", + "Statystyka testowa dla dwóch prób zależnych:\n", + "-1.6329931618554525 - z naszej funkcji\n", + "-1.632993161855452 - z gotowej biblioteki\n" + ] + } + ], + "source": [ + "# Testy\n", + "dummy = [1, 2, 3, 4, 5]\n", + "dummy2 = [4, 5, 6, 7, 8]\n", + "dummy3 = [1, 3 , 3, 4, 6]\n", + "t_stat_selfmade = t_stat_single(dummy, 2)\n", + "t_stat_lib, _ = ttest_1samp(dummy, 2)\n", + "print('Statystyka testowa dla jednej próby:')\n", + "print(t_stat_selfmade, '- z naszej funkcji')\n", + "print(t_stat_lib, '- z gotowej biblioteki')\n", + "print()\n", + "t_stat_selfmade = get_t_stat(dummy, dummy2)\n", + "t_stat_lib, _ = ttest_ind(dummy, dummy2)\n", + "print('Statystyka testowa dla dwóch prób niezależnych:')\n", + "print(t_stat_selfmade, '- z naszej funkcji')\n", + "print(t_stat_lib, '- z gotowej biblioteki')\n", + "print()\n", + "t_stat_selfmade = t_stat_dep(dummy, dummy3)\n", + "t_stat_lib, _ = ttest_rel(dummy, dummy3)\n", + "print('Statystyka testowa dla dwóch prób zależnych:')\n", + "print(t_stat_selfmade, '- z naszej funkcji')\n", + "print(t_stat_lib, '- z gotowej biblioteki')" + ], + "metadata": { + "collapsed": false, + "pycharm": { + "name": "#%%\n" + } + } + }, + { + "cell_type": "code", + "execution_count": 130, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "t: 6.89001510574949, df: 998, cv: 1.6463818766348755, p: 9.867218153658541e-12\n", "\n", "Reject the null hypothesis that the means are equal.\n", "Reject the null hypothesis that the means are equal.\n"