{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Projekt - Test t studenta\n", "\n", "- Marcin Kostrzewski\n", "- Krystian Wasilewski\n", "- Mateusz Tylka\n", "\n", "## Test t studenta\n", "\n", "Metoda statystyczna służącą do porównania dwóch średnich między sobą gdy znamy liczbę badanych próbek, średnią arytmetyczną oraz wartość odchylenia standardowego lub wariancji.\n", "Jest to jeden z mniej skomplikowanych i bardzo często wykorzystywanych testów statystycznych używanych do weryfikacji hipotez. Dzięki niemu możemy dowiedzieć się czy dwie różne średnie są różne niechcący (w wyniku przypadku) czy są różne istotnie statystycznie (np. z uwagi na naszą manipulację eksperymentalna).\n", "Wyróżniamy 3 wersję testu t:\n", "\n", "1. test t Studenta dla jednej próby\n", "2. test t Studenta dla prób niezależnych \n", "3. test t Studenta dla prób zależnych" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Test Shapiro Wilka\n", "\n", "Wszystkie rodzaje testów są testami parametrycznymi, a co za tym idzie nasze mierzone zmienne ilościowe powinny mieć rozkład normalny. \n", "Dzięki testowi Shapiro Wilka możemy sprawdzić to założenie." ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "## Testowanie hipotez metodą bootstrap\n", "\n", "**Bootstrap** – metoda szacowania (estymacji) wyników poprzez wielokrotne losowanie ze zwracaniem z próby. Polega ona na utworzeniu nowego rozkładu wyników, na podstawie posiadanych danych, poprzez wielokrotne losowanie wartości z posiadanej próby. Metoda ze zwracaniem polega na tym, że po wylosowaniu danej wartości, “wraca” ona z powrotem do zbioru.\n", "\n", "Metoda bootstrapowa znajduje zastosowanie w sytuacji, w której nie znamy rozkładu z populacji z której pochodzi próbka lub w przypadku rozkładów małych lub asymetrycznych. W takim wypadku, dzięki tej metodzie, wyniki testów parametrycznych i analiz opartych o modele liniowe są bardziej precyzyjne. Zazwyczaj losuje się wiele próbek, np. 2000 czy 5000." ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "# Definicje funkcji" ] }, { "cell_type": "code", "execution_count": 40, "metadata": { "pycharm": { "name": "#%%\n" } }, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "from enum import Enum\n", "from scipy.stats import ttest_ind, ttest_1samp, ttest_rel, shapiro" ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [], "source": [ "dataset = pd.read_csv('experiment_data.csv') # TODO: del?" ] }, { "cell_type": "code", "execution_count": 42, "metadata": {}, "outputs": [], "source": [ "class Alternatives(Enum):\n", " LESS = 'less'\n", " GREATER = 'greater'" ] }, { "cell_type": "code", "execution_count": 43, "metadata": {}, "outputs": [], "source": [ "def calculate_t_difference(t_stat_sample, t_stat_list, alternative):\n", " \"\"\"\n", " Funkcja oblicza procent statystyk testowych powstałych z prób bootstrapowych, \n", " które róznią się od statystyki testowej powstałej ze zbioru według hipotezy alternatywnej.\n", " \"\"\"\n", " all_stats = len(t_stat_list)\n", " stats_different_count = 0\n", " for t_stat_boot in t_stat_list:\n", " if alternative is Alternatives.LESS and t_stat_boot > t_stat_sample:\n", " stats_different_count += 1 \n", " elif alternative is Alternatives.GREATER and t_stat_boot < t_stat_sample:\n", " stats_different_count += 1\n", " return stats_different_count / all_stats" ] }, { "cell_type": "code", "execution_count": 44, "metadata": { "pycharm": { "name": "#%%\n" } }, "outputs": [], "source": [ "def t_test_1_samp(sample_1, population_mean=None, alternative=Alternatives.LESS):\n", " \"\"\"\n", " Funkcja przeprowadza test T-studenta dla jednej zmiennej.\n", " \"\"\"\n", " t_stat_from_sample, _ = ttest_1samp(a=sample_1, popmean=population_mean, alternative=alternative.value)\n", " t_stat_list = get_t_stats(sample_1, t_stat_fn=ttest_1samp, alternative=alternative, population_mean=population_mean)\n", "\n", " p = calculate_t_difference(t_stat_from_sample, t_stat_list, alternative)\n", "\n", " return p, t_stat_from_sample, t_stat_list" ] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [], "source": [ "def t_test_ind(sample_1, sample_2, alternative=Alternatives.LESS):\n", " \"\"\"\n", " Funkcja przeprowadza test T-studenta dla dwóch zmiennych niezależnych.\n", " \"\"\"\n", " t_stat_from_sample, _ = ttest_ind(sample_1, sample_2, alternative=alternative.value)\n", " t_stat_list = get_t_stats(sample_1, sample_2, alternative=alternative, t_stat_fn=ttest_ind)\n", "\n", " p = calculate_t_difference(t_stat_from_sample, t_stat_list, alternative)\n", "\n", " return p, t_stat_from_sample, t_stat_list" ] }, { "cell_type": "code", "execution_count": 46, "metadata": {}, "outputs": [], "source": [ "def t_test_dep(sample_1, sample_2, alternative=Alternatives.LESS):\n", " \"\"\"\n", " Funkcja przeprowadza test T-studenta dla dwóch zmiennych zależnych.\n", " \"\"\"\n", " t_stat_list = get_t_stats(sample_1, sample_2, alternative=alternative, t_stat_fn=ttest_rel)\n", " t_stat_from_sample, _ = ttest_rel(sample_1, sample_2, alternative=alternative.value)\n", "\n", " p = calculate_t_difference(t_stat_from_sample, t_stat_list, alternative)\n", "\n", " return p, t_stat_from_sample, t_stat_list" ] }, { "cell_type": "code", "execution_count": 47, "metadata": {}, "outputs": [], "source": [ "def get_t_stats(sample_1, sample_2=None, t_stat_fn=ttest_1samp, alternative=Alternatives.LESS, population_mean=None):\n", " \"\"\"Funkcja oblicza listę statystyk testowych dla każdej próbki bootstrapowej wybranej na podstawie danych sample_1 i sample_2\"\"\"\n", " t_stat_list = []\n", "\n", " # One sample test\n", " if t_stat_fn is ttest_1samp and sample_2 is None:\n", " if not population_mean:\n", " raise Exception(\"population_mean not provided\")\n", " for bootstrap in generate_bootstraps(sample_1):\n", " stat, _ = t_stat_fn(bootstrap, population_mean, alternative=alternative.value)\n", " t_stat_list.append(stat)\n", " return t_stat_list\n", "\n", " # Two sample test\n", " for bootstrap_sample in generate_bootstraps(pd.concat((sample_1, sample_2), ignore_index=True)):\n", " bootstrap_1 = bootstrap_sample.iloc[: len(bootstrap_sample) // 2]\n", " bootstrap_2 = bootstrap_sample.iloc[len(bootstrap_sample) // 2 :]\n", " stat, _ = t_stat_fn(bootstrap_1, bootstrap_2, alternative=alternative.value)\n", " t_stat_list.append(stat)\n", " return t_stat_list" ] }, { "cell_type": "code", "execution_count": 48, "metadata": {}, "outputs": [], "source": [ "def pretty_print_test(p, t_stat_from_sample, t_stat_list, thesis, alternative, max_print=5):\n", " print('Wyniki bootstrapowej wersji testu T-studenta')\n", " print()\n", " print(f'Hipoteza: {thesis}')\n", " if alternative is Alternatives.LESS:\n", " print(f'Hipoteza alternatywna: średnia jest mniejsza')\n", " else:\n", " print(f'Hipoteza alternatywna: średnia jest większa')\n", " print()\n", " print(f'p: {p}')\n", " print(f'Wartość statystyki testowej z próby: {t_stat_from_sample}')\n", " print(f'Wartości statystyk z prób boostrapowych:')\n", "\n", " t_stat_list_len = len(t_stat_list)\n", " for i in range(min(max_print, t_stat_list_len)):\n", " print(f'{t_stat_list[i]}, ', end='')\n", " if max_print < t_stat_list_len:\n", " remaining = t_stat_list_len - max_print\n", " print(f'... (i {remaining} pozostałych)')\n", "\n", " print()\n", " print()" ] }, { "cell_type": "code", "execution_count": 49, "metadata": { "pycharm": { "name": "#%%\n" } }, "outputs": [], "source": [ "def generate_bootstraps(data, n_bootstraps=1000):\n", " data_size = data.shape[0]\n", " for _ in range(n_bootstraps):\n", " indices = np.random.choice(len(data), size=data_size)\n", " yield data.iloc[indices, :]" ] }, { "cell_type": "code", "execution_count": 50, "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } }, "outputs": [], "source": [ "def bootstrap_one_sample(sample, population_mean, alternative=Alternatives.LESS):\n", " p, t, ts = t_test_1_samp(\n", " sample_1=sample,\n", " population_mean=population_mean,\n", " alternative=alternative,\n", " )\n", " \n", " pretty_print_test(p, t, ts, f'średnia jest równa {population_mean}', alternative)\n", " print()\n", " return p, t, ts" ] }, { "cell_type": "code", "execution_count": 51, "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } }, "outputs": [], "source": [ "def bootstrap_independent(sample_1, sample_2, alternative=Alternatives.LESS):\n", " p, t, ts = t_test_ind(\n", " sample_1=sample_1,\n", " sample_2=sample_2,\n", " alternative=alternative,\n", " )\n", " \n", " pretty_print_test(p, t, ts, 'średnie są takie same', alternative)\n", " return p, t, ts" ] }, { "cell_type": "code", "execution_count": 52, "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } }, "outputs": [], "source": [ "def bootstrap_dependent(sample_1, sample_2, alternative=Alternatives.LESS):\n", " p, t, ts = t_test_dep(\n", " sample_1=sample_1,\n", " sample_2=sample_2,\n", " alternative=alternative,\n", " )\n", " \n", " pretty_print_test(p, t, ts, 'średnie są takie same', alternative)\n", " return p, t, ts" ] }, { "cell_type": "code", "execution_count": 53, "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } }, "outputs": [], "source": [ "def draw_distribution(stats, comparision_value):\n", " \"\"\"\n", " Funkcja rysuje rozkład statystyki testowej\n", " @param stats: lista statystyk testowych\n", " @param comparision_value: pierwotna próbka\n", " \"\"\"\n", " plt.hist(stats)\n", " plt.axvline(comparision_value, color='red')\n", " plt.xlabel('Test statistic value')\n", " plt.ylabel('Frequency')\n", " plt.show()" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "# Wczytanie danych" ] }, { "cell_type": "code", "execution_count": 54, "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "0 169.5557\ndtype: float64\n0 175.1417\ndtype: float64\n0 79.6342\ndtype: float64\n0 76.5602\ndtype: float64\n" ] } ], "source": [ "dataset = pd.read_csv('experiment_data.csv')\n", "heights_female = pd.DataFrame(dataset['Female height'].to_numpy()) # xd\n", "heights_male = pd.DataFrame(dataset['Male height'].to_numpy())\n", "weights_before = pd.DataFrame(dataset['Weight before'].to_numpy())\n", "weights_after = pd.DataFrame(dataset['Weight after'].to_numpy())\n", "print(np.mean(heights_female))\n", "print(np.mean(heights_male))\n", "print(np.mean(weights_before))\n", "print(np.mean(weights_after))\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "# Jedna próba\n", "\n", "**Test t Studenta dla jednej próby** wykorzystujemy gdy chcemy porównać średnią “teoretyczną” ze średnią, którą faktycznie możemy zaobserwować w naszej bazie danych. Średnia teoretyczna to średnia pochodząca z innych badań lub po prostu bez większych uzasadnień pochodząca z naszej głowy.\n", "\n", "Wyobraźmy sobie, że mamy dane z takimi zmiennymi jak wzrost pewnej grupy ludzi. Dzięki testowi t Studenta dla jednej próby możemy dowiedzieć się np. czy wzrost naszego młodszego brata wynoszący 160cm odbiega znacząco od średniej wzrostu tej grupy.\n", "\n", "### Hipoteza\n", "\n", "*H0: Badana próba została wylosowana z populacji, w której wzrost osób wynosi średnio 160cm.* \n", "*H1: Badana próba została wylosowana z populacji gdzie średni wzrost jest większy 160cm.*\n", "\n", "### Sprawdzenie założeń\n" ] }, { "cell_type": "code", "execution_count": 55, "metadata": {}, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "p = 0.791\n" ] } ], "source": [ "# Sprawdzamy, czy próby mają rozkład normalny\n", "shapiro_test = shapiro(heights_female)\n", "print(f\"p = {round(shapiro_test.pvalue,4)}\")" ] }, { "source": [ "P wartość jest większa niż alfa = 0.05, więc próba ma prawdopodobnie rozkład normalny. Możemy stostować testy." ], "cell_type": "markdown", "metadata": {} }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "## Test\n" ] }, { "cell_type": "code", "execution_count": 56, "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Wyniki bootstrapowej wersji testu T-studenta\n\nHipoteza: średnia jest równa 160.0\nHipoteza alternatywna: średnia jest większa\n\np: 0.5\nWartość statystyki testowej z próby: [19.1207964]\nWartości statystyk z prób boostrapowych:\n[17.41702865], [19.17874674], [20.59090525], [17.666445], [19.3593138], ... (i 95 pozostałych)\n\n\n\n" ] }, { "output_type": "display_data", "data": { "text/plain": "
", "image/svg+xml": "\n\n\n \n \n \n \n 2022-05-18T12:02:51.846030\n image/svg+xml\n \n \n Matplotlib v3.5.2, https://matplotlib.org/\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n", "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAEGCAYAAAB/+QKOAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAAWwElEQVR4nO3debRlZX3m8e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Ix8D3gI1X1UwbXA17SukgNHJbkkiQXAf8CnMHg9MxdSS5Mcjjw18Ch3bYew+APMo12m7veYf8NeHC3zIXAM2fudFXdBXyZQQh8uZt2YbevlzO4nvDtET+zI7pl/pG7T8cBvBVY2V0Y/z6DC/pawuzNVZLU5BGEJKnJgJAkNRkQkqQmA0KS1GRASJKaDAhJUpMBIUlq+v/Aa8GYN/SqPQAAAABJRU5ErkJggg==\n" }, "metadata": { "needs_background": "light" } } ], "source": [ "tested_mean = 160.0\n", "\n", "p, t, ts = bootstrap_one_sample(heights_female, tested_mean, alternative=Alternatives.GREATER)\n", "draw_distribution([x[0] for x in ts], t)" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "## Wniosek\n", "\n", "Nie mamy podstaw, żeby odrzucić hipotezę zerową mówiącą, że średnia wynosi 160." ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "# Dwie próby niezależne\n", "\n", "**Test t Studenta dla prób niezależnych** jest najczęściej stosowaną metodą statystyczną w celu porównania średnich z dwóch niezależnych od siebie grup. Wykorzystujemy go gdy chcemy porównać dwie grupy pod względem jakiejś zmiennej ilościowej. Na przykład gdy chcemy porównać średni wzrost kobiet i mężczyzn w danej grupie.\n", "Zazwyczaj dwie średnie z różnych od siebie grup będą się różnić. Test t Studenta powie nam jednak czy owe różnice są istotne statystycznie – czy nie są przypadkowe.\n", "Jeśli wynik testu t Studenta będzie istotny na poziomie p < 0,05 możemy odrzucić hipotezę zerową na rzecz hipotezy alternatywnej.\n", "\n", "## Hipoteza\n", "\n", "*H0: Średni wzrost w grupie mężczyzn jest taki sam jak średni w grupie kobiet. Hipoteza alternatywna z kolei* \n", "*H1: Kobiety będą niższe od mężczyzn pod względem wzrostu.*\n", "\n", "## Sprawdzenie założeń\n", "\n", "Założenie o rozkładzie normalnym danych - sprawdzane testem Shapiro-Wilka" ] }, { "cell_type": "code", "execution_count": 57, "metadata": {}, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "p = 0.791\np = 0.7535\n" ] } ], "source": [ "shapiro_test = shapiro(heights_female)\n", "print(f\"p = {round(shapiro_test.pvalue,4)}\")\n", "\n", "shapiro_test = shapiro(heights_male)\n", "print(f\"p = {round(shapiro_test.pvalue,4)}\")" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "Wartości **p** w teście Shapiro-Wilka powyżej **0.05** -> Dane prawdopodobnie mają rozkład normalny" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "## Test" ] }, { "cell_type": "code", "execution_count": 58, "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Wyniki bootstrapowej wersji testu T-studenta\n\nHipoteza: średnie są takie same\nHipoteza alternatywna: średnia jest mniejsza\n\np: 0.0\nWartość statystyki testowej z próby: [8.04931557]\nWartości statystyk z prób boostrapowych:\n[0.2748409], [-0.61193473], [1.24335163], [-2.56879464], [0.34249038], ... (i 95 pozostałych)\n\n\n" ] }, { "output_type": "display_data", "data": { "text/plain": "
", "image/svg+xml": "\n\n\n \n \n \n \n 2022-05-18T12:02:55.815731\n image/svg+xml\n \n \n Matplotlib v3.5.2, https://matplotlib.org/\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n", "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAEGCAYAAAB/+QKOAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAAXRklEQVR4nO3de7RedX3n8feHgBdABeQMIhBDHQaLKEiPqMVLFERuiraOwowOWmvEwVEcOzVql1rbmYWr46VKK6aAeEF0vGBRUIlWvLUqIXJHCkNREhCiUC7qSIPf+ePZkcfj7yRPkueSk/N+rbXX2Zff3vv7JHA+2Zfn90tVIUnSTNtMugBJ0pbJgJAkNRkQkqQmA0KS1GRASJKatp10AcO066671qJFiyZdhiSNz7XX9n7uu+8m7X7JJZf8pKqmWtu2qoBYtGgRK1asmHQZkjQ+ixf3fl500SbtnuSHs23zFpMkqcmAkCQ1GRCSpCYDQpLUZEBIkpoMCElSkwEhSWoyICRJTQaEJKlpq/om9XyzaOn5m7zvjaccPcRKJG2NvIKQJDUZEJKkJgNCktRkQEiSmgwISVLTyAIiyV5Jvpbk6iRXJXldt36XJMuTXNf93HmW/U/o2lyX5IRR1SlJahvlFcRa4A1VtR/wZOCkJPsBS4GvVtU+wFe75d+QZ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3unQi8vrvieNqM4zyj72rk+0keApwCPK1b9/ruX/7fTLKym9aFzcx2i9eNsTDgcfvb75jkQ0mu6Gr/wxl1HpHkU33L/ft+IMmKbpyAP5/lz+uevvkXJjmrm59K8pkkF3fTIZv6d6KtRFU5Oc3JCXg78D+AfwSmunUvpvetbuh1f/zAbn6nvn3+ZJbjfR44pJvfkV5PA4uBL/S12R54UDe/D7Cim5/Z7tfLAx63v/07gff2bdt5Rp3b0utqYYdu+QPAS7r5XbqfC4CLgMd3yxfRGzsA4J6+Y70QOKub/zjw1G5+Ib1uRib+9+w0ucmuNjTXPRDYn/u7MVlAr/tjgMvpdbXwOeBzAxzr28C7k5wNfLaqVnXH7LcdcGqSA4H7gP8wpOP2O4y+wV+q6o7+jdXr5uRLwHO77haOptfXF8CLkiyhFyK70xvM6fIBalx33v36antokh2r6p717KOtmAGhuS7AVVXVGk7yaHqDxjwXeEuSx63vQFV1SpLzgaOAbyd5TqPZ64Fb6Y1Qtg3w/zZU4IDH3VifAF4D3E7vKubuJHsDfwI8saru6G4dtYah7O9fp3/7NsCTq2qDn0nzg88gNNf9EphKN95wku2SPDbJNsBeVfU14I3Aw+jd3rkbeEjrQEkeXVVXVNU76fVW+5hG+4cBt1TVr+h15regW7+5x+23HDipb/+dG22+Tm+8g1fSCwuAh9Ib9+DOJLvRGw625dYkv9v9Gb2gb/2F9Dq4W3feA2fZX/OEAaG57lf07qO/M8llwKX03lJaAHwsyRX0erp8X/WGnPw88ILWQ2rg5PQGeboc+Dd6I/9dDtyX5LIkrwf+FjihO9dj6P1CptFuY4/b7y+Bnbt9LgOeOfNDV9V9wBfohcAXunWXdZ/1B/SeJ3x7lj+zpd0+/8j9t+OgG+O4ezB+Nb0H+prH7M1VktTkFYQkqcmAkCQ1GRCSpCYDQpLUZEBIkpoMCElSkwEhSWr6/15Iu2fHJRYeAAAAAElFTkSuQmCC\n" }, "metadata": { "needs_background": "light" } } ], "source": [ "p, t, ts = bootstrap_independent(heights_male, heights_female)\n", "ts = [x[0] for x in ts]\n", "draw_distribution(ts, t)" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "## Wniosek" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "# Dwie próby zależne\n", "\n", "W odróżnieniu od testu dla prób niezależnych, gdzie porównujemy dwie grupy, ten rodzaj testu stosujemy gdy poddajemy analizie tą samą pojedynczą grupę, ale dwukrotnie w czasie.\n", "\n", "**Przykład**: Porównane zostały wagi przed dietą i po diecie.\n" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "### Hipoteza\n", "H0 - Średnia waga nie uległa zmianie po zastosowaniu diety\n", "H1 - Średnia waga po diecie jest znacząco mniejsza od wagi przed dietą\n" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "\n", "### Sprawdzenie założeń\n", "\n", "Założenie o rozkładzie normalnym danych - sprawdzane testem Shapiro-Wilka" ] }, { "cell_type": "code", "execution_count": 59, "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "p = 0.3308\np = 0.4569\n" ] } ], "source": [ "shapiro_test = shapiro(weights_before)\n", "print(f\"p = {round(shapiro_test.pvalue,4)}\")\n", "\n", "shapiro_test = shapiro(weights_after)\n", "print(f\"p = {round(shapiro_test.pvalue,4)}\")" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "Wartości **p** w teście Shapiro-Wilka powyżej **0.05** -> Dane prawdopodobnie mają rozkład normalny" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "## Test" ] }, { "cell_type": "code", "execution_count": 39, "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Wyniki bootstrapowej wersji testu T-studenta\n\nHipoteza: średnie są takie same\nHipoteza alternatywna: średnia jest mniejsza\n\np: 0.0\nWartość statystyki testowej z próby: [48.30834167]\nWartości statystyk z prób boostrapowych:\n[-0.18332849], [-1.21537352], [1.64628473], [1.06552535], [-0.71420173], ... (i 95 pozostałych)\n\n\n" ] }, { "output_type": "display_data", "data": { "text/plain": "
", "image/svg+xml": "\n\n\n \n \n \n \n 2022-05-18T12:02:30.324226\n image/svg+xml\n \n \n Matplotlib v3.5.2, https://matplotlib.org/\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n", "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYkAAAEGCAYAAACQO2mwAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90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lwH3A707Tdru9gM74QgBU1R3dC6tqc5KvAy9J8gU670h4R7P4FekMCT0f2IvOi7Gu7qPGLd97QFdtj0mySz3w3gnNQYaEdnQBrq2q5/RYdgzwPOAlwJ8nefrWNlRVpyW5EDga+G6SF/Xo9lY6Y1kdROd07f/bVoF9bneqPgO8ic6LoSaq6u4k+wJvB55ZVXc0p5Ee2aukrunu5Q8Dnl1V29wnzR1ek9CO7jfAWJLnQGe47yRPTfIwYJ+quhR4J/BYOqd67gZ27bWhJE+uqmuq6gN0Rvt9So/+jwVurarfAq+hc+TCNGy32yrg5K71e72D+FvAwcDr6AQGwGOAXwJ3JllA5xW7vdyW5PeaP6OXd7VfDPzXru9d0rK+5hBDQju639I5r/6BJFcBa+jcvTQP+Ick19AZ3fOj1XlvwleAl/e6cA2ckmRtkquBfwO+RudUzX1JrkryVuBvgJOa73oKnb+U6dFvqtvt9j+B3Zt1rgIOn7zT1Xlh0FfpBMFXm7armn39EZ3rC99t+TNb3qzzTzxwag7gzcB4c7H8OjoX+TXHOQqsJKmVRxKSpFaGhCSplSEhSWplSEiSWhkSkqRWhoQkqZUhIUlq9f8BW9ItBG2V78MAAAAASUVORK5CYII=\n" }, "metadata": { "needs_background": "light" } } ], "source": [ "p, t, ts = bootstrap_dependent(weights_before, weights_after)\n", "ts = [x[0] for x in ts]\n", "draw_distribution(ts, t)" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "## Wniosek\n", "\n", "???" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": { "pycharm": { "name": "#%%\n" } }, "outputs": [], "source": [] } ], "metadata": { "interpreter": { "hash": "1b132c2ed43285dcf39f6d01712959169a14a721cf314fe69015adab49bb1fd1" }, "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.8.10-final" } }, "nbformat": 4, "nbformat_minor": 2 }