Advertisement
Guest User

Untitled

a guest
Apr 26th, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.37 KB | None | 0 0
  1. {
  2. "metadata": {
  3. "name": "",
  4. "signature": "sha256:c7b073830f81f402a5e9f2cb7a0c9630a300bf629c408e5003e17339b63b4593"
  5. },
  6. "nbformat": 3,
  7. "nbformat_minor": 0,
  8. "worksheets": [
  9. {
  10. "cells": [
  11. {
  12. "cell_type": "code",
  13. "collapsed": false,
  14. "input": [
  15. "import numpy as np\n",
  16. "import scipy.misc as misc\n",
  17. "from matplotlib import pyplot as plt\n",
  18. "%matplotlib inline"
  19. ],
  20. "language": "python",
  21. "metadata": {},
  22. "outputs": []
  23. },
  24. {
  25. "cell_type": "heading",
  26. "level": 1,
  27. "metadata": {},
  28. "source": [
  29. "HW 4"
  30. ]
  31. },
  32. {
  33. "cell_type": "markdown",
  34. "metadata": {},
  35. "source": [
  36. "Alexander Lee\n",
  37. "\n",
  38. "Phys 326\n",
  39. "\n",
  40. "Dr. Kristen Larson\n",
  41. "\n",
  42. "3/9/15 (originally due 2/17/15)"
  43. ]
  44. },
  45. {
  46. "cell_type": "heading",
  47. "level": 2,
  48. "metadata": {},
  49. "source": [
  50. "Problem 1:"
  51. ]
  52. },
  53. {
  54. "cell_type": "heading",
  55. "level": 3,
  56. "metadata": {},
  57. "source": [
  58. "8.5"
  59. ]
  60. },
  61. {
  62. "cell_type": "markdown",
  63. "metadata": {},
  64. "source": [
  65. "$y = Bx$\n",
  66. "\n",
  67. "However, we have a N measurements of x and y with negligible uncertainty in x and equal uncertainties in y.\n",
  68. "\n",
  69. "$\\rightarrow y_i = B_ix$\n",
  70. "\n",
  71. "$\\rightarrow Prob_B (y_i) \\alpha (1/ \\sigma_y)* \\exp {(-(y_i - Bx_i)^2)/2 \\sigma^2 }$\n",
  72. "\n",
  73. "$\\rightarrow Prob_B (y_1 ... y_n)$ $\\alpha$ $Prob_B (y_1) ... Prob_B (y_n) \\alpha (1/ ((\\sigma_y)^N)) * \\exp(- \\chi^2/2)$\n",
  74. "\n",
  75. "where $\\chi^2 = \\sum\\limits_{i=1}^{N}((y_i - Bx_i)/ \\sigma_y) ^2$\n",
  76. "\n",
  77. "$\\rightarrow d\\chi^2 / dB = -2/ \\sigma_y^2 \\sum\\limits_{i=1}^{N}((y_i - Bx_i)^2 = 0$\n",
  78. "\n",
  79. "$\\rightarrow -2/ \\sigma_y^2 \\sum\\limits_{i=1}^{N}(x_i(y_i - Bx_i)^2 = 0$\n",
  80. "\n",
  81. "$\\rightarrow -\\sum\\limits_{i=1}^{N}(x_i)(y_i - Bx_i)^2 = 0$\n",
  82. "\n",
  83. "$\\rightarrow -\\sum\\limits_{i=1}^{N}x_i y_i + B\\sum\\limits_{i=1}^{N}x_i^2 = 0$\n",
  84. "\n",
  85. "$\\rightarrow \\sum\\limits_{i=1}^{N}(x_iy_i) = B\\sum\\limits_{i=1}^{N} (x_i)^2$\n",
  86. "\n",
  87. "$\\rightarrow B = \\sum\\limits_{i=1}^{N}(x_iy_i) / \\sum\\limits_{i=1}^{N} (x_i)^2$"
  88. ]
  89. },
  90. {
  91. "cell_type": "heading",
  92. "level": 3,
  93. "metadata": {},
  94. "source": [
  95. "8.18"
  96. ]
  97. },
  98. {
  99. "cell_type": "markdown",
  100. "metadata": {},
  101. "source": [
  102. "**Propogation of uncertainty in a function of several variables**\n",
  103. "\n",
  104. "for q(x,...,z)\n",
  105. "\n",
  106. "$dq = \\sqrt{((dq/dx) \\delta x)^2 + ... + ((dq/dz) \\delta z)^2}$\n",
  107. "\n",
  108. "B is a function of x and y\n",
  109. "\n",
  110. "Let $\\delta x = \\sigma_x$ and $\\delta y = \\sigma_y$.\n",
  111. "\n",
  112. "$\\sigma_B^2 = \\sum\\limits_{i=1}^{N} ( (dB / dy) \\sigma_y) ^2) $\n",
  113. "\n",
  114. "where $dB / dy = \\sum\\limits_{i=1}^{N} (x_i) / \\sum\\limits_{i=1}^{N} ((x_i)^2)$\n",
  115. "\n",
  116. "$\\sigma_B^2 = (( \\sum\\limits_{i=1}^{N} (x_i)^2) (\\sigma_y)^2 ) / (\\sum\\limits_{i=1}^{N} ((x_i)^2))^2 $\n",
  117. "\n",
  118. "$\\rightarrow \\sigma_B^2 = (\\sigma_y)^2 / (\\sum\\limits_{i=1}^{N} ((x_i)^2))^2$\n",
  119. "\n",
  120. "$\\rightarrow \\sigma_B = \\sqrt{ (\\sigma_y)^2 / \\sum\\limits_{i=1}^{N} ((x_i)^2) }$\n",
  121. "\n",
  122. "$\\rightarrow \\sigma_B = \\sigma_y / \\sqrt{ \\sum\\limits_{i=1}^{N} ((x_i)^2) }$"
  123. ]
  124. },
  125. {
  126. "cell_type": "heading",
  127. "level": 2,
  128. "metadata": {},
  129. "source": [
  130. "Problem 2"
  131. ]
  132. },
  133. {
  134. "cell_type": "heading",
  135. "level": 3,
  136. "metadata": {},
  137. "source": [
  138. "8.6"
  139. ]
  140. },
  141. {
  142. "cell_type": "markdown",
  143. "metadata": {},
  144. "source": [
  145. "$(x_1 + y_1)$ and $(x_2 + y_2)$ fits the line $y = A+Bx$\n",
  146. "\n",
  147. "The linear equation is:\n",
  148. "\n",
  149. "$y_i = A + Bx_i$\n",
  150. "\n",
  151. "$Prob(y_i) \\alpha (1/ \\sigma_y)* \\exp {(-(y_i - A - Bx_i)^2)/2 \\sigma_y^2 }$\n",
  152. "\n",
  153. "$Prob_B (y_1 ... y_n)$ \\alpha Prob_B (y_1) ... Prob_B (y_n) \\alpha 1/ ((\\sigma_y)^2) * \\exp(- \\chi^2/2)$\n",
  154. "\n",
  155. "$\\rightarrow \\alpha 1/ ((\\sigma_y)^2) * \\exp(- \\chi^2/2)$\n",
  156. "\n",
  157. "$\\rightarrow \\chi^2 = \\sum\\limits_{i=1}^{2}((y_i -A - Bx_i)) ^2$\n",
  158. "\n",
  159. "$\\rightarrow d\\chi^2 / dA = -2/ \\sigma_y^2 \\sum\\limits_{i=1}^{2}(y_i - A - Bx_i) = 0$\n",
  160. "\n",
  161. "$\\rightarrow -\\sum\\limits_{i=1}^{2}(y_i - A - Bx_i) = 0$\n",
  162. "\n",
  163. "$\\rightarrow -\\sum\\limits_{i=1}^{2}(y_i) + 2A + B\\sum\\limits_{i=1}^{2}(x_i) = 0$\n",
  164. "\n",
  165. "$\\rightarrow 2A + B\\sum\\limits_{i=1}^{2}(x_i) = \\sum\\limits_{i=1}^{2}(y_i)$\n",
  166. "\n",
  167. "$\\rightarrow 2A + B(x_1 + x_2) = y_1 + y_2$ \n",
  168. "\n",
  169. "We will call this Equation 1"
  170. ]
  171. },
  172. {
  173. "cell_type": "markdown",
  174. "metadata": {},
  175. "source": [
  176. "$d\\chi^2 / dB = -2/ \\sigma_y^2 \\sum\\limits_{i=1}^{2}((y_i - A - Bx_i)x_i) = 0$\n",
  177. "\n",
  178. "$\\rightarrow -\\sum\\limits_{i=1}^{2}(y_i x_i - A x_i - B x_i x_i) = 0$\n",
  179. "\n",
  180. "$\\rightarrow - \\sum\\limits_{i=1}^{2}(y_i x_i) + A \\sum\\limits_{i=1}^{2}(x_i) + B \\sum\\limits_{i=1}^{2}(x_i^2) = 0$\n",
  181. "\n",
  182. "$\\rightarrow A \\sum\\limits_{i=1}^{2}(x_i) + B \\sum\\limits_{i=1}^{2}(x_i^2) = \\sum\\limits_{i=1}^{2}(y_i x_i)$\n",
  183. "\n",
  184. "$\\rightarrow A (x_1 + x_2) + B (x_1^2 + x_2^2) = y_1x_1 + y_2x_2$\n",
  185. "\n",
  186. "We will call this Equation 2"
  187. ]
  188. },
  189. {
  190. "cell_type": "markdown",
  191. "metadata": {},
  192. "source": [
  193. "Rearrange Equation 1:\n",
  194. " \n",
  195. "$2A = - B(x_1 + x_2) + y_1 + y_2$ \n",
  196. "\n",
  197. "$\\rightarrow A = - B(x_1 + x_2)/2 + (y_1 + y_2)/2$ \n",
  198. "\n",
  199. "And insert into equation 2\n",
  200. "\n",
  201. "$\\rightarrow - B(x_1 + x_2)/2 + (y_1 + y_2)/2) *(x_1 + x_2) + B (x_1^2 + x_2^2) = y_1x_1 + y_2x_2$\n",
  202. "\n",
  203. "$\\rightarrow - B(x_1 + x_2)^2/2 + (y_1 + y_2)(x_1 + x_2)/2) + B (x_1^2 + x_2^2) = y_1x_1 + y_2x_2$\n",
  204. "\n",
  205. "$\\rightarrow - B(x_1^2 + 2 x_1x_2 + x_2^2)/2 + (x_1y_1 +x_2y_1 + x_1y_2 + x_2y_2)/2) + B (x_1^2 + x_2^2) = y_1x_1 + y_2x_2$\n",
  206. "\n",
  207. "$\\rightarrow - B(x_1^2 + 2 x_1x_2 + x_2^2) + x_1y_1 +x_2y_1 + x_1y_2 + x_2y_2 + 2B (x_1^2 + x_2^2) = 2y_1x_1 + 2y_2x_2$\n",
  208. "\n",
  209. "$\\rightarrow B(x_1^2 - 2 x_1x_2 + x_2^2) = 2x_1y_1 + 2x_2y_2 - x_1y_1 - x_2y_1 - x_1y_2 - x_2y_2$\n",
  210. "\n",
  211. "$\\rightarrow B(x_1 - x_2)^2 = x_1y_1 - x_1y_2 - x_2y_1 + x_2y_2$\n",
  212. "\n",
  213. "$\\rightarrow B = (x_1 - x_2)(y_1 - y_2) / (x_1 - x_2)^2$\n",
  214. "\n",
  215. "$\\rightarrow B = (y_1 - y_2) / (x_1 - x_2)$\n",
  216. "\n",
  217. "This is simply the slope of a line running throught the two points $(x_1, y_1)$ and $(x_2, y_2)$."
  218. ]
  219. },
  220. {
  221. "cell_type": "markdown",
  222. "metadata": {},
  223. "source": [
  224. "$\\sigma_y = (1/N-2) \\sum\\limits_{i=1}^{2}((y_i -A - Bx_i)) ^2$\n",
  225. "\n",
  226. "However, $1/N-2 = 0$. So the $\\sigma_y$ is undefined.\n",
  227. "\n",
  228. "Since,\n",
  229. "\n",
  230. "$\\sigma_B = \\sigma_y \\sqrt{N/\\Delta}$\n",
  231. "\n",
  232. "$\\sigma_B$ must also be undefined. This is logical as you cannot have a standard deviation of a line when only one line exists (there are only two points)."
  233. ]
  234. }
  235. ],
  236. "metadata": {}
  237. }
  238. ]
  239. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement