These modules provide basic data analysis or data fitting functionality.
Fit a line to a data set with optional weights.
Returns the parameters of the model, bo, b1: Y = b0 + b1* X
author: | |
---|---|
Nadia Dencheva | |
version: | |
‘1.0 (2007-02-20)’ |
Parameters : | |
---|---|
y: 1D numpy array :
x: 1D numpy array :
weights: 1D numpy array, must have the same shape as x and y :
|
Examples
>>> x=N.array([-5, -4 ,-3 ,-2 ,-1, 0, 1, 2, 3, 4, 5])
>>> y=N.array([1, 5, 4, 7, 10, 8, 9, 13, 14, 13, 18])
>>> around(linefit(x,y), decimals=5)
array([ 9.27273, 1.43636])
>>> x=N.array([1.3,1.3,2.0,2.0,2.7,3.3,3.3,3.7,3.7,4.,4.,4.,4.7,4.7,5.,5.3,5.3,5.3,5.7,6.,6.,6.3,6.7])
>>> y = N.array([2.3,1.8,2.8,1.5,2.2,3.8,1.8,3.7,1.7,2.8,2.8,2.2,3.2,1.9,1.8,3.5,2.8,2.1,3.4,3.2,3.,3.,5.9])
>>> around(linefit(x,y), decimals=5)
array([ 1.42564, 0.31579])
Python/Numeric version of this module was called mpfit. This version was modified to use numpy.
Module: | |
---|---|
xyinterp.py |
Interpolates y based on the given xval.
x and y are a pair of independent/dependent variable arrays that must be the same length. The x array must also be sorted. xval is a user-specified value. This routine looks up xval in the x array and uses that information to properly interpolate the value in the y array.
author: | |
---|---|
Vicki Laidler | |
version: | |
‘0.1 (2006-07-06)’ |
Purpose : | |
---|---|
Interpolates y based on the given xval. |
x and y are a pair of independent/dependent variable arrays that must be the same length. The x array must also be sorted. xval is a user-specified value. This routine looks up xval in the x array and uses that information to properly interpolate the value in the y array.
Parameters : | |
---|---|
x: 1D numpy array :
y: 1D numpy array :
xval: float :
|
|
Returns : | |
y: float :
|
|
Raises : | |
ValueError: :
:version: 0.1 last modified 2006-07-06 : |
See also
numpy
Notes
Use the searchsorted method on the X array to determine the bin in which xval falls; then use that information to compute the corresponding y value.
Return the gaussian fit of a 1D array.
Uses mpfit.py - a python implementation of the Levenberg-Marquardt least-squares minimization, based on MINPACK-1. See nmpfit.py for the history of this module (fortran -> idl -> python). nmpfit.py is a version of mpfit.py which uses numarray.
@author: Nadia Dencheva @version: ‘1.0 (2007-02-20)’
Return the gaussian fit as an object.
Parameters : | |
---|---|
y: 1D Numarray array :
x: 1D Numarray array :
err: 1D Numarray array :
weights: 1D Numarray array :
par: List :
parinfo: Dictionary of lists :
maxiter: number :
quiet: number :
|
Examples
>>> x=N.arange(10,20, 0.1)
>>> y= 10*N.e**(-(x-15)**2/4)
>>> print gfit1d(y,x=x, maxiter=20,quiet=1).params
[ 10. 15. 1.41421356]
The numcombine module serves as a limited replacement for IRAF’s ‘imcombine’ task.
A lite version of the imcombine IRAF task