Bootstrap-t-student/bootstrap-t.ipynb

765 lines
116 KiB
Plaintext
Raw Normal View History

2022-05-11 15:02:15 +02:00
{
"cells": [
2022-05-13 22:06:56 +02:00
{
"cell_type": "markdown",
2022-05-17 17:27:59 +02:00
"metadata": {},
2022-05-13 22:06:56 +02:00
"source": [
2022-05-17 17:27:59 +02:00
"# 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",
2022-05-18 11:20:39 +02:00
"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",
2022-05-17 17:27:59 +02:00
"\n",
2022-05-18 11:20:39 +02:00
"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."
2022-05-16 23:34:31 +02:00
]
2022-05-13 22:06:56 +02:00
},
2022-05-18 06:51:04 +02:00
{
"cell_type": "markdown",
2022-05-18 11:20:39 +02:00
"metadata": {
"collapsed": false
},
2022-05-18 06:51:04 +02:00
"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."
2022-05-18 11:20:39 +02:00
]
2022-05-18 06:51:04 +02:00
},
2022-05-18 01:08:58 +02:00
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
2022-05-18 11:20:39 +02:00
},
"source": [
"# Definicje funkcji"
]
2022-05-18 01:08:58 +02:00
},
2022-05-13 22:06:56 +02:00
{
2022-05-17 17:27:59 +02:00
"cell_type": "code",
2022-05-18 12:03:27 +02:00
"execution_count": 40,
2022-05-16 23:34:31 +02:00
"metadata": {
2022-05-17 17:27:59 +02:00
"pycharm": {
"name": "#%%\n"
}
2022-05-16 23:34:31 +02:00
},
2022-05-17 17:27:59 +02:00
"outputs": [],
2022-05-13 22:06:56 +02:00
"source": [
2022-05-17 17:27:59 +02:00
"import numpy as np\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
2022-05-17 21:38:59 +02:00
"from enum import Enum\n",
2022-05-17 21:49:11 +02:00
"from scipy.stats import ttest_ind, ttest_1samp, ttest_rel, shapiro"
2022-05-16 23:34:31 +02:00
]
2022-05-13 22:06:56 +02:00
},
2022-05-11 15:02:15 +02:00
{
"cell_type": "code",
2022-05-18 12:03:27 +02:00
"execution_count": 41,
2022-05-17 17:27:59 +02:00
"metadata": {},
2022-05-17 13:58:25 +02:00
"outputs": [],
"source": [
2022-05-18 01:08:58 +02:00
"dataset = pd.read_csv('experiment_data.csv') # TODO: del?"
2022-05-17 17:27:59 +02:00
]
},
{
"cell_type": "code",
2022-05-18 12:03:27 +02:00
"execution_count": 42,
2022-05-17 17:27:59 +02:00
"metadata": {},
"outputs": [],
"source": [
2022-05-17 19:40:13 +02:00
"class Alternatives(Enum):\n",
" LESS = 'less'\n",
" GREATER = 'greater'"
2022-05-17 17:27:59 +02:00
]
2022-05-17 13:58:25 +02:00
},
{
"cell_type": "code",
2022-05-18 12:03:27 +02:00
"execution_count": 43,
2022-05-17 17:27:59 +02:00
"metadata": {},
"outputs": [],
"source": [
2022-05-17 19:40:13 +02:00
"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",
2022-05-18 11:20:39 +02:00
" if alternative is Alternatives.LESS and t_stat_boot > t_stat_sample:\n",
2022-05-17 19:40:13 +02:00
" stats_different_count += 1 \n",
2022-05-18 11:20:39 +02:00
" elif alternative is Alternatives.GREATER and t_stat_boot < t_stat_sample:\n",
2022-05-17 19:40:13 +02:00
" stats_different_count += 1\n",
" return stats_different_count / all_stats"
2022-05-17 17:27:59 +02:00
]
},
{
"cell_type": "code",
2022-05-18 12:03:27 +02:00
"execution_count": 44,
2022-05-11 15:02:15 +02:00
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
2022-05-17 19:40:13 +02:00
"def t_test_1_samp(sample_1, population_mean=None, alternative=Alternatives.LESS):\n",
2022-05-17 17:27:59 +02:00
" \"\"\"\n",
2022-05-17 19:40:13 +02:00
" Funkcja przeprowadza test T-studenta dla jednej zmiennej.\n",
2022-05-17 17:27:59 +02:00
" \"\"\"\n",
2022-05-17 19:40:13 +02:00
" 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",
2022-05-17 17:27:59 +02:00
"\n",
2022-05-17 20:56:02 +02:00
" return p, t_stat_from_sample, t_stat_list"
2022-05-17 19:40:13 +02:00
]
},
{
"cell_type": "code",
2022-05-18 12:03:27 +02:00
"execution_count": 45,
2022-05-17 19:40:13 +02:00
"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",
2022-05-17 17:27:59 +02:00
"\n",
2022-05-17 19:40:13 +02:00
" p = calculate_t_difference(t_stat_from_sample, t_stat_list, alternative)\n",
2022-05-17 17:27:59 +02:00
"\n",
2022-05-17 20:56:02 +02:00
" return p, t_stat_from_sample, t_stat_list"
2022-05-17 17:27:59 +02:00
]
},
{
"cell_type": "code",
2022-05-18 12:03:27 +02:00
"execution_count": 46,
2022-05-17 17:27:59 +02:00
"metadata": {},
"outputs": [],
"source": [
2022-05-17 19:40:13 +02:00
"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",
2022-05-17 20:56:02 +02:00
" return p, t_stat_from_sample, t_stat_list"
2022-05-17 19:40:13 +02:00
]
},
{
"cell_type": "code",
2022-05-18 12:03:27 +02:00
"execution_count": 47,
2022-05-17 19:40:13 +02:00
"metadata": {},
"outputs": [],
"source": [
"def get_t_stats(sample_1, sample_2=None, t_stat_fn=ttest_1samp, alternative=Alternatives.LESS, population_mean=None):\n",
2022-05-17 17:27:59 +02:00
" \"\"\"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",
2022-05-17 19:40:13 +02:00
" if t_stat_fn is ttest_1samp and sample_2 is None:\n",
2022-05-17 17:27:59 +02:00
" if not population_mean:\n",
" raise Exception(\"population_mean not provided\")\n",
" for bootstrap in generate_bootstraps(sample_1):\n",
2022-05-17 19:40:13 +02:00
" stat, _ = t_stat_fn(bootstrap, population_mean, alternative=alternative.value)\n",
2022-05-17 17:27:59 +02:00
" t_stat_list.append(stat)\n",
" return t_stat_list\n",
"\n",
" # Two sample test\n",
2022-05-17 21:38:59 +02:00
" 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",
2022-05-17 19:40:13 +02:00
" stat, _ = t_stat_fn(bootstrap_1, bootstrap_2, alternative=alternative.value)\n",
2022-05-17 17:27:59 +02:00
" t_stat_list.append(stat)\n",
" return t_stat_list"
]
},
2022-05-17 21:08:54 +02:00
{
"cell_type": "code",
2022-05-18 12:03:27 +02:00
"execution_count": 48,
2022-05-17 21:08:54 +02:00
"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()"
]
},
2022-05-11 15:02:15 +02:00
{
"cell_type": "code",
2022-05-18 12:03:27 +02:00
"execution_count": 49,
2022-05-11 15:02:15 +02:00
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
2022-05-18 12:03:27 +02:00
"def generate_bootstraps(data, n_bootstraps=1000):\n",
2022-05-11 15:02:15 +02:00
" data_size = data.shape[0]\n",
2022-05-13 22:06:56 +02:00
" for _ in range(n_bootstraps):\n",
" indices = np.random.choice(len(data), size=data_size)\n",
" yield data.iloc[indices, :]"
2022-05-11 15:02:15 +02:00
]
},
{
"cell_type": "code",
2022-05-18 12:03:27 +02:00
"execution_count": 50,
2022-05-16 23:34:31 +02:00
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
},
2022-05-14 15:31:47 +02:00
"outputs": [],
"source": [
2022-05-17 19:40:13 +02:00
"def bootstrap_one_sample(sample, population_mean, alternative=Alternatives.LESS):\n",
2022-05-17 21:08:54 +02:00
" p, t, ts = t_test_1_samp(\n",
2022-05-17 19:40:13 +02:00
" sample_1=sample,\n",
" population_mean=population_mean,\n",
" alternative=alternative,\n",
2022-05-17 21:08:54 +02:00
" )\n",
" \n",
" pretty_print_test(p, t, ts, f'średnia jest równa {population_mean}', alternative)\n",
" print()\n",
" return p, t, ts"
2022-05-16 23:34:31 +02:00
]
},
2022-05-17 17:27:59 +02:00
{
"cell_type": "code",
2022-05-18 12:03:27 +02:00
"execution_count": 51,
2022-05-17 17:27:59 +02:00
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
},
2022-05-16 23:34:31 +02:00
"outputs": [],
"source": [
2022-05-17 19:40:13 +02:00
"def bootstrap_independent(sample_1, sample_2, alternative=Alternatives.LESS):\n",
2022-05-17 21:08:54 +02:00
" p, t, ts = t_test_ind(\n",
2022-05-17 17:27:59 +02:00
" sample_1=sample_1,\n",
" sample_2=sample_2,\n",
2022-05-17 19:40:13 +02:00
" alternative=alternative,\n",
2022-05-17 21:08:54 +02:00
" )\n",
" \n",
" pretty_print_test(p, t, ts, 'średnie są takie same', alternative)\n",
" return p, t, ts"
2022-05-16 23:34:31 +02:00
]
},
{
"cell_type": "code",
2022-05-18 12:03:27 +02:00
"execution_count": 52,
2022-05-14 17:09:29 +02:00
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
2022-05-16 23:34:31 +02:00
},
"outputs": [],
"source": [
2022-05-17 19:40:13 +02:00
"def bootstrap_dependent(sample_1, sample_2, alternative=Alternatives.LESS):\n",
2022-05-17 21:08:54 +02:00
" p, t, ts = t_test_dep(\n",
2022-05-16 23:34:31 +02:00
" sample_1=sample_1,\n",
" sample_2=sample_2,\n",
2022-05-17 19:40:13 +02:00
" alternative=alternative,\n",
2022-05-17 21:08:54 +02:00
" )\n",
" \n",
" pretty_print_test(p, t, ts, 'średnie są takie same', alternative)\n",
" return p, t, ts"
2022-05-16 23:34:31 +02:00
]
},
{
"cell_type": "code",
2022-05-18 12:03:27 +02:00
"execution_count": 53,
2022-05-11 15:02:15 +02:00
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
2022-05-16 23:34:31 +02:00
},
2022-05-16 18:52:49 +02:00
"outputs": [],
2022-05-13 22:06:56 +02:00
"source": [
2022-05-18 01:08:58 +02:00
"def draw_distribution(stats, comparision_value):\n",
2022-05-16 18:52:49 +02:00
" \"\"\"\n",
" Funkcja rysuje rozkład statystyki testowej\n",
2022-05-17 16:21:32 +02:00
" @param stats: lista statystyk testowych\n",
2022-05-18 01:08:58 +02:00
" @param comparision_value: pierwotna próbka\n",
2022-05-16 18:52:49 +02:00
" \"\"\"\n",
" plt.hist(stats)\n",
2022-05-18 01:08:58 +02:00
" plt.axvline(comparision_value, color='red')\n",
2022-05-16 18:52:49 +02:00
" plt.xlabel('Test statistic value')\n",
" plt.ylabel('Frequency')\n",
" plt.show()"
2022-05-16 23:34:31 +02:00
]
},
2022-05-17 17:27:59 +02:00
{
"cell_type": "markdown",
2022-05-18 01:08:58 +02:00
"metadata": {
"collapsed": false
2022-05-18 11:20:39 +02:00
},
"source": [
"# Wczytanie danych"
]
2022-05-17 17:27:59 +02:00
},
2022-05-16 23:34:31 +02:00
{
"cell_type": "code",
2022-05-18 12:03:27 +02:00
"execution_count": 54,
2022-05-18 01:08:58 +02:00
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
2022-05-17 21:38:59 +02:00
}
2022-05-18 11:20:39 +02:00
},
"outputs": [
{
"output_type": "stream",
2022-05-18 12:03:27 +02:00
"name": "stdout",
2022-05-18 11:20:39 +02:00
"text": [
2022-05-18 12:03:27 +02:00
"0 169.5557\ndtype: float64\n0 175.1417\ndtype: float64\n0 79.6342\ndtype: float64\n0 76.5602\ndtype: float64\n"
2022-05-18 11:20:39 +02:00
]
}
],
"source": [
2022-05-18 12:03:27 +02:00
"dataset = pd.read_csv('experiment_data.csv')\n",
2022-05-18 11:20:39 +02:00
"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"
]
2022-05-18 01:08:58 +02:00
},
2022-05-18 12:03:27 +02:00
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
2022-05-18 01:08:58 +02:00
{
"cell_type": "markdown",
2022-05-18 11:20:39 +02:00
"metadata": {
"collapsed": false
},
2022-05-18 01:08:58 +02:00
"source": [
"# Jedna próba\n",
"\n",
2022-05-18 11:20:39 +02:00
"**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",
2022-05-18 12:03:27 +02:00
"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",
2022-05-18 11:20:39 +02:00
"\n",
2022-05-18 01:08:58 +02:00
"### Hipoteza\n",
"\n",
2022-05-18 12:03:27 +02:00
"*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",
2022-05-18 11:20:39 +02:00
"\n",
2022-05-18 06:37:27 +02:00
"### Sprawdzenie założeń\n"
2022-05-18 11:20:39 +02:00
]
2022-05-18 06:37:27 +02:00
},
2022-05-18 12:03:27 +02:00
{
"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": {}
},
2022-05-18 06:37:27 +02:00
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
2022-05-18 11:20:39 +02:00
},
"source": [
"## Test\n"
]
2022-05-18 06:37:27 +02:00
},
{
"cell_type": "code",
2022-05-18 12:03:27 +02:00
"execution_count": 56,
2022-05-18 06:37:27 +02:00
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
2022-05-18 11:20:39 +02:00
},
2022-05-18 12:03:27 +02:00
"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": "<Figure size 432x288 with 1 Axes>",
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"392.14375pt\" height=\"262.19625pt\" viewBox=\"0 0 392.14375 262.19625\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n <metadata>\n <rdf:RDF xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n <cc:Work>\n <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n <dc:date>2022-05-18T12:02:51.846030</dc:date>\n <dc:format>image/svg+xml</dc:format>\n <dc:creator>\n <cc:Agent>\n <dc:title>Matplotlib v3.5.2, https://matplotlib.org/</dc:title>\n </cc:Agent>\n </dc:creator>\n </cc:Work>\n </rdf:RDF>\n </metadata>\n <defs>\n <style type=\"text/css\">*{stroke-linejoin: round; stroke-linecap: butt}</style>\n </defs>\n <g id=\"figure_1\">\n <g id=\"patch_1\">\n <path d=\"M 0 262.19625 \nL 392.14375 262.19625 \nL 392.14375 0 \nL 0 0 \nL 0 262.19625 \nz\n\" style=\"fill: none\"/>\n </g>\n <g id=\"axes_1\">\n <g id=\"patch_2\">\n <path d=\"M 50.14375 224.64 \nL 384.94375 224.64 \nL 384.94375 7.2 \nL 50.14375 7.2 \nz\n\" style=\"fill: #ffffff\"/>\n </g>\n <g id=\"patch_3\">\n <path d=\"M 65.361932 224.64 \nL 95.798295 224.64 \nL 95.798295 159.244511 \nL 65.361932 159.244511 \nz\n\" clip-path=\"url(#p1d4603d369)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"patch_4\">\n <path d=\"M 95.798295 224.64 \nL 126.234659 224.64 \nL 126.234659 104.748271 \nL 95.798295 104.748271 \nz\n\" clip-path=\"url(#p1d4603d369)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"patch_5\">\n <path d=\"M 126.234659 224.64 \nL 156.671023 224.64 \nL 156.671023 82.949774 \nL 126.234659 82.949774 \nz\n\" clip-path=\"url(#p1d4603d369)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"patch_6\">\n <path d=\"M 156.671023 224.64 \nL 187.107386 224.64 \nL 187.107386 17.554286 \nL 156.671023 17.554286 \nz\n\" clip-path=\"url(#p1d4603d369)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"patch_7\">\n <path d=\"M 187.107386 224.64 \nL 217.54375 224.64 \nL 217.54375 50.25203 \nL 187.107386 50.25203 \nz\n\" clip-path=\"url(#p1d4603d369)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"patch_8\">\n <path d=\"M 217.54375 224.64 \nL 247.980114 224.64 \nL 247.980114 115.647519 \nL 217.54375 115.647519 \nz\n\" clip-path=\"url(#p1d4603d369)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"patch_9\">\n <path d=\"M 247.980114 224.64 \nL 278.416477 224.64 \nL 278.416477 61.151278 \nL 247.980114 61.151278 \nz\n\" clip-path=\"url(#p1d4603d369)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"patch_10\">\n <path d=\"M 278.416477 224.64 \nL 308.852841 224.64 \nL 308.852841 191.942256 \nL 278.416477 191.942256 \nz\n\" clip-path=\"url(#p1d4603d369)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"patch_11\">\n <path d=\"M 308.852841 224.64 \nL 339.289205 224.64 \nL 339.289205 191.942256 \nL 308.852841 191.942256 \nz\n\" clip-path=\"url(#p1d4603d369)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"patch_12\">\n <path d=\"M 339.289205 224.64 \nL 369.725568 224.64 \nL 369.725568 181.043008 \nL 339.289205 181.043008 \nz\n\" clip-path=\"url(#p1d4603d369)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"matplotlib.axis_1\">\n <g id=\"xtick_1\">\n <g id=\"line2d_1\">\n <defs>\n <path id=\"ma6477f8760\" d=\"M 0 0 \nL 0 3.5 \n\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n </defs>\n <g>\n <use xlink:href=\"#ma6477f8760\" x=\"75.382988\" y=\"224.64\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n </g>\n </g>\n <g id=\"text_1\">\n <!-- 17 -->\n <g transform=\"translate(69.020488 239.238437)scale(0.1 -0.1)\">\n <defs>\n <path id=\"DejaVuSans-31\" d=\"M 794 531 \nL 1825 531 \nL 1825 4091 \nL 703 3866 \nL 703 4441 \nL 1819 4666 \nL 2450 4666 \nL 2450 531 \nL 3481 531 \nL 3481 0 \nL 7
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAEGCAYAAAB/+QKOAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAAWwElEQVR4nO3debRlZX3m8e8joEYholIiAmUZm2BwgGCJsRUt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JlSTJGkBGPeVo+8D3snd/SFtA/ztpIqSJPVv3COIlwAvBH4GUFXXAdtNqihJUv/GDYg7q6rouvxO8sDJlSRJWgjGDYi/S/IxYPskrwO+xjy/PEiStLBs8i6mJAFOBh4D3AbsDvxpVZ014dokST0ap8vuSnJ6VT0eMBQkaYkY9xTTBUmeNNFKJEkLyrhPUj8ZeFWSaxjcyRQGBxdPmFRhkqR+zRoQSZZX1T8Bz59SPZKkBWJTp5i+CFBVPwA+XFU/GP7MZYNJdk+ybuhzW5LDZrRZleTWoTZ/OpdtSZLmblOnmDI0/FvzscGqugLYCyDJVsC1wCmNpt+sqoPmY5uSpM23qSOIGjE8X54N/N+5Ho1IkiZnUwGxZ3cK6HbgCd3wbUluT3LbPGz/YOCkEfOekuTCJGckeeyoFSRZnWRNkjU33XTTPJQkSYJNnGKqqq0mteEk92XQv9O7GrMvAB5ZVXckOYDBtZDdRtR4LHAswMqVKydxlCNJS9LmdPc93/YHLqiqG2bOqKrbquqObvh0YJskO0y7QElayvoMiEMYcXopycO7Lj5Isg+DOm+eYm2StOSN+6DcvOp6g30u8PqhaW8AqKpjgJcBb0yyAfgFcHD
},
"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)"
]
2022-05-18 06:37:27 +02:00
},
{
"cell_type": "markdown",
2022-05-18 01:08:58 +02:00
"metadata": {
"collapsed": false
2022-05-18 11:20:39 +02:00
},
"source": [
2022-05-18 12:03:27 +02:00
"## Wniosek\n",
"\n",
"Nie mamy podstaw, żeby odrzucić hipotezę zerową mówiącą, że średnia wynosi 160."
2022-05-18 11:20:39 +02:00
]
2022-05-18 01:08:58 +02:00
},
{
"cell_type": "markdown",
2022-05-18 11:20:39 +02:00
"metadata": {
"collapsed": false
},
2022-05-17 21:38:59 +02:00
"source": [
2022-05-18 01:08:58 +02:00
"# Dwie próby niezależne\n",
2022-05-17 21:38:59 +02:00
"\n",
2022-05-18 11:20:39 +02:00
"**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",
2022-05-18 01:08:58 +02:00
"\n",
2022-05-18 11:20:39 +02:00
"## 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",
2022-05-18 12:03:27 +02:00
"execution_count": 57,
2022-05-18 11:20:39 +02:00
"metadata": {},
"outputs": [
{
"output_type": "stream",
2022-05-18 12:03:27 +02:00
"name": "stdout",
2022-05-18 11:20:39 +02:00
"text": [
2022-05-18 12:03:27 +02:00
"p = 0.791\np = 0.7535\n"
2022-05-18 11:20:39 +02:00
]
}
2022-05-18 06:37:27 +02:00
],
2022-05-18 11:20:39 +02:00
"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",
2022-05-18 06:37:27 +02:00
"metadata": {
"collapsed": false
2022-05-18 11:20:39 +02:00
},
"source": [
"Wartości **p** w teście Shapiro-Wilka powyżej **0.05** -> Dane prawdopodobnie mają rozkład normalny"
]
2022-05-18 06:37:27 +02:00
},
{
"cell_type": "markdown",
2022-05-18 01:08:58 +02:00
"metadata": {
"collapsed": false
2022-05-18 11:20:39 +02:00
},
"source": [
"## Test"
]
2022-05-18 01:08:58 +02:00
},
2022-05-18 06:37:27 +02:00
{
"cell_type": "code",
2022-05-18 12:03:27 +02:00
"execution_count": 58,
2022-05-18 06:37:27 +02:00
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
2022-05-18 11:20:39 +02:00
},
"outputs": [
{
"output_type": "stream",
2022-05-18 12:03:27 +02:00
"name": "stdout",
2022-05-18 11:20:39 +02:00
"text": [
2022-05-18 12:03:27 +02:00
"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"
2022-05-18 11:20:39 +02:00
]
},
{
2022-05-18 12:03:27 +02:00
"output_type": "display_data",
2022-05-18 11:20:39 +02:00
"data": {
2022-05-18 12:03:27 +02:00
"text/plain": "<Figure size 432x288 with 1 Axes>",
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"392.14375pt\" height=\"262.19625pt\" viewBox=\"0 0 392.14375 262.19625\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n <metadata>\n <rdf:RDF xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n <cc:Work>\n <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n <dc:date>2022-05-18T12:02:55.815731</dc:date>\n <dc:format>image/svg+xml</dc:format>\n <dc:creator>\n <cc:Agent>\n <dc:title>Matplotlib v3.5.2, https://matplotlib.org/</dc:title>\n </cc:Agent>\n </dc:creator>\n </cc:Work>\n </rdf:RDF>\n </metadata>\n <defs>\n <style type=\"text/css\">*{stroke-linejoin: round; stroke-linecap: butt}</style>\n </defs>\n <g id=\"figure_1\">\n <g id=\"patch_1\">\n <path d=\"M 0 262.19625 \nL 392.14375 262.19625 \nL 392.14375 0 \nL 0 0 \nL 0 262.19625 \nz\n\" style=\"fill: none\"/>\n </g>\n <g id=\"axes_1\">\n <g id=\"patch_2\">\n <path d=\"M 50.14375 224.64 \nL 384.94375 224.64 \nL 384.94375 7.2 \nL 50.14375 7.2 \nz\n\" style=\"fill: #ffffff\"/>\n </g>\n <g id=\"patch_3\">\n <path d=\"M 65.361932 224.64 \nL 80.32579 224.64 \nL 80.32579 195.056327 \nL 65.361932 195.056327 \nz\n\" clip-path=\"url(#pe75ca4c90e)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"patch_4\">\n <path d=\"M 80.32579 224.64 \nL 95.289647 224.64 \nL 95.289647 204.917551 \nL 80.32579 204.917551 \nz\n\" clip-path=\"url(#pe75ca4c90e)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"patch_5\">\n <path d=\"M 95.289647 224.64 \nL 110.253505 224.64 \nL 110.253505 165.472653 \nL 95.289647 165.472653 \nz\n\" clip-path=\"url(#pe75ca4c90e)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"patch_6\">\n <path d=\"M 110.253505 224.64 \nL 125.217363 224.64 \nL 125.217363 17.554286 \nL 110.253505 17.554286 \nz\n\" clip-path=\"url(#pe75ca4c90e)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"patch_7\">\n <path d=\"M 125.217363 224.64 \nL 140.18122 224.64 \nL 140.18122 56.999184 \nL 125.217363 56.999184 \nz\n\" clip-path=\"url(#pe75ca4c90e)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"patch_8\">\n <path d=\"M 140.18122 224.64 \nL 155.145078 224.64 \nL 155.145078 27.41551 \nL 140.18122 27.41551 \nz\n\" clip-path=\"url(#pe75ca4c90e)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"patch_9\">\n <path d=\"M 155.145078 224.64 \nL 170.108936 224.64 \nL 170.108936 106.305306 \nL 155.145078 106.305306 \nz\n\" clip-path=\"url(#pe75ca4c90e)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"patch_10\">\n <path d=\"M 170.108936 224.64 \nL 185.072794 224.64 \nL 185.072794 106.305306 \nL 170.108936 106.305306 \nz\n\" clip-path=\"url(#pe75ca4c90e)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"patch_11\">\n <path d=\"M 185.072794 224.64 \nL 200.036651 224.64 \nL 200.036651 204.917551 \nL 185.072794 204.917551 \nz\n\" clip-path=\"url(#pe75ca4c90e)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"patch_12\">\n <path d=\"M 200.036651 224.64 \nL 215.000509 224.64 \nL 215.000509 175.333878 \nL 200.036651 175.333878 \nz\n\" clip-path=\"url(#pe75ca4c90e)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"matplotlib.axis_1\">\n <g id=\"xtick_1\">\n <g id=\"line2d_1\">\n <defs>\n <path id=\"m6c6f9a8310\" d=\"M 0 0 \nL 0 3.5 \n\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n </defs>\n <g>\n <use xlink:href=\"#m6c6f9a8310\" x=\"87.830669\" y=\"224.64\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n </g>\n </g>\n <g id=\"text_1\">\n <!-- 2 -->\n <g transform=\"translate(80.459575 239.238437)scale(0.1 -0.1)\">\n <defs>\n <path id=\"DejaVuSans-2212\" d=\"M 678 2272 \nL 4684 2272 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KTJG0dBn2L6VfA33WTJGkeGLQvpn+h8cyhqn5n6BVJkrYIG9MX0zoPAv4jsMvwy5EkbSkGegZRVT/tm1ZX1XsBu8eUpK3YoLeYDupb3IbeFcXGjCUhSZpjBv0l/66++bXAjcCLhl6NJGmLMehbTM/clIMnOZPe+NO3VdX+3bpdgE/SG53uRuBFVXVHY98TuP9V2r+sqg9vSg2SpE0z6C2m/76+7VX17lk2nQWcym+OPLcU+GpVnZJkabf8xhnn24XeEKXT9N6euiTJea0gkSSNxqBflJsGXk2vk749gBOBg4CHdFNTVX0DuH3G6mOBdVcDHwae39j1OcDyqrq9C4XlwBED1ipJGoJBn0HsCRxUVXcDJHk7cH5VvWQTzrlbVd3Szf8Y2K3RZg/gpr7lVd2635JkCbAEYOHChZtQjiSpZdAriN2Ae/uW76X9i32jdGNcb1anf1W1rKqmq2p6ampqc0uSJHUGvYL4CPC9JOd2y8/n/ttEG+vWJLtX1S1Jdgdua7RZDSzuW94TuGgTzydJ2gSDflHufwIvB+7oppdX1f/axHOeB5zQzZ8A/H2jzZeBw5PsnGRn4PBunSRpTAa9xQSwPXBXVf01sCrJ3hvaIck5wD8B+yZZleQVwCnAs5NcBxzWLZNkOsnpAFV1O/AXwMXd9I5unSRpTAZ9zXXdK6f7Ah8CtgM+Rm+UuVlV1fGzbDq00XYF8Md9y2cCZw5SnyRp+Aa9gngB8DzgZwBVdTPreb1VkjT3DRoQ9/a/cZRkh9GVJEnaEgwaEP8nyQeBnZK8EvgKDh4kSVu1DT6DSBJ6fSc9BriL3nOIt1bV8hHXJkmaoA0GRFVVkguq6nH0uryQJM0Dg95iWpnkiSOtRJK0RRn0m9RPAl6S5EZ6bzKF3sXF40dVmCRpstYbEEkWVtWP6PWuKkm
2022-05-18 11:20:39 +02:00
},
"metadata": {
"needs_background": "light"
2022-05-18 12:03:27 +02:00
}
2022-05-18 11:20:39 +02:00
}
],
"source": [
"p, t, ts = bootstrap_independent(heights_male, heights_female)\n",
"ts = [x[0] for x in ts]\n",
"draw_distribution(ts, t)"
]
2022-05-18 06:37:27 +02:00
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
2022-05-18 11:20:39 +02:00
},
"source": [
"## Wniosek"
]
2022-05-18 06:37:27 +02:00
},
2022-05-18 01:08:58 +02:00
{
"cell_type": "markdown",
2022-05-18 11:20:39 +02:00
"metadata": {
"collapsed": false
},
2022-05-18 01:08:58 +02:00
"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"
2022-05-18 11:20:39 +02:00
]
2022-05-18 01:08:58 +02:00
},
{
"cell_type": "markdown",
2022-05-18 11:20:39 +02:00
"metadata": {
"collapsed": false
},
2022-05-18 01:08:58 +02:00
"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"
2022-05-18 11:20:39 +02:00
]
2022-05-18 01:08:58 +02:00
},
{
"cell_type": "markdown",
2022-05-18 11:20:39 +02:00
"metadata": {
"collapsed": false
},
2022-05-18 01:08:58 +02:00
"source": [
"\n",
"### Sprawdzenie założeń\n",
"\n",
"Założenie o rozkładzie normalnym danych - sprawdzane testem Shapiro-Wilka"
2022-05-18 11:20:39 +02:00
]
2022-05-17 21:38:59 +02:00
},
{
"cell_type": "code",
2022-05-18 12:03:27 +02:00
"execution_count": 59,
2022-05-18 11:20:39 +02:00
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
},
2022-05-17 21:38:59 +02:00
"outputs": [
{
"output_type": "stream",
2022-05-18 12:03:27 +02:00
"name": "stdout",
2022-05-17 21:38:59 +02:00
"text": [
2022-05-18 12:03:27 +02:00
"p = 0.3308\np = 0.4569\n"
2022-05-17 21:38:59 +02:00
]
}
],
"source": [
2022-05-18 01:08:58 +02:00
"shapiro_test = shapiro(weights_before)\n",
2022-05-18 11:20:39 +02:00
"print(f\"p = {round(shapiro_test.pvalue,4)}\")\n",
"\n",
"shapiro_test = shapiro(weights_after)\n",
2022-05-18 01:08:58 +02:00
"print(f\"p = {round(shapiro_test.pvalue,4)}\")"
2022-05-18 11:20:39 +02:00
]
2022-05-18 01:08:58 +02:00
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
2022-05-18 11:20:39 +02:00
},
"source": [
"Wartości **p** w teście Shapiro-Wilka powyżej **0.05** -> Dane prawdopodobnie mają rozkład normalny"
]
2022-05-18 01:08:58 +02:00
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
2022-05-18 11:20:39 +02:00
},
"source": [
"## Test"
]
2022-05-17 21:38:59 +02:00
},
{
"cell_type": "code",
2022-05-18 12:03:27 +02:00
"execution_count": 39,
2022-05-18 11:20:39 +02:00
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
},
2022-05-17 21:38:59 +02:00
"outputs": [
{
"output_type": "stream",
2022-05-18 12:03:27 +02:00
"name": "stdout",
2022-05-17 21:38:59 +02:00
"text": [
2022-05-18 12:03:27 +02:00
"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"
2022-05-16 18:52:49 +02:00
]
2022-05-18 01:08:58 +02:00
},
{
2022-05-18 12:03:27 +02:00
"output_type": "display_data",
2022-05-18 01:08:58 +02:00
"data": {
2022-05-18 12:03:27 +02:00
"text/plain": "<Figure size 432x288 with 1 Axes>",
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"393.485968pt\" height=\"262.19625pt\" viewBox=\"0 0 393.485968 262.19625\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n <metadata>\n <rdf:RDF xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n <cc:Work>\n <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n <dc:date>2022-05-18T12:02:30.324226</dc:date>\n <dc:format>image/svg+xml</dc:format>\n <dc:creator>\n <cc:Agent>\n <dc:title>Matplotlib v3.5.2, https://matplotlib.org/</dc:title>\n </cc:Agent>\n </dc:creator>\n </cc:Work>\n </rdf:RDF>\n </metadata>\n <defs>\n <style type=\"text/css\">*{stroke-linejoin: round; stroke-linecap: butt}</style>\n </defs>\n <g id=\"figure_1\">\n <g id=\"patch_1\">\n <path d=\"M 0 262.19625 \nL 393.485968 262.19625 \nL 393.485968 0 \nL 0 0 \nL 0 262.19625 \nz\n\" style=\"fill: none\"/>\n </g>\n <g id=\"axes_1\">\n <g id=\"patch_2\">\n <path d=\"M 50.14375 224.64 \nL 384.94375 224.64 \nL 384.94375 7.2 \nL 50.14375 7.2 \nz\n\" style=\"fill: #ffffff\"/>\n </g>\n <g id=\"patch_3\">\n <path d=\"M 65.361932 224.64 \nL 68.00557 224.64 \nL 68.00557 172.868571 \nL 65.361932 172.868571 \nz\n\" clip-path=\"url(#pbb38b03de6)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"patch_4\">\n <path d=\"M 68.00557 224.64 \nL 70.649208 224.64 \nL 70.649208 214.285714 \nL 68.00557 214.285714 \nz\n\" clip-path=\"url(#pbb38b03de6)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"patch_5\">\n <path d=\"M 70.649208 224.64 \nL 73.292846 224.64 \nL 73.292846 131.451429 \nL 70.649208 131.451429 \nz\n\" clip-path=\"url(#pbb38b03de6)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"patch_6\">\n <path d=\"M 73.292846 224.64 \nL 75.936484 224.64 \nL 75.936484 100.388571 \nL 73.292846 100.388571 \nz\n\" clip-path=\"url(#pbb38b03de6)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"patch_7\">\n <path d=\"M 75.936484 224.64 \nL 78.580122 224.64 \nL 78.580122 17.554286 \nL 75.936484 17.554286 \nz\n\" clip-path=\"url(#pbb38b03de6)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"patch_8\">\n <path d=\"M 78.580122 224.64 \nL 81.22376 224.64 \nL 81.22376 27.908571 \nL 78.580122 27.908571 \nz\n\" clip-path=\"url(#pbb38b03de6)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"patch_9\">\n <path d=\"M 81.22376 224.64 \nL 83.867398 224.64 \nL 83.867398 100.388571 \nL 81.22376 100.388571 \nz\n\" clip-path=\"url(#pbb38b03de6)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"patch_10\">\n <path d=\"M 83.867398 224.64 \nL 86.511036 224.64 \nL 86.511036 110.742857 \nL 83.867398 110.742857 \nz\n\" clip-path=\"url(#pbb38b03de6)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"patch_11\">\n <path d=\"M 86.511036 224.64 \nL 89.154674 224.64 \nL 89.154674 162.514286 \nL 86.511036 162.514286 \nz\n\" clip-path=\"url(#pbb38b03de6)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"patch_12\">\n <path d=\"M 89.154674 224.64 \nL 91.798312 224.64 \nL 91.798312 172.868571 \nL 89.154674 172.868571 \nz\n\" clip-path=\"url(#pbb38b03de6)\" style=\"fill: #1f77b4\"/>\n </g>\n <g id=\"matplotlib.axis_1\">\n <g id=\"xtick_1\">\n <g id=\"line2d_1\">\n <defs>\n <path id=\"m15befd83cc\" d=\"M 0 0 \nL 0 3.5 \n\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n </defs>\n <g>\n <use xlink:href=\"#m15befd83cc\" x=\"78.506233\" y=\"224.64\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n </g>\n </g>\n <g id=\"text_1\">\n <!-- 0 -->\n <g transform=\"translate(75.324983 239.238437)scale(0.1 -0.1)\">\n <defs>\n <path id=\"DejaVuSans-30\" d=\"M 2034 4250 \nQ 1547 4250 1301 3770 \nQ 1056 3291 1056 2328 \nQ 1056 1369 1301 889 \nQ 1547 409 2034 409 \nQ 2525 409 2770 889 \nQ 3016 1369 3016 2328 \nQ 3016 32
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYkAAAEGCAYAAACQO2mwAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAAXrklEQVR4nO3dfbRddX3n8ffHBJ8ABeQaMRBDHYpFhUivqAVtQEUEFG1ZCqMO7VijDo7i6Gi0s8TacRauWT5UaaWppKBFfAZRUIkURG1VLjFAABkoE2sCkijIgzrS4Hf+ODtwuD07OTfcc87Nve/XWmfdvX/7t/f57nDJJ/vpt1NVSJLUy8NGXYAkaeYyJCRJrQwJSVIrQ0KS1MqQkCS1mj/qAqbTnnvuWYsXLx51GZI0PDfc0Pm5//7btfqVV175s6oaa1s+q0Ji8eLFTExMjLoMSRqepUs7Py+7bLtWT/LjrS33dJMkqZUhIUlqZUhIkloZEpKkVoaEJKmVISFJajWwkEiyT5JLk1yX5Nokb2na90iyKsmNzc/dW9Y/qelzY5KTBlWnJKndII8kNgNvq6oDgGcDJyc5AFgOXFJV+wGXNPMPkmQP4FTgWcAhwKltYSJJGpyBhURV3VpVq5vpu4HrgYXAccDZTbezgZf1WP1FwKqqur2q7gBWAUcNqlZJUm9DeeI6yWLgGcD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CSpFlvm6ebkgT4LPAU4C5gf+A9VbVqwLVJkkZsmyHRjNR6UVU9nc57HSRJc0S/p5tWJ3nmQCuRJM04/d7d9Czg1UnWAb8EQucg48BBFSZJGr2thkSSRVX1r3ReJyp
2022-05-18 01:08:58 +02:00
},
"metadata": {
"needs_background": "light"
2022-05-18 12:03:27 +02:00
}
2022-05-11 15:02:15 +02:00
}
],
"source": [
2022-05-18 01:08:58 +02:00
"p, t, ts = bootstrap_dependent(weights_before, weights_after)\n",
"ts = [x[0] for x in ts]\n",
"draw_distribution(ts, t)"
2022-05-18 11:20:39 +02:00
]
2022-05-18 01:08:58 +02:00
},
{
"cell_type": "markdown",
2022-05-18 11:20:39 +02:00
"metadata": {
"collapsed": false
},
2022-05-18 01:08:58 +02:00
"source": [
"## Wniosek\n",
"\n",
"???"
2022-05-18 11:20:39 +02:00
]
2022-05-18 01:08:58 +02:00
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
2022-05-18 11:20:39 +02:00
},
"outputs": [],
"source": []
2022-05-18 01:08:58 +02:00
},
{
"cell_type": "code",
2022-05-18 11:20:39 +02:00
"execution_count": null,
2022-05-18 01:08:58 +02:00
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
2022-05-18 11:20:39 +02:00
"outputs": [],
"source": []
2022-05-11 15:02:15 +02:00
}
],
"metadata": {
"interpreter": {
2022-05-18 11:20:39 +02:00
"hash": "1b132c2ed43285dcf39f6d01712959169a14a721cf314fe69015adab49bb1fd1"
2022-05-11 15:02:15 +02:00
},
"kernelspec": {
2022-05-18 12:03:27 +02:00
"display_name": "Python 3 (ipykernel)",
2022-05-18 11:20:39 +02:00
"language": "python",
2022-05-17 20:56:02 +02:00
"name": "python3"
2022-05-11 15:02:15 +02:00
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
2022-05-18 12:03:27 +02:00
"version": "3.8.10-final"
2022-05-17 21:49:11 +02:00
}
2022-05-11 15:02:15 +02:00
},
"nbformat": 4,
"nbformat_minor": 2
2022-05-18 12:03:27 +02:00
}