aboutsummaryrefslogtreecommitdiff
path: root/sem6/prob/miniexam/Untitled.ipynb
blob: 3d81069f8a2aec0c90574ecd440c93d6fdd3b6f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from scipy import stats"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Problem 1\n",
    "\n",
    "Man kan sige at distribution af et enkelt kast af den 8 kantede terning er $1/8$ for hver værdi i $[1, 8]$.\n",
    "Ved at summe dem sammen kommer de til at ligne en gaussian random variable.\n",
    "\n",
    "Man ved også de to limits for distributionen, nemlig $[50 \\cdot 1, 50 \\cdot 8]$, og hver imellem må mean ligge.\n",
    "Ud fra intervallet og mean kan man regne varience."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Man kan først finde størrelsen af intervallet, eller var * 2\n",
    "var2 = 50 * 8 - 50 * 1\n",
    "sigma2 = var2/2\n",
    "mean = 50 * 1 + sigma2\n",
    "\n",
    "# Ved coin flip får man egentlig det samme distribution"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Part A\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<BarContainer object of 500 artists>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/d3fzzAAAACXBIWXMAAAsTAAALEwEAmpwYAAANXklEQVR4nO3db4hl9X3H8fenu5s/RCFrd5RFpWODhEpoVhmsYAk2JulqSzWQQITKPrBsHkRQGiibBNrkWVoa0yclsKmShRqDoKJoaLNsDRII2lmz6i6rXZNuU+OyM1aC5kla9dsH9wwZxpm9d++fmfndeb/gcs753XPnfL8X9jNnz/2dO6kqJEnt+a2NLkCSNBwDXJIaZYBLUqMMcElqlAEuSY3avp4H27VrV83Ozq7nISWpeUePHn2tqmZWjq9rgM/OzjI/P7+eh5Sk5iX5r9XGvYQiSY0ywCWpUQa4JDXKAJekRhngktQoA1ySGmWAS1KjDHBJapQBLkmNMsA1tWYPPLHRJUgTZYBLUqMMcElqVN8AT/K+JM8keS7JiSRf68YvSnI4yaluuXPy5UqSlgxyB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z32pew9eSvLHG1P18JJcnuTJJCeTnEhyVzc+zT2/L8kzSZ7rev5aNz61PS9Jsi3JT5I83m1Pdc9JTid5IcmxJPPd2GR7rqpN/aD3AelPgd8F3gM8B1y10XWNqbePAdcAx5eN/R1woFs/APxtt35V1/t7gSu692TbRvdwnv3uBq7p1i8E/qPra5p7DnBBt74DeBq4bpp7Xtb7XwLfBR7vtqe6Z+A0sGvF2ER7buEMfGpv2a+qp4DXVwzfAhzq1g8Bty4b/15V/bqq/hN4md5704yqOlNVz3brbwIngUuZ7p6rqn7Vbe7oHsUU9wyQ5DLgT4B/WjY81T2vYaI9txDglwL/vWz7lW5sWl1SVWegF3jAxd34VL0PSWaBq+mdkU51z92lhGPAAnC4qqa+Z+AfgL8C3lk2Nu09F/CDJEe7rxCBCfc8yq3062WgW/a3gKl5H5JcADwE3F1VbySrtdbbdZWx5nquqreBPUk+CDyS5CPn2L35npP8KbBQVUeT3DDIS1YZa6rnzvVV9WqSi4HDSV48x75j6bmFM/Ctdsv+2SS7AbrlQjc+Fe9Dkh30wvv+qnq4G57qnpdU1S+BHwJ7me6erwf+LMlpepc8P57kn5nunqmqV7vlAvAIvUsiE+25hQDfarfsPwbs69b3AY8uG/9ckvcmuQK4EnhmA+obWnqn2vcCJ6vqnmVPTXPPM92ZN0neD3wCeJEp7rmqvlRVl1XVLL1/r/9WVX/OFPec5ANJLlxaBz4FHGfSPW/0J7cDfrp7M70ZCz8FvrLR9YyxrweAM8D/0fuNfAfw28AR4FS3vGjZ/l/p3oOXgJs2uv4h+v1Dev9NfB441j1unvKefx/4SdfzceCvu/Gp7XlF/zfwm1koU9szvVlyz3WPE0s5NemevZVekhrVwiUUSdIqDHBJapQBLkmNMsAlqVEGuCQ1ygCXpEYZ4JLUqP8HvlS2LghG5EEAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "slots = np.zeros(500)\n",
    "x = np.arange(500)\n",
    "for exp in range(1000):\n",
    "    s = 0\n",
    "    for i in range(50):\n",
    "        r = np.random.randint(1, 9)\n",
    "        #r = [1, 8][np.random.randint(0, 2)]\n",
    "        s += r\n",
    "    slots[s] += 1\n",
    "\n",
    "plt.bar(x, slots)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Problem 2\n",
    "\n",
    "The distribution function is given by:\n",
    "$$\n",
    "f(x)_\\theta = \\frac x {\\theta^2} e ^ {- \\frac x \\theta }\n",
    "$$\n",
    "\n",
    "Then we can find the likelyhood function $f(x_1,...,x_n | \\theta)$.\n",
    "\n",
    "$$\n",
    "f(x_1,...,x_n | \\theta) = f(x_1)_\\theta \\cdot ... \\cdot f(x_n)_\\theta = \\frac {\\prod_i x_i} {\\theta^{2n}} \\cdot \\exp \\left( -\\frac {\\sum_i} \\theta \\right)\n",
    "$$\n",
    "\n",
    "Her kan man tage log på hver side\n",
    "\n",
    "$$\n",
    "\\log f(x_1,...,x_n | \\theta) = \\log \\left( \\frac {\\prod_i x_i} {\\theta^{2n}} \\right) - \\frac 1 \\theta \\sum_i x_i\n",
    "$$\n",
    "\n",
    "Og diff i forhold til $\\theta$.\n",
    "\n",
    "$$\n",
    "\\frac d {d\\theta} \\log f(x_1,...,x_n | \\theta) = -\\frac {2n} \\theta + \\frac 1 {\\theta^2} \\sum_i x_i\n",
    "$$\n",
    "\n",
    "Og man kan løse for $0$.\n",
    "\n",
    "$$\n",
    "\\theta = \\frac {\\sum_i x_i} {2n}\n",
    "$$\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Estimated theta = 1.2944444444444445\n"
     ]
    }
   ],
   "source": [
    "# Part B\n",
    "# Her indsættes samples\n",
    "\n",
    "samples = np.array([3.2, 1.4, 6.5, 2.2, 1.8, 2.6, 3.9, 0.5, 1.2])\n",
    "N = len(samples)\n",
    "\n",
    "sum_samples = np.sum(samples)\n",
    "\n",
    "theta_est = sum_samples / (2 * N)\n",
    "print(f\"Estimated theta = {theta_est}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "argmax: 1.2962962962962963\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x7faf4d186640>]"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAEDCAYAAAAlRP8qAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/d3fzzAAAACXBIWXMAAAsTAAALEwEAmpwYAAAj/ElEQVR4nO3deXScd33v8fd3NFqsxZK12JYtyWtsx3glirOTACELJKSl0JPALYUbbnALHLhcLnB7Tttzy+npdtsLtKQhDbRwaUlDSblprklCIAtJSLCdeInj2JZ3LbY2S9a+ze/+MTPORJbssT0zz6LP6xxFmplnnueryP74p9/zW8w5h4iIBF/E6wJERCQzFOgiIiGhQBcRCQkFuohISCjQRURCQoEuIhISnga6mX3XzNrN7PUMnOvdZrYj5WPYzH4jA2WKiASCeTkO3czeBfQD33fOrcngeSuBJqDOOTeYqfOKiPiZpy1059zzQHfqc2a2zMyeMLPtZvZLM1t1Eaf+MPBThbmIzCR+7EN/EPicc+4K4EvA/RdxjruBH2a0KhERn4t6XUAqMysFrgV+ZGbJpwsTr30I+JMp3tbinLs15Ry1wFrgyexWKyLiL74KdOK/MfQ45zZMfsE59yjwaBrn+G3g351zYxmuTUTE13zV5eKcOw0cNrOPAFjc+gs8zT2ou0VEZiCvhy3+EPgVsNLMms3sXuBjwL1mthPYA9x1AedbDNQDz2WhXBERX/N02KKIiGSOr7pcRETk4nl2U7S6utotXrzYq8u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m1mRmX/W6nmwzs++aWbuZve51LbliZvVm9oyZ7TWzPWb2ea9ryiYzKzKzX5vZzsT3+z+9rilXzCzPzF4zs8e9riUXzOyIme02sx1mti3j5w9SH3piw+r9pGxYDdwzacPqUDGzdwH9xPdsXeN1PblgZrVArXPuVTMrA7YDvxHWn7PF9zUscc71m1k+8ALweefcyx6XlnVm9kWgEZjtnLvD63qyzcyOAI3OuaxMpApaC/3MhtXOuVEguWF1aDnnnge6va4jl5xzbc65VxNf9wF7ie9RG0ourj/xMD/xEZyW1kUyszrgA8BDXtcSFkEL9Ok2o5aQMrPFwEbgFY9LyapE18MOoB34mXMu1N9vwteBLwOx8xwXJg54ysy2m9l9mT550AI9rc2oJRzMrBT4MfAF59xpr+vJJufchHNuA/H9eDeZWai718zsDqDdObfd61py7Drn3DuB24HPJLpUMyZoga7NqGeIRF/yj4F/ds496nU9ueKc6wGeBW7ztpKsuw74YKJP+WHgPWb2A29Lyj7nXGviczvw78S7kTMmaIGezobVEnCJm4TfAfY65/7G63qyzcxqzKwi8fUs4GbgTU+LyjLn3P9wztU55xYT/3v8C+fcf/K4rKwys5LETX7MrAS4Bcjo6LVABbpzbhxIbli9F3jEObfH26qyy8x+CPwKWGlmzWZ2r9c15cB1wO8Qb7XtSHy83+uisqgWeMbMdhFvtPzMOTcjhvHNMPOAF8xsJ/Br4P85557I5AUCNWxRRESmF6gWuoiITE+BLiISEgp0EZGQUKCLiISEAl1EJCQU6CIiIaFAFxEJif8P0+PrXvkm6SQAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Prøver lige at løse den programmerbart også\n",
    "thetas = np.linspace(0, 5, 1000)[1:]\n",
    "res = np.empty(thetas.shape)\n",
    "\n",
    "for i, theta in enumerate(thetas):\n",
    "    f = lambda x: ((x / (theta**2)) * np.exp(-x / theta))\n",
    "    score = 1\n",
    "    for sample in samples:\n",
    "        score *= f(sample)\n",
    "    \n",
    "    res[i] = score\n",
    "\n",
    "maxtheta = thetas[np.argmax(res)]\n",
    "print(f\"argmax: {maxtheta}\")\n",
    "plt.plot(thetas, res)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Problem 3\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [],
   "source": [
    "radial = np.array([5.2, 5.7, 7.6, 8.0, 7.7, 5.5, 6.7, 7.0, 8.4, 5.9])\n",
    "\n",
    "belted = np.array([5.1, 5.9, 7.2, 7.9, 7.8, 5.4, 6.7, 6.8, 7.9, 5.7])\n",
    "belted_mean = np.mean(belted)\n",
    "N = len(belted)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Part A\n",
    "\n",
    "Here we don't know the varience, and will therefore have to use the t distribution method.\n",
    "The interval is given by:\n",
    "$$\n",
    "\\bar X \\pm t_{\\alpha/2,n-1} \\frac S {\\sqrt{n}}\n",
    "$$\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Then the interval becomes [6.174311863003706, 7.105688136996291]\n"
     ]
    }
   ],
   "source": [
    "alpha = 0.1\n",
    "# Lets start by calculating the t value\n",
    "tval = stats.t.ppf(1 - alpha, N-1)\n",
    "\n",
    "S = np.sqrt(np.sum((belted - belted_mean)**2) / (N - 1))\n",
    "\n",
    "diff = tval * S / np.sqrt(N)\n",
    "print(f\"Then the interval becomes [{belted_mean - diff}, {belted_mean + diff}]\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Part B\n",
    "\n",
    "We can take the difference of the two and say that this should be less than or equal to $0$.\n",
    "Thus the $H_0$ is $(\\mu_{belted} - \\mu_{radial}) \\leq 0$.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ 0.1 -0.2  0.4  0.1 -0.1  0.1  0.   0.2  0.5  0.2] 0.12999999999999998\n",
      "ts: 1.9475670608117976\n",
      "p-value: 0.04164574347828587\n",
      "H_0 is accepted, thus radial does not make it better\n"
     ]
    }
   ],
   "source": [
    "mu_0 = 0\n",
    "alpha = 0.05\n",
    "diff = radial - belted\n",
    "diff_mean = np.mean(diff)\n",
    "print(diff, diff_mean)\n",
    "\n",
    "S = np.sqrt(np.sum((diff - diff_mean)**2) / (N - 1))\n",
    "\n",
    "ts = np.sqrt(N) * (diff_mean - mu_0) / S\n",
    "print(f\"ts: {ts}\")\n",
    "p_value = 1 - stats.t.cdf(ts, N - 1)\n",
    "print(f\"p-value: {p_value}\")\n",
    "\n",
    "if p_value > alpha:\n",
    "    print(\"H_0 is rejected thus radial tires have better economy\")\n",
    "else:\n",
    "    print(\"H_0 is accepted, thus radial does not make it better\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Part C\n",
    "\n",
    "Drivers can drive radically different in the way they brake, shift gears and apply power.\n",
    "The driver is therefore as important a parameter as the car driven.\n",
    "\n",
    "When creating such tests it is very important to only change the variable in question, in this case the tires.\n",
    "By keeping all other variables the same, one can say that a change in performance likely comes from the other tires."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "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.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}