Created
March 17, 2014 16:02
-
-
Save PBarmby/9602148 to your computer and use it in GitHub Desktop.
ipython notebook: least-squares special cases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"%matplotlib inline" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 1 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"import numpy as np" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 2 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"import scipy.optimize as spo" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 3 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"import matplotlib.pylab as plt" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 4 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"xi = np.array([25,16,11.11,8.16,6.25,4.94,4,2.78,1.78,1])\n", | |
"ci = np.array([44,18,17,6,8,9,9,11,3,3])\n", | |
"obs_unc = np.sqrt(ci)" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 5 | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Standard least-squares fit. Note that this is the correct use of w (I had been squaring the number before, which isn't necessary). Polyfit returns coefficient of highest power first, so it's 1.22*x+1.52" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"np.polyfit(xi,ci,1,w=1/obs_unc)" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 6, | |
"text": [ | |
"array([ 1.22327698, 1.51995345])" | |
] | |
} | |
], | |
"prompt_number": 6 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"plt.errorbar(xi,ci,obs_unc,marker='s',ls='None',color='k')\n", | |
"xfit = np.arange(0,30,0.5)\n", | |
"plt.plot(xfit,1.52+1.22*xfit,marker=None,ls='solid',label='Std least-sq')\n", | |
"plt.plot(xfit,2.54+1.35*xfit,marker=None,ls='solid',label='Gaussian, analytic')\n", | |
"plt.plot(xfit,2.10+1.32*xfit,marker=None,ls='solid',label='Poisson, analytic')\n", | |
"plt.legend()" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 13, | |
"text": [ | |
"<matplotlib.legend.Legend at 0x105724d90>" | |
] | |
}, | |
{ | |
"metadata": {}, | |
"output_type": "display_data", | |
"png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAEACAYAAACwB81wAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3Xd4VNX28PHvmYQUqYEQWigJBEKvSgIqQYqIiBTlSgel\niQiiiHr1J3Av+nq90kEjzQsYLIggSBEViZRgkA5BIBSlS5UeUtb7x3YOqSQhCQlkfZ5nHpKZM+fs\nM0zW7Nln77UsERGUUkrd8xy53QCllFJ3hgZ8pZTKJzTgK6VUPqEBXyml8gkN+EoplU9owFdKqXwi\nQwH/7NmzvPTSS/j5+eHu7k7JkiVp3rw527ZtAyA2NpYxY8bg7++Pm5sbvr6+DB8+nMuXL+do45VS\nSmWcld48/LNnz9K4cWMOHjyIq6srAQEBuLq6cvjwYT755BM6depEz549CQsLw8XFhYCAAA4cOEBs\nbCzNmjVj9erVWJZ1p85HKaVUGtLt4b/11lscPHgQX19f9uzZw+7du9m+fTvn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V1qKmpcXtbeK8k/IUuzJIbGzZsQEhICO/v3bsXGo0GgPyemBzM\n9sGa7pXDS7vdzn+yk4uXc70mMyUlBUqlkvcPHz7Mj+Xg59DQELKzs1FbW4u1a9eioaEB27ZtA+Ab\n/s2lD5C/fw70ej0uX77M+69fv0ZUVBTv/41/Xkn4vr4wy2KxoLe3l/efP3+O79+/A5hakyBHpj8x\nTD92eEX/2f4aAJ48eQKbzeZ0fakzm77BwUHcuHHD6av/9JK4pe5nR0cH0tLS0NTUhNTUVDQ3NyM5\nOZlfl7t/8+mTs3/j4+OoqqqC1Wrl5x49esSPdTqd+/55cIJ5TiorK/lMcmxsLK/Q0el01Nvb660w\nFgVHqVh0dDQlJCRwncHBwdTR0SF1eAuivr6eTCYTGY1GrkOj0ZDJZKLCwkIiIiooKCDGGPn5+VF8\nfDwvHcvMzJQ2eBeYT19XVxcxxkipVFJ8fDxFRUXxcZs2bSKbzSa1hDnZuHEjjzcpKYnS0tJ4q66u\nJiJ5+zefPjn7NzIyQowxCgwMpMTERDKZTDz20NBQ6u7uJiL3/PNawiciun37NqWmppJaraY1a9ZQ\nbm4uffr0yZshLAqVlZW0Z88eMhgMpFaryWg0UlFREX38+FHq0BbMrVu3eBnY/7adO3cSEdHk5CSV\nlpZSbGwsqVQqMhgMdPr0aRodHZU4+vmZT9/Pnz+ppKSE0tLSSKvV0sqVKykxMZEuXLhAP378kDr8\neYmJiZlRm0Kh4OWncvZvPn1y9s9qtVJRURHFxcVRUFAQqVQqiomJIbPZTJ2dnXycO/5J8k5bgUAg\nEHgfSat0BAKBQOA9RMIXCASCZYJI+AKBQLBMEAlfIBAIlgki4QsEAsEyQSR8gUAgWCb8C33WyuW7\nLpiCAAAAAElFTkSuQmCC\n", | |
"text": [ | |
"<matplotlib.figure.Figure at 0x1054fead0>" | |
] | |
} | |
], | |
"prompt_number": 13 | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Now define a vector function representing the 2 equations to be solved for a and b, for the Gaussian analytic uncertainty case." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"def alt_func1(a,xi,ci):\n", | |
" term2 = (ci/(a[0]+a[1]*xi))**2\n", | |
" eq1 = len(xi)-term2.sum()\n", | |
" term2 = xi*(ci/(a[0]+a[1]*xi))**2\n", | |
" eq2 = xi.sum()-term2.sum()\n", | |
" return(np.array([eq1,eq2]))" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 8 | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"And use scipy.optimize.root to find the roots of this equation. \"args\" are the extra arguments to the function, in this case our data." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"spo.root(alt_func1,np.array([1.5,1.2]),args=(xi,ci))" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 9, | |
"text": [ | |
" status: 1\n", | |
" success: True\n", | |
" qtf: array([ 7.05012347e-10, 9.96187576e-09])\n", | |
" nfev: 12\n", | |
" r: array([ -10.73741172, -101.08350504, -11.6317085 ])\n", | |
" fun: array([ -4.27444746e-11, 1.12549969e-11])\n", | |
" x: array([ 2.53529043, 1.34635396])\n", | |
" message: 'The solution converged.'\n", | |
" fjac: array([[-0.18532915, -0.9826765 ],\n", | |
" [ 0.9826765 , -0.18532915]])" | |
] | |
} | |
], | |
"prompt_number": 9 | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Same thing for the Poisson uncertainty case" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"def alt_func2(a,xi,ci):\n", | |
" term2 = ci/(a[0]+a[1]*xi)\n", | |
" eq1 = len(xi)-term2.sum()\n", | |
" term2 = xi*(ci/(a[0]+a[1]*xi))\n", | |
" eq2 = xi.sum()-term2.sum()\n", | |
" return(np.array([eq1,eq2]))" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 11 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"spo.root(alt_func2,np.array([1.5,1.2]),args=(xi,ci))" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 12, | |
"text": [ | |
" status: 1\n", | |
" success: True\n", | |
" qtf: array([ 3.26631559e-08, -1.65932458e-08])\n", | |
" nfev: 10\n", | |
" r: array([ -5.58603901, -51.17813446, -6.35955669])\n", | |
" fun: array([ 2.21742624e-11, 2.47695198e-11])\n", | |
" x: array([ 2.09937404, 1.32073883])\n", | |
" message: 'The solution converged.'\n", | |
" fjac: array([[-0.21038093, -0.97761949],\n", | |
" [ 0.97761949, -0.21038093]])" | |
] | |
} | |
], | |
"prompt_number": 12 | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Now what about the case with uncertainties in both parameters? First define some x uncertainties:" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"x_unc = np.log(xi)" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 26 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"plt.errorbar(xi,ci,yerr=obs_unc,xerr=x_unc,marker='s',ls='None')\n", | |
"#plt.plot(xfit,1.16+1.41*xfit,ls='solid',marker='None')" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 29, | |
"text": [ | |
"<Container object of 3 artists>" | |
] | |
}, | |
{ | |
"metadata": {}, | |
"output_type": "display_data", | |
"png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAEACAYAAACwB81wAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t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6/VyPZKS\nkkRGRoYoKioSQgixdu1aIUmSiIqKEpmZmfLUsezs7OAW3gue6tfZ2SkkSRIxMTEiMzNTzJkzR97v\nwQcfFDabLdhVGNMDDzwgl3fhwoVi2bJl8rJ3714hRHi3n6f6hXP79fT0CEmSRFxcnFiwYIHIyMiQ\ny37fffeJCxcuCCF8a79JC3whhDCbzWLx4sUiPj5eTJ8+XeTn54vPPvtsMosQELt37xZPPPGEmD17\ntoiPjxd6vV4UFxeLTz/9NNhFG7d33nlHngY2cnn00UeFEELY7XZRVlYm0tPThVqtFrNnzxabNm0S\nN2/eDHLpPfNUv1u3bonS0lKxbNkyodFoREJCgliwYIH41a9+JW7cuBHs4nuUlpbmtm4qlUqefhrO\n7eepfuHcfrdv3xbFxcVi3rx5IjExUajVapGWlibWr18v2tvb5f18aT+/3VqBiIhCW1Bn6RAR0eRh\n4BMRKQQDn4hIIRj4REQKwcAnIlIIBj4RkUL8P5atFVUvsqpOAAAAAElFTkSuQmCC\n", | |
"text": [ | |
"<matplotlib.figure.Figure at 0x105742a90>" | |
] | |
} | |
], | |
"prompt_number": 29 | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Now define the chi^2 function to be minimzed. " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"def chi_errxy(a,x,unc_x,y,unc_y):\n", | |
" numer = (y-(a[0]+a[1]*x))**2\n", | |
" denom = unc_y**2 + (a[1]*unc_x)**2\n", | |
" chi2=numer/denom\n", | |
" return(chi2.sum())\n" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 21 | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"and pass it to scipy.optimize.minimize" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"spo.minimize(chi_errxy,[1.5,1.2],args=(xi,x_unc,ci,obs_unc))" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 27, | |
"text": [ | |
" status: 0\n", | |
" success: True\n", | |
" njev: 9\n", | |
" nfev: 36\n", | |
" fun: 8.446592441153806\n", | |
" x: array([ 1.16276895, 1.41272227])\n", | |
" message: 'Optimization terminated successfully.'\n", | |
" hess: array([[ 0.81804591, -0.10377374],\n", | |
" [-0.10377374, 0.03095001]])\n", | |
" jac: array([ 1.19209290e-07, -1.19209290e-07])" | |
] | |
} | |
], | |
"prompt_number": 27 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [] | |
} | |
], | |
"metadata": {} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment