Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "metadata": {
- "name": "",
- "signature": "sha256:c7b073830f81f402a5e9f2cb7a0c9630a300bf629c408e5003e17339b63b4593"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import numpy as np\n",
- "import scipy.misc as misc\n",
- "from matplotlib import pyplot as plt\n",
- "%matplotlib inline"
- ],
- "language": "python",
- "metadata": {},
- "outputs": []
- },
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "HW 4"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Alexander Lee\n",
- "\n",
- "Phys 326\n",
- "\n",
- "Dr. Kristen Larson\n",
- "\n",
- "3/9/15 (originally due 2/17/15)"
- ]
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Problem 1:"
- ]
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "8.5"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "$y = Bx$\n",
- "\n",
- "However, we have a N measurements of x and y with negligible uncertainty in x and equal uncertainties in y.\n",
- "\n",
- "$\\rightarrow y_i = B_ix$\n",
- "\n",
- "$\\rightarrow Prob_B (y_i) \\alpha (1/ \\sigma_y)* \\exp {(-(y_i - Bx_i)^2)/2 \\sigma^2 }$\n",
- "\n",
- "$\\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",
- "\n",
- "where $\\chi^2 = \\sum\\limits_{i=1}^{N}((y_i - Bx_i)/ \\sigma_y) ^2$\n",
- "\n",
- "$\\rightarrow d\\chi^2 / dB = -2/ \\sigma_y^2 \\sum\\limits_{i=1}^{N}((y_i - Bx_i)^2 = 0$\n",
- "\n",
- "$\\rightarrow -2/ \\sigma_y^2 \\sum\\limits_{i=1}^{N}(x_i(y_i - Bx_i)^2 = 0$\n",
- "\n",
- "$\\rightarrow -\\sum\\limits_{i=1}^{N}(x_i)(y_i - Bx_i)^2 = 0$\n",
- "\n",
- "$\\rightarrow -\\sum\\limits_{i=1}^{N}x_i y_i + B\\sum\\limits_{i=1}^{N}x_i^2 = 0$\n",
- "\n",
- "$\\rightarrow \\sum\\limits_{i=1}^{N}(x_iy_i) = B\\sum\\limits_{i=1}^{N} (x_i)^2$\n",
- "\n",
- "$\\rightarrow B = \\sum\\limits_{i=1}^{N}(x_iy_i) / \\sum\\limits_{i=1}^{N} (x_i)^2$"
- ]
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "8.18"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "**Propogation of uncertainty in a function of several variables**\n",
- "\n",
- "for q(x,...,z)\n",
- "\n",
- "$dq = \\sqrt{((dq/dx) \\delta x)^2 + ... + ((dq/dz) \\delta z)^2}$\n",
- "\n",
- "B is a function of x and y\n",
- "\n",
- "Let $\\delta x = \\sigma_x$ and $\\delta y = \\sigma_y$.\n",
- "\n",
- "$\\sigma_B^2 = \\sum\\limits_{i=1}^{N} ( (dB / dy) \\sigma_y) ^2) $\n",
- "\n",
- "where $dB / dy = \\sum\\limits_{i=1}^{N} (x_i) / \\sum\\limits_{i=1}^{N} ((x_i)^2)$\n",
- "\n",
- "$\\sigma_B^2 = (( \\sum\\limits_{i=1}^{N} (x_i)^2) (\\sigma_y)^2 ) / (\\sum\\limits_{i=1}^{N} ((x_i)^2))^2 $\n",
- "\n",
- "$\\rightarrow \\sigma_B^2 = (\\sigma_y)^2 / (\\sum\\limits_{i=1}^{N} ((x_i)^2))^2$\n",
- "\n",
- "$\\rightarrow \\sigma_B = \\sqrt{ (\\sigma_y)^2 / \\sum\\limits_{i=1}^{N} ((x_i)^2) }$\n",
- "\n",
- "$\\rightarrow \\sigma_B = \\sigma_y / \\sqrt{ \\sum\\limits_{i=1}^{N} ((x_i)^2) }$"
- ]
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Problem 2"
- ]
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "8.6"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "$(x_1 + y_1)$ and $(x_2 + y_2)$ fits the line $y = A+Bx$\n",
- "\n",
- "The linear equation is:\n",
- "\n",
- "$y_i = A + Bx_i$\n",
- "\n",
- "$Prob(y_i) \\alpha (1/ \\sigma_y)* \\exp {(-(y_i - A - Bx_i)^2)/2 \\sigma_y^2 }$\n",
- "\n",
- "$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",
- "\n",
- "$\\rightarrow \\alpha 1/ ((\\sigma_y)^2) * \\exp(- \\chi^2/2)$\n",
- "\n",
- "$\\rightarrow \\chi^2 = \\sum\\limits_{i=1}^{2}((y_i -A - Bx_i)) ^2$\n",
- "\n",
- "$\\rightarrow d\\chi^2 / dA = -2/ \\sigma_y^2 \\sum\\limits_{i=1}^{2}(y_i - A - Bx_i) = 0$\n",
- "\n",
- "$\\rightarrow -\\sum\\limits_{i=1}^{2}(y_i - A - Bx_i) = 0$\n",
- "\n",
- "$\\rightarrow -\\sum\\limits_{i=1}^{2}(y_i) + 2A + B\\sum\\limits_{i=1}^{2}(x_i) = 0$\n",
- "\n",
- "$\\rightarrow 2A + B\\sum\\limits_{i=1}^{2}(x_i) = \\sum\\limits_{i=1}^{2}(y_i)$\n",
- "\n",
- "$\\rightarrow 2A + B(x_1 + x_2) = y_1 + y_2$ \n",
- "\n",
- "We will call this Equation 1"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "$d\\chi^2 / dB = -2/ \\sigma_y^2 \\sum\\limits_{i=1}^{2}((y_i - A - Bx_i)x_i) = 0$\n",
- "\n",
- "$\\rightarrow -\\sum\\limits_{i=1}^{2}(y_i x_i - A x_i - B x_i x_i) = 0$\n",
- "\n",
- "$\\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",
- "\n",
- "$\\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",
- "\n",
- "$\\rightarrow A (x_1 + x_2) + B (x_1^2 + x_2^2) = y_1x_1 + y_2x_2$\n",
- "\n",
- "We will call this Equation 2"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Rearrange Equation 1:\n",
- " \n",
- "$2A = - B(x_1 + x_2) + y_1 + y_2$ \n",
- "\n",
- "$\\rightarrow A = - B(x_1 + x_2)/2 + (y_1 + y_2)/2$ \n",
- "\n",
- "And insert into equation 2\n",
- "\n",
- "$\\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",
- "\n",
- "$\\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",
- "\n",
- "$\\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",
- "\n",
- "$\\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",
- "\n",
- "$\\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",
- "\n",
- "$\\rightarrow B(x_1 - x_2)^2 = x_1y_1 - x_1y_2 - x_2y_1 + x_2y_2$\n",
- "\n",
- "$\\rightarrow B = (x_1 - x_2)(y_1 - y_2) / (x_1 - x_2)^2$\n",
- "\n",
- "$\\rightarrow B = (y_1 - y_2) / (x_1 - x_2)$\n",
- "\n",
- "This is simply the slope of a line running throught the two points $(x_1, y_1)$ and $(x_2, y_2)$."
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "$\\sigma_y = (1/N-2) \\sum\\limits_{i=1}^{2}((y_i -A - Bx_i)) ^2$\n",
- "\n",
- "However, $1/N-2 = 0$. So the $\\sigma_y$ is undefined.\n",
- "\n",
- "Since,\n",
- "\n",
- "$\\sigma_B = \\sigma_y \\sqrt{N/\\Delta}$\n",
- "\n",
- "$\\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)."
- ]
- }
- ],
- "metadata": {}
- }
- ]
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement