Skip to content

Instantly share code, notes, and snippets.

@PBarmby
Created March 12, 2014 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PBarmby/9519225 to your computer and use it in GitHub Desktop.
Save PBarmby/9519225 to your computer and use it in GitHub Desktop.
ipython notebook for demonstrating least-squares fitting and chi^2
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"setup and load packages"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%matplotlib inline"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import scipy.stats as sps"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 2
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import numpy as np"
],
"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": "markdown",
"metadata": {},
"source": [
"Generate a set of x values"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"x = np.arange(0,5,0.1)"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 37
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now some Gaussian noise"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"gauss_noise_1 = sps.norm(loc=0,scale=0.3)"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 38
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"random_gauss_1 = gauss_noise_1.rvs(len(x))"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 39
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"random_gauss_2 = gauss_noise_1.rvs(len(x))"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 40
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"random_gauss_1"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 41,
"text": [
"array([-0.01527424, 0.90483845, -0.14772177, 0.48751598, -0.58252677,\n",
" 0.1727146 , -0.07703082, 0.17155032, 0.16298625, 0.30335679,\n",
" -0.19924831, -0.13559424, -0.28148125, -0.17440548, 0.05189903,\n",
" 0.34949444, -0.41032898, -0.44136499, -0.00962964, -0.68953672,\n",
" -0.07359837, 0.12830748, 0.20711083, 0.48446765, 0.11520149,\n",
" 0.1257288 , -0.51378533, 0.35586096, 0.10773178, 0.49506007,\n",
" 0.24545989, 0.24043002, 0.64948792, 0.1179628 , 0.22867986,\n",
" 0.30404989, -0.15652229, 0.25107982, 0.50090187, -0.53797168,\n",
" 0.00661192, -0.12039878, 0.05337592, 0.06687503, 0.04433742,\n",
" -0.46955137, -0.17347405, 0.35325241, -0.32480156, 0.35988961])"
]
}
],
"prompt_number": 41
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"random_gauss_2"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 10,
"text": [
"array([ 0.10161237, -0.0728139 , -0.21675509, 0.07686902, 0.23972285,\n",
" 0.0657801 , -0.10659676, 0.14038602, 0.22224802, 0.05252895,\n",
" -0.2215578 , -0.00246837, 0.03466819, -0.29465311, 0.04524024,\n",
" -0.22324192, 0.1550886 , 0.10407618, 0.18105872, 0.0231177 ])"
]
}
],
"prompt_number": 10
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Define y=x+noise"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"y = x+ random_gauss_1"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 42
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"plt.plot(x,y)\n",
"plt.errorbar(x,y,random_gauss_2,ls='None',marker='None',color='k')\n",
"plt.plot(x,y1(x),marker=None,lw=1,ls='solid',label='unweighted',color='k')\n",
"plt.plot(x,y2(x),marker=None,lw=3,ls='dashed',label='weighted')\n",
"plt.plot(x,x,marker=None,lw=1,ls='solid',label='y=x')\n",
"plt.legend(loc='upper left')"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 53,
"text": [
"<matplotlib.legend.Legend at 0x10799cf50>"
]
},
{
"metadata": {},
"output_type": "display_data",
"png": "iVBORw0KGgoAAAANSUhEUgAAAXgAAAEACAYAAAC57G0KAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XdcVfX/wPHXuWxBRBAURVkqmntrLtKGlV/NmeWe3yxH\n0z2w4fpmWmrDEWpmWZJZZlq/ErdirlIRFypJKooDBZmf3x/EFRAQ8FwuXN7Px+M85F7OOZ/3PV7e\n93M/5zM0pZRCCCGExTGYOwAhhBCmIQleCCEslCR4IYSwUJLghRDCQkmCF0IICyUJXgghLJTuCf7a\ntWu8+uqr+Pr6Ymdnh7u7O4899hiHDx/WuyghhBB5sNbzZNeuXaNFixacPXsWa2tratSogbW1NQcP\nHuTs2bM0bNhQz+KEEELkQdcEP2XKFM6ePYuXlxdbt27F398fgLS0NBITE/UsSgghxAPo1kSjlOKb\nb74BwNfXl169euHo6EidOnVYsmQJDg4OehUlhBAiHzS9piq4cuUKlSpVMj728PDA0dGRyMhIABYu\nXMgrr7yiR1FCCCHyQbcEHx0djZeXFwAVKlQgMjISBwcH2rZty549ewgICCA8PPxewZqmR7FCCFHq\n5Ddt69ZE4+7ujo2NDQA1a9bE0dERg8FA48aNATh//nyOQcqmmD59utljKC6bXAu5FnIt8t4KQrcE\nb2Njw2OPPQZAREQEd+7cIS0tjUOHDgHpSV8IIUTR0bUf/LvvvoudnR3Xrl3Dz88Pf39/du/ejaZp\nTJ8+Xc+ihBBCPICuCb5p06aEhobSsWNHEhISiIuLIzAwkN9//51u3brpWZRFC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ZFER0ebO7wik5iYaHz9x44dY//+/cbt4sWL5g6vSDk4\nONCvXz+qVavGhQsX+Pvvv/H29mbQoEGEhYVRtWpVc4doVqV1EaHJkyfTsWNHUlNTOXfuHL6+vvTr\n148DBw5Qq1atPI/VbaoCIYQQxYvZe9EIIYQwDUnwQghhoSTBCyGEhZIEL4QQFkoSvBBCWChJ8EII\nYaH+H5/CkCfv42kIAAAAAElFTkSuQmCC\n",
"text": [
"<matplotlib.figure.Figure at 0x1077ec0d0>"
]
}
],
"prompt_number": 53
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Do a least-squares linear fit"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"sps.linregress(x,y)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 45,
"text": [
"(1.0012842578118442,\n",
" 0.047093021680977731,\n",
" 0.97446382195943138,\n",
" 8.5576353434068425e-33,\n",
" 0.033302250906870397)"
]
}
],
"prompt_number": 45
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Look up what the fit parameters mean"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"help(sps.linregress)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Help on function linregress in module scipy.stats.stats:\n",
"\n",
"linregress(x, y=None)\n",
" Calculate a regression line\n",
" \n",
" This computes a least-squares regression for two sets of measurements.\n",
" \n",
" Parameters\n",
" ----------\n",
" x, y : array_like\n",
" two sets of measurements. Both arrays should have the same length.\n",
" If only x is given (and y=None), then it must be a two-dimensional\n",
" array where one dimension has length 2. The two sets of measurements\n",
" are then found by splitting the array along the length-2 dimension.\n",
" \n",
" Returns\n",
" -------\n",
" slope : float\n",
" slope of the regression line\n",
" intercept : float\n",
" intercept of the regression line\n",
" r-value : float\n",
" correlation coefficient\n",
" p-value : float\n",
" two-sided p-value for a hypothesis test whose null hypothesis is\n",
" that the slope is zero.\n",
" stderr : float\n",
" Standard error of the estimate\n",
" \n",
" \n",
" Examples\n",
" --------\n",
" >>> from scipy import stats\n",
" >>> import numpy as np\n",
" >>> x = np.random.random(10)\n",
" >>> y = np.random.random(10)\n",
" >>> slope, intercept, r_value, p_value, std_err = stats.linregress(x,y)\n",
" \n",
" # To get coefficient of determination (r_squared)\n",
" \n",
" >>> print \"r-squared:\", r_value**2\n",
" r-squared: 0.15286643777\n",
"\n"
]
}
],
"prompt_number": 16
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Define a function which returns the fitted value for any x"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"def y1(x):\n",
" return(0.0471+x*1.0013)"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 46
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Polyfit is another way to do these fits, can also weight by uncertainties"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"np.polyfit(x,y,1,w=1.0/random_gauss_2**2,cov=True)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 49,
"text": [
"(array([ 1.04069318, -0.1239218 ]),\n",
" array([[ 0.00442845, -0.01308322],\n",
" [-0.01308322, 0.04038001]]))"
]
}
],
"prompt_number": 49
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"help(np.polyfit)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Help on function polyfit in module numpy.lib.polynomial:\n",
"\n",
"polyfit(x, y, deg, rcond=None, full=False, w=None, cov=False)\n",
" Least squares polynomial fit.\n",
" \n",
" Fit a polynomial ``p(x) = p[0] * x**deg + ... + p[deg]`` of degree `deg`\n",
" to points `(x, y)`. Returns a vector of coefficients `p` that minimises\n",
" the squared error.\n",
" \n",
" Parameters\n",
" ----------\n",
" x : array_like, shape (M,)\n",
" x-coordinates of the M sample points ``(x[i], y[i])``.\n",
" y : array_like, shape (M,) or (M, K)\n",
" y-coordinates of the sample points. Several data sets of sample\n",
" points sharing the same x-coordinates can be fitted at once by\n",
" passing in a 2D-array that contains one dataset per column.\n",
" deg : int\n",
" Degree of the fitting polynomial\n",
" rcond : float, optional\n",
" Relative condition number of the fit. Singular values smaller than this\n",
" relative to the largest singular value will be ignored. The default\n",
" value is len(x)*eps, where eps is the relative precision of the float\n",
" type, about 2e-16 in most cases.\n",
" full : bool, optional\n",
" Switch determining nature of return value. When it is\n",
" False (the default) just the coefficients are returned, when True\n",
" diagnostic information from the singular value decomposition is also\n",
" returned.\n",
" w : array_like, shape (M,), optional\n",
" weights to apply to the y-coordinates of the sample points.\n",
" cov : bool, optional\n",
" Return the estimate and the covariance matrix of the estimate\n",
" If full is True, then cov is not returned.\n",
" \n",
" Returns\n",
" -------\n",
" p : ndarray, shape (M,) or (M, K)\n",
" Polynomial coefficients, highest power first.\n",
" If `y` was 2-D, the coefficients for `k`-th data set are in ``p[:,k]``.\n",
" \n",
" residuals, rank, singular_values, rcond : present only if `full` = True\n",
" Residuals of the least-squares fit, the effective rank of the scaled\n",
" Vandermonde coefficient matrix, its singular values, and the specified\n",
" value of `rcond`. For more details, see `linalg.lstsq`.\n",
" \n",
" V : ndaray, shape (M,M) or (M,M,K) : present only if `full` = False and `cov`=True\n",
" The covariance matrix of the polynomial coefficient estimates. The diagonal\n",
" of this matrix are the variance estimates for each coefficient. If y is a 2-d\n",
" array, then the covariance matrix for the `k`-th data set are in ``V[:,:,k]``\n",
" \n",
" \n",
" Warns\n",
" -----\n",
" RankWarning\n",
" The rank of the coefficient matrix in the least-squares fit is\n",
" deficient. The warning is only raised if `full` = False.\n",
" \n",
" The warnings can be turned off by\n",
" \n",
" >>> import warnings\n",
" >>> warnings.simplefilter('ignore', np.RankWarning)\n",
" \n",
" See Also\n",
" --------\n",
" polyval : Computes polynomial values.\n",
" linalg.lstsq : Computes a least-squares fit.\n",
" scipy.interpolate.UnivariateSpline : Computes spline fits.\n",
" \n",
" Notes\n",
" -----\n",
" The solution minimizes the squared error\n",
" \n",
" .. math ::\n",
" E = \\sum_{j=0}^k |p(x_j) - y_j|^2\n",
" \n",
" in the equations::\n",
" \n",
" x[0]**n * p[n] + ... + x[0] * p[1] + p[0] = y[0]\n",
" x[1]**n * p[n] + ... + x[1] * p[1] + p[0] = y[1]\n",
" ...\n",
" x[k]**n * p[n] + ... + x[k] * p[1] + p[0] = y[k]\n",
" \n",
" The coefficient matrix of the coefficients `p` is a Vandermonde matrix.\n",
" \n",
" `polyfit` issues a `RankWarning` when the least-squares fit is badly\n",
" conditioned. This implies that the best fit is not well-defined due\n",
" to numerical error. The results may be improved by lowering the polynomial\n",
" degree or by replacing `x` by `x` - `x`.mean(). The `rcond` parameter\n",
" can also be set to a value smaller than its default, but the resulting\n",
" fit may be spurious: including contributions from the small singular\n",
" values can add numerical noise to the result.\n",
" \n",
" Note that fitting polynomial coefficients is inherently badly conditioned\n",
" when the degree of the polynomial is large or the interval of sample points\n",
" is badly centered. The quality of the fit should always be checked in these\n",
" cases. When polynomial fits are not satisfactory, splines may be a good\n",
" alternative.\n",
" \n",
" References\n",
" ----------\n",
" .. [1] Wikipedia, \"Curve fitting\",\n",
" http://en.wikipedia.org/wiki/Curve_fitting\n",
" .. [2] Wikipedia, \"Polynomial interpolation\",\n",
" http://en.wikipedia.org/wiki/Polynomial_interpolation\n",
" \n",
" Examples\n",
" --------\n",
" >>> x = np.array([0.0, 1.0, 2.0, 3.0, 4.0, 5.0])\n",
" >>> y = np.array([0.0, 0.8, 0.9, 0.1, -0.8, -1.0])\n",
" >>> z = np.polyfit(x, y, 3)\n",
" >>> z\n",
" array([ 0.08703704, -0.81349206, 1.69312169, -0.03968254])\n",
" \n",
" It is convenient to use `poly1d` objects for dealing with polynomials:\n",
" \n",
" >>> p = np.poly1d(z)\n",
" >>> p(0.5)\n",
" 0.6143849206349179\n",
" >>> p(3.5)\n",
" -0.34732142857143039\n",
" >>> p(10)\n",
" 22.579365079365115\n",
" \n",
" High-order polynomials may oscillate wildly:\n",
" \n",
" >>> p30 = np.poly1d(np.polyfit(x, y, 30))\n",
" /... RankWarning: Polyfit may be poorly conditioned...\n",
" >>> p30(4)\n",
" -0.80000000000000204\n",
" >>> p30(5)\n",
" -0.99999999999999445\n",
" >>> p30(4.5)\n",
" -0.10547061179440398\n",
" \n",
" Illustration:\n",
" \n",
" >>> import matplotlib.pyplot as plt\n",
" >>> xp = np.linspace(-2, 6, 100)\n",
" >>> plt.plot(x, y, '.', xp, p(xp), '-', xp, p30(xp), '--')\n",
" [<matplotlib.lines.Line2D object at 0x...>, <matplotlib.lines.Line2D object at 0x...>, <matplotlib.lines.Line2D object at 0x...>]\n",
" >>> plt.ylim(-2,2)\n",
" (-2, 2)\n",
" >>> plt.show()\n",
"\n"
]
}
],
"prompt_number": 19
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"def y2(x):\n",
" return(1.0407*x-0.124)"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 50
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Does scipy.stats already have a chi^2 function? Maybe, but chi here is the chi^2 probability distribution"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"help(sps.chi)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Help on chi_gen in module scipy.stats.distributions object:\n",
"\n",
"class chi_gen(rv_continuous)\n",
" | A chi continuous random variable.\n",
" | \n",
" | %(before_notes)s\n",
" | \n",
" | Notes\n",
" | -----\n",
" | The probability density function for `chi` is::\n",
" | \n",
" | chi.pdf(x,df) = x**(df-1) * exp(-x**2/2) / (2**(df/2-1) * gamma(df/2))\n",
" | \n",
" | for ``x > 0``.\n",
" | \n",
" | %(example)s\n",
" | \n",
" | Method resolution order:\n",
" | chi_gen\n",
" | rv_continuous\n",
" | rv_generic\n",
" | __builtin__.object\n",
" | \n",
" | Methods inherited from rv_continuous:\n",
" | \n",
" | __call__(self, *args, **kwds)\n",
" | \n",
" | __init__(self, momtype=1, a=None, b=None, xa=None, xb=None, xtol=1e-14, badvalue=None, name=None, longname=None, shapes=None, extradoc=None)\n",
" | \n",
" | cdf(self, x, *args, **kwds)\n",
" | Cumulative distribution function of the given RV.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | x : array_like\n",
" | quantiles\n",
" | arg1, arg2, arg3,... : array_like\n",
" | The shape parameter(s) for the distribution (see docstring of the\n",
" | instance object for more information)\n",
" | loc : array_like, optional\n",
" | location parameter (default=0)\n",
" | scale : array_like, optional\n",
" | scale parameter (default=1)\n",
" | \n",
" | Returns\n",
" | -------\n",
" | cdf : ndarray\n",
" | Cumulative distribution function evaluated at `x`\n",
" | \n",
" | entropy(self, *args, **kwds)\n",
" | Differential entropy of the RV.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | arg1, arg2, arg3,... : array_like\n",
" | The shape parameter(s) for the distribution (see docstring of the\n",
" | instance object for more information).\n",
" | loc : array_like, optional\n",
" | Location parameter (default=0).\n",
" | scale : array_like, optional\n",
" | Scale parameter (default=1).\n",
" | \n",
" | est_loc_scale(*args, **kwds)\n",
" | `est_loc_scale` is deprecated!\n",
" | \n",
" | This function is deprecated, use self.fit_loc_scale(data) instead.\n",
" | \n",
" | expect(self, func=None, args=(), loc=0, scale=1, lb=None, ub=None, conditional=False, **kwds)\n",
" | Calculate expected value of a function with respect to the distribution\n",
" | \n",
" | Location and scale only tested on a few examples.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | func : callable, optional\n",
" | Function for which integral is calculated. Takes only one argument.\n",
" | The default is the identity mapping f(x) = x.\n",
" | args : tuple, optional\n",
" | Argument (parameters) of the distribution.\n",
" | lb, ub : scalar, optional\n",
" | Lower and upper bound for integration. default is set to the support\n",
" | of the distribution.\n",
" | conditional : bool, optional\n",
" | If True, the integral is corrected by the conditional probability\n",
" | of the integration interval. The return value is the expectation\n",
" | of the function, conditional on being in the given interval.\n",
" | Default is False.\n",
" | \n",
" | Additional keyword arguments are passed to the integration routine.\n",
" | \n",
" | Returns\n",
" | -------\n",
" | expected value : float\n",
" | \n",
" | Notes\n",
" | -----\n",
" | This function has not been checked for it's behavior when the integral is\n",
" | not finite. The integration behavior is inherited from integrate.quad.\n",
" | \n",
" | fit(self, data, *args, **kwds)\n",
" | Return MLEs for shape, location, and scale parameters from data.\n",
" | \n",
" | MLE stands for Maximum Likelihood Estimate. Starting estimates for\n",
" | the fit are given by input arguments; for any arguments not provided\n",
" | with starting estimates, ``self._fitstart(data)`` is called to generate\n",
" | such.\n",
" | \n",
" | One can hold some parameters fixed to specific values by passing in\n",
" | keyword arguments ``f0``, ``f1``, ..., ``fn`` (for shape parameters)\n",
" | and ``floc`` and ``fscale`` (for location and scale parameters,\n",
" | respectively).\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | data : array_like\n",
" | Data to use in calculating the MLEs.\n",
" | args : floats, optional\n",
" | Starting value(s) for any shape-characterizing arguments (those not\n",
" | provided will be determined by a call to ``_fitstart(data)``).\n",
" | No default value.\n",
" | kwds : floats, optional\n",
" | Starting values for the location and scale parameters; no default.\n",
" | Special keyword arguments are recognized as holding certain\n",
" | parameters fixed:\n",
" | \n",
" | f0...fn : hold respective shape parameters fixed.\n",
" | \n",
" | floc : hold location parameter fixed to specified value.\n",
" | \n",
" | fscale : hold scale parameter fixed to specified value.\n",
" | \n",
" | optimizer : The optimizer to use. The optimizer must take func,\n",
" | and starting position as the first two arguments,\n",
" | plus args (for extra arguments to pass to the\n",
" | function to be optimized) and disp=0 to suppress\n",
" | output as keyword arguments.\n",
" | \n",
" | Returns\n",
" | -------\n",
" | shape, loc, scale : tuple of floats\n",
" | MLEs for any shape statistics, followed by those for location and\n",
" | scale.\n",
" | \n",
" | fit_loc_scale(self, data, *args)\n",
" | Estimate loc and scale parameters from data using 1st and 2nd moments.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | data : array_like\n",
" | Data to fit.\n",
" | arg1, arg2, arg3,... : array_like\n",
" | The shape parameter(s) for the distribution (see docstring of the\n",
" | instance object for more information).\n",
" | \n",
" | Returns\n",
" | -------\n",
" | Lhat : float\n",
" | Estimated location parameter for the data.\n",
" | Shat : float\n",
" | Estimated scale parameter for the data.\n",
" | \n",
" | freeze(self, *args, **kwds)\n",
" | Freeze the distribution for the given arguments.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | arg1, arg2, arg3,... : array_like\n",
" | The shape parameter(s) for the distribution. Should include all\n",
" | the non-optional arguments, may include ``loc`` and ``scale``.\n",
" | \n",
" | Returns\n",
" | -------\n",
" | rv_frozen : rv_frozen instance\n",
" | The frozen distribution.\n",
" | \n",
" | isf(self, q, *args, **kwds)\n",
" | Inverse survival function at q of the given RV.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | q : array_like\n",
" | upper tail probability\n",
" | arg1, arg2, arg3,... : array_like\n",
" | The shape parameter(s) for the distribution (see docstring of the\n",
" | instance object for more information)\n",
" | loc : array_like, optional\n",
" | location parameter (default=0)\n",
" | scale : array_like, optional\n",
" | scale parameter (default=1)\n",
" | \n",
" | Returns\n",
" | -------\n",
" | x : ndarray or scalar\n",
" | Quantile corresponding to the upper tail probability q.\n",
" | \n",
" | logcdf(self, x, *args, **kwds)\n",
" | Log of the cumulative distribution function at x of the given RV.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | x : array_like\n",
" | quantiles\n",
" | arg1, arg2, arg3,... : array_like\n",
" | The shape parameter(s) for the distribution (see docstring of the\n",
" | instance object for more information)\n",
" | loc : array_like, optional\n",
" | location parameter (default=0)\n",
" | scale : array_like, optional\n",
" | scale parameter (default=1)\n",
" | \n",
" | Returns\n",
" | -------\n",
" | logcdf : array_like\n",
" | Log of the cumulative distribution function evaluated at x\n",
" | \n",
" | logpdf(self, x, *args, **kwds)\n",
" | Log of the probability density function at x of the given RV.\n",
" | \n",
" | This uses a more numerically accurate calculation if available.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | x : array_like\n",
" | quantiles\n",
" | arg1, arg2, arg3,... : array_like\n",
" | The shape parameter(s) for the distribution (see docstring of the\n",
" | instance object for more information)\n",
" | loc : array_like, optional\n",
" | location parameter (default=0)\n",
" | scale : array_like, optional\n",
" | scale parameter (default=1)\n",
" | \n",
" | Returns\n",
" | -------\n",
" | logpdf : array_like\n",
" | Log of the probability density function evaluated at x\n",
" | \n",
" | logsf(self, x, *args, **kwds)\n",
" | Log of the survival function of the given RV.\n",
" | \n",
" | Returns the log of the \"survival function,\" defined as (1 - `cdf`),\n",
" | evaluated at `x`.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | x : array_like\n",
" | quantiles\n",
" | arg1, arg2, arg3,... : array_like\n",
" | The shape parameter(s) for the distribution (see docstring of the\n",
" | instance object for more information)\n",
" | loc : array_like, optional\n",
" | location parameter (default=0)\n",
" | scale : array_like, optional\n",
" | scale parameter (default=1)\n",
" | \n",
" | Returns\n",
" | -------\n",
" | logsf : ndarray\n",
" | Log of the survival function evaluated at `x`.\n",
" | \n",
" | moment(self, n, *args, **kwds)\n",
" | n'th order non-central moment of distribution.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | n : int, n>=1\n",
" | Order of moment.\n",
" | arg1, arg2, arg3,... : float\n",
" | The shape parameter(s) for the distribution (see docstring of the\n",
" | instance object for more information).\n",
" | kwds : keyword arguments, optional\n",
" | These can include \"loc\" and \"scale\", as well as other keyword\n",
" | arguments relevant for a given distribution.\n",
" | \n",
" | nnlf(self, theta, x)\n",
" | \n",
" | pdf(self, x, *args, **kwds)\n",
" | Probability density function at x of the given RV.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | x : array_like\n",
" | quantiles\n",
" | arg1, arg2, arg3,... : array_like\n",
" | The shape parameter(s) for the distribution (see docstring of the\n",
" | instance object for more information)\n",
" | loc : array_like, optional\n",
" | location parameter (default=0)\n",
" | scale : array_like, optional\n",
" | scale parameter (default=1)\n",
" | \n",
" | Returns\n",
" | -------\n",
" | pdf : ndarray\n",
" | Probability density function evaluated at x\n",
" | \n",
" | ppf(self, q, *args, **kwds)\n",
" | Percent point function (inverse of cdf) at q of the given RV.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | q : array_like\n",
" | lower tail probability\n",
" | arg1, arg2, arg3,... : array_like\n",
" | The shape parameter(s) for the distribution (see docstring of the\n",
" | instance object for more information)\n",
" | loc : array_like, optional\n",
" | location parameter (default=0)\n",
" | scale : array_like, optional\n",
" | scale parameter (default=1)\n",
" | \n",
" | Returns\n",
" | -------\n",
" | x : array_like\n",
" | quantile corresponding to the lower tail probability q.\n",
" | \n",
" | sf(self, x, *args, **kwds)\n",
" | Survival function (1-cdf) at x of the given RV.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | x : array_like\n",
" | quantiles\n",
" | arg1, arg2, arg3,... : array_like\n",
" | The shape parameter(s) for the distribution (see docstring of the\n",
" | instance object for more information)\n",
" | loc : array_like, optional\n",
" | location parameter (default=0)\n",
" | scale : array_like, optional\n",
" | scale parameter (default=1)\n",
" | \n",
" | Returns\n",
" | -------\n",
" | sf : array_like\n",
" | Survival function evaluated at x\n",
" | \n",
" | stats(self, *args, **kwds)\n",
" | Some statistics of the given RV\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | arg1, arg2, arg3,... : array_like\n",
" | The shape parameter(s) for the distribution (see docstring of the\n",
" | instance object for more information)\n",
" | loc : array_like, optional\n",
" | location parameter (default=0)\n",
" | scale : array_like, optional\n",
" | scale parameter (default=1)\n",
" | moments : str, optional\n",
" | composed of letters ['mvsk'] defining which moments to compute:\n",
" | 'm' = mean,\n",
" | 'v' = variance,\n",
" | 's' = (Fisher's) skew,\n",
" | 'k' = (Fisher's) kurtosis.\n",
" | (default='mv')\n",
" | \n",
" | Returns\n",
" | -------\n",
" | stats : sequence\n",
" | of requested moments.\n",
" | \n",
" | ----------------------------------------------------------------------\n",
" | Methods inherited from rv_generic:\n",
" | \n",
" | interval(self, alpha, *args, **kwds)\n",
" | Confidence interval with equal areas around the median.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | alpha : array_like of float\n",
" | Probability that an rv will be drawn from the returned range.\n",
" | Each value should be in the range [0, 1].\n",
" | arg1, arg2, ... : array_like\n",
" | The shape parameter(s) for the distribution (see docstring of the\n",
" | instance object for more information).\n",
" | loc : array_like, optional\n",
" | location parameter, Default is 0.\n",
" | scale : array_like, optional\n",
" | scale parameter, Default is 1.\n",
" | \n",
" | Returns\n",
" | -------\n",
" | a, b : ndarray of float\n",
" | end-points of range that contain ``100 * alpha %`` of the rv's possible\n",
" | values.\n",
" | \n",
" | mean(self, *args, **kwds)\n",
" | Mean of the distribution\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | arg1, arg2, arg3,... : array_like\n",
" | The shape parameter(s) for the distribution (see docstring of the\n",
" | instance object for more information)\n",
" | loc : array_like, optional\n",
" | location parameter (default=0)\n",
" | scale : array_like, optional\n",
" | scale parameter (default=1)\n",
" | \n",
" | Returns\n",
" | -------\n",
" | mean : float\n",
" | the mean of the distribution\n",
" | \n",
" | median(self, *args, **kwds)\n",
" | Median of the distribution.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | arg1, arg2, arg3,... : array_like\n",
" | The shape parameter(s) for the distribution (see docstring of the\n",
" | instance object for more information)\n",
" | loc : array_like, optional\n",
" | Location parameter, Default is 0.\n",
" | scale : array_like, optional\n",
" | Scale parameter, Default is 1.\n",
" | \n",
" | Returns\n",
" | -------\n",
" | median : float\n",
" | The median of the distribution.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | stats.distributions.rv_discrete.ppf\n",
" | Inverse of the CDF\n",
" | \n",
" | rvs(self, *args, **kwds)\n",
" | Random variates of given type.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | arg1, arg2, arg3,... : array_like\n",
" | The shape parameter(s) for the distribution (see docstring of the\n",
" | instance object for more information).\n",
" | loc : array_like, optional\n",
" | Location parameter (default=0).\n",
" | scale : array_like, optional\n",
" | Scale parameter (default=1).\n",
" | size : int or tuple of ints, optional\n",
" | Defining number of random variates (default=1).\n",
" | \n",
" | Returns\n",
" | -------\n",
" | rvs : ndarray or scalar\n",
" | Random variates of given `size`.\n",
" | \n",
" | std(self, *args, **kwds)\n",
" | Standard deviation of the distribution.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | arg1, arg2, arg3,... : array_like\n",
" | The shape parameter(s) for the distribution (see docstring of the\n",
" | instance object for more information)\n",
" | loc : array_like, optional\n",
" | location parameter (default=0)\n",
" | scale : array_like, optional\n",
" | scale parameter (default=1)\n",
" | \n",
" | Returns\n",
" | -------\n",
" | std : float\n",
" | standard deviation of the distribution\n",
" | \n",
" | var(self, *args, **kwds)\n",
" | Variance of the distribution\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | arg1, arg2, arg3,... : array_like\n",
" | The shape parameter(s) for the distribution (see docstring of the\n",
" | instance object for more information)\n",
" | loc : array_like, optional\n",
" | location parameter (default=0)\n",
" | scale : array_like, optional\n",
" | scale parameter (default=1)\n",
" | \n",
" | Returns\n",
" | -------\n",
" | var : float\n",
" | the variance of the distribution\n",
" | \n",
" | ----------------------------------------------------------------------\n",
" | Data descriptors inherited from rv_generic:\n",
" | \n",
" | __dict__\n",
" | dictionary for instance variables (if defined)\n",
" | \n",
" | __weakref__\n",
" | list of weak references to the object (if defined)\n",
"\n"
]
}
],
"prompt_number": 27
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"so we define our own chi^2 function"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"def chi2_lin(x,y,unc_y,f):\n",
" chi = (y-f(x))/unc_y\n",
" chi2 = chi**2\n",
" return(chi2.sum())"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 28
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"and then evaluate it for the various fits"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"chi2_lin(x,y,random_gauss_2,y1)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 58,
"text": [
"1146.9897355522685"
]
}
],
"prompt_number": 58
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"chi2_lin(x,y,random_gauss_2,y2)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 59,
"text": [
"1262.3276543106767"
]
}
],
"prompt_number": 59
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"def y3(x):\n",
" return(x)\n"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 56
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"chi2_lin(x,y,random_gauss_2,y3)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 60,
"text": [
"1159.1015927721865"
]
}
],
"prompt_number": 60
},
{
"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