hLinearFitPolynomialX(vecout, xvec, powers)
Calculate the -value vector for the polynomial (linear-fitting) routine, calculating essentially all powers of the input vector.
Parameters
vecout Output vector containing rows with all the requested powers of the -vector. Size is (n+1)*len(xvec), where n=len(powers).
xvec Input vector with -values for the fitting routine.
powers Input vector with the powers to consider in the fitting. For an nth order polynomial, this is simply [0,1,2,...,n].
Description
n is the number of powers of the polynomial to fit, i.e. len(powers). The length of the output vector is the length of xvec*(n+1).
See also
Example
[x_0,x_1,x_2,...] -> [0,x_0,x_0^2,...,x_0^n,0,x_1,x_1^2,...,x_1^n]
hBSplineFitXValues(vecout, xvec, Ncoeffs, xmin, xmax, k)
Calculate the -value vector for the basis Spline (BSpline) fitting routine, calculating essentially all powers of the input vector.
Parameters
vecout Output vector containing rows with all the requested powers of the -vector. Size is Ncoeffs * len(xvec).
xvec Input vector with -values for the fitting routine.
Ncoeffs Number of coefficients to calculate. xmin Lower end of the -range for calculation of break points.
xmax Upper end of the -range for calculation of break points.
k Order of polynomial to fit locally, e.g. k=4 is a 3rd order polynomial.
Description
Note: for k=2 you get a linear fit.
See also
hBSplineFit(), hBSplineCalc(), hBSpline(), hBSplineFitXValues(), hBSplineCalcAdd(), hBSplineCalcMul()
hBSpline(vecout, xvec, coeffs, k)
Calculate the -value vector of the results of a basis Spline fit, providing the powers of
as input.
Parameters
vecout Output vector containing the -values for the input vector
-values.
xvec Input vector of Ndata*Ncoeffs -values produced with hBSplineFitXValues(). Size is Ncoeffs*len(xvec).
coeffs Input vector with the coefficients calculated by the fitting routine. k Order of polynomial to fit locally, e.g. k=4 is a 3rd order polynomial.
See also
hBSplineFit(), hBSplineCalc(), hBSpline(), hBSplineFitXValues(), hBSplineCalcAdd(), hBSplineCalcMul()
hBSplineCalcMul(vecout, xvec, coeffs, xmin, xmax, k)
Calculate the -values of the results of a basis Spline fit and Mul to the output vector.
Parameters
vecout Output vector containing the -values for the input vector
-values.
xvec Input vector with -values.
coeffs Input vector with the number of coefficients calculated by the fitting routine. xmin Lower limit of interval where spline is defined. xmax Upper limit of interval where spline is defined. k Order of polynomial to fit locally, e.g. k=4 is 3rd order polynomial.
See also
hBSplineFit(), hBSpline(), hBSplineFitXValues(), hBSplineCalc(), hBSplineCalcAdd(), hBSplineCalcMul()
hBSplineCalcAdd(vecout, xvec, coeffs, xmin, xmax, k)
Calculate the -values of the results of a basis Spline fit and Add to the output vector.
Parameters
vecout Output vector containing the -values for the input vector
-values.
xvec Input vector with -values.
coeffs Input vector with the number of coefficients calculated by the fitting routine. xmin Lower limit of interval where spline is defined. xmax Upper limit of interval where spline is defined. k Order of polynomial to fit locally, e.g. k=4 is 3rd order polynomial.
See also
hBSplineFit(), hBSpline(), hBSplineFitXValues(), hBSplineCalc(), hBSplineCalcAdd(), hBSplineCalcMul()
hBSplineCalcAssign(vecout, xvec, coeffs, xmin, xmax, k)
Calculate the -values of the results of a basis Spline fit and Assign to the output vector.
Parameters
vecout Output vector containing the -values for the input vector
-values.
xvec Input vector with -values.
coeffs Input vector with the number of coefficients calculated by the fitting routine. xmin Lower limit of interval where spline is defined. xmax Upper limit of interval where spline is defined. k Order of polynomial to fit locally, e.g. k=4 is 3rd order polynomial.
See also
hBSplineFit(), hBSpline(), hBSplineFitXValues(), hBSplineCalc(), hBSplineCalcAdd(), hBSplineCalcMul()
hBSplineCalc(vecout, xvec, coeffs, xmin, xmax, k)
Calculate the -values of the results of a basis Spline fit and assign to the output vector.
Parameters
vecout Output vector containing the -values for the input vector
-values.
xvec Input vector with -values.
coeffs Input vector with the number of coefficients calculated by the fitting routine. xmin Lower limit of interval where spline is defined. xmax Upper limit of interval where spline is defined. k Order of polynomial to fit locally, e.g. k=4 is a 3rd order polynomial.
See also
hBSplineFit(), hBSpline(), hBSplineFitXValues(), hBSplineCalc(), hBSplineCalcAdd(), hBSplineCalcMul()
hBSplineFit(vecout, veccov, xmatrix, xvec, yvec, xmin, xmax, k)
Do a basis spline fit to a data set (without weights) and return the coefficients and covariance matrix in two vectors.
Parameters
vecout Output vector containing the bets fit coefficients of the polynomial
. The first element is
, i.e. the constant. Its length determines the order of the polynomial.
veccov Output vector of length containing the covariance matrix of the fit.
xmatrix Output vector containing the -values of the data, where each value is actually one row of ncoeff values some power of
. Calculated with hBSplineFitXValues().
xvec Vector containing the values of the data.
yvec Vector containing the values of the data.
xmin Lower limit of interval where spline is defined. xmax Upper limit of interval where spline is defined. k Order of polynomial to fit locally, e.g. k=4 is a 3rd order polynomial.
Description
Returns the value of the fit.
See also
hBSplineFit(), hBSpline(), hBSplineFitXValues(), hBSplineCalcAssign(), hBSplineCalcAdd(), hBSplineCalcMul()
hPolynomial(vecout, xvec, coeff, powers)
Calculates a polynomial from a vector of -values, coefficients, and powers writing it to the output vector.
Parameters
vecout Output vector containing the polynomial -values.
xvec Input vector with -values.
coeff Coefficients for each power in powers. powers Input vector with the powers to take into account. For an n-th order polynomial, this is simply [0,1,2,...,n].
Usage
xvec=[x_0,x_1,x_2,...],powers=[0,1,2,....],coeff=[C_0,C_1,C_2,...]:
vecout.polynmomial(xvec,coeff,powers) -> [sum(C_0,C_1*x_0,C_2*x_0**2,...),sum(C_0,C_1*x_1,C_2*x_1**2,...,C_n*x_1**n),...]
See also
hLinearFit(), hLinearFitPolynomialX(), hPolynomialAdd(), hPolynomialMul()
hPolynomialMul(vecout, xvec, coeff, powers)
Calculates a polynomial from a vector of -values, coefficients, and powers multiplies it to the output vector.
Parameters
vecout Output vector containing the polynomial -values.
xvec Input vector with -values.
coeff Coefficients for each power in powers. powers Input vector with the powers to take into account. For an n-th order polynomial, this is simply [0,1,2,...,n].
Description
Same as hPolynomialMul(), but multiply result to the output (i.e., use *=). So, for a first iteration vecout has to be filled with 1.
Usage
vecout.polynmomialmul(xvec,coeff,powers) -> vecout_0 *= [sum(C_0,C_1*x_0,C_2*x_0**2,...,C_n*x_0**n),sum(C_0,C_1*x_1,C_2*x_1**2,...,C_n*x_1**n),...]
xvec=[x_0,x_1,x_2,...],powers=[0,1,2,....],coeff=[C_0,C_1,C_2,...]
See also
hLinearFit(), hLinearFitPolynomialX(), hPolynomialAdd(), hPolynomialMul(), hPolynomial()
hPolynomialAdd(vecout, xvec, coeff, powers)
Calculates a polynomial from a vector of xvalues, coefficients, and powers and adds it to the output vector.
Parameters
vecout Output vector containing the polynomial y-values. xvec Input vector with x-values. coeff Coefficients for each power in powers. powers Input vector with the powers to take into account. For an n-th order polynomial, this is simply [0,1,2,...,n].
Description
Same as hPolynomialMul(), but add result to the output (i.e., use +=). So, for a first iteration vecout has to be filled with 1.
Usage
vecout.polynmomialadd(xvec,coeff,powers) -> vecout += [sum(C_0,C_1*x_0,C_2*x_0**2,...),sum(C_0,C_1*x_1,C_2*x_1**2,...,C_n*x_1**n),...]
xvec=[x_0,x_1,x_2,...],powers=[0,1,2,....],coeff=[C_0,C_1,C_2,...]
See also
hLinearFit(), hLinearFitPolynomialX(), hPolynomialAdd(), hPolynomialMul(), hPolynomial()
hErrorsToWeights(vecout, vecin)
Calculates a weight factor from an error for a fitting routine, i.e. w=1/Error^2.
Parameters
vecout Output vector containing the weights. vecin Input vector with errorvalues.
See also
hLinearFit(), hLinearFitPolynomialX(), hPolynomial()
Example
[x_0,x_1,x_2,...] -> [1/x_0^2,1/x_1^2,...]
hLinearFit(vecout, veccov, xvec, yvec, wvec, ndata)
Do a linear fit (e.g. to an n-th order polynomial) to a data set provided a vector of weights and return the coefficients and covariance matrix in two vectors.
Parameters
vecout Output vector containing the bets fit coefficients of the polynomial
). The first element is
, i.e. the constant. Its length determines the order of the polynomial.
veccov Output vector of length containing the covariance matrix of the fit.
xvec Vector containing the -values of the data, where each value is actually one row of
values of
(e.g., if
-values are [2,3] => xvec=[0,2,4,0,3,9] for a quadratic polynomical (
)).
yvec Vector containing the -values of the data.
wvec Vector containing the weights of the data (which are 1/Error^2). ndata Number of data points to take into account (ndata=-1 -> take all elements in yvec; if ndata > 0 only take the first ndata).
Description
Returns as function value the value of the fit.
See also
hLinearFitPolynomialX(), hPolynomial()
hLinearFit(vecout, veccov, xvec, yvec, ndata)
Do a linear fit (e.g. to an n-th order polynomial) to a data set (without weights) and return the coefficients and covariance matrix in two vectors.
Parameters
vecout Output vector containing the bets fit coefficients of the polynomial
. The first element is
, i.e. the constant. Its length determines the order of the polynomial.
veccov Output vector of length containing the covariance matrix of the fit.
xvec Vector containing the -values of the data, where each value is actually one row of
values of
(e.g., if
-values are [2,3] => xvec=[0,2,4,0,3,9] for a quadratic polynomical (
)).
yvec Vector containing the -values of the data.
ndata Number of data points to take into account (ndata=-1 -> take all elements in yvec; if ndata > 0 only take the first ndata).
Description
Returns as function value the value of the fit.
See also
hLinearFit(vecout, veccov, xvec, yvec, wvec, ndata)
Do a linear fit (e.g. to an n-th order polynomial) to a data set provided a vector of weights and return the coefficients and covariance matrix in two vectors.
Parameters
vecout Output vector containing the bets fit coefficients of the polynomial
). The first element is
, i.e. the constant. Its length determines the order of the polynomial.
veccov Output vector of length containing the covariance matrix of the fit.
xvec Vector containing the -values of the data, where each value is actually one row of
values of
(e.g., if
-values are [2,3] => xvec=[0,2,4,0,3,9] for a quadratic polynomical (
)).
yvec Vector containing the -values of the data.
wvec Vector containing the weights of the data (which are 1/Error^2). ndata Number of data points to take into account (ndata=-1 -> take all elements in yvec; if ndata > 0 only take the first ndata).
Description
Returns as function value the value of the fit.
See also
hLinearFitPolynomialX(), hPolynomial()
hLinearFit(vecout, veccov, xvec, yvec, ndata)
Do a linear fit (e.g. to an n-th order polynomial) to a data set (without weights) and return the coefficients and covariance matrix in two vectors.
Parameters
vecout Output vector containing the bets fit coefficients of the polynomial
. The first element is
, i.e. the constant. Its length determines the order of the polynomial.
veccov Output vector of length containing the covariance matrix of the fit.
xvec Vector containing the -values of the data, where each value is actually one row of
values of
(e.g., if
-values are [2,3] => xvec=[0,2,4,0,3,9] for a quadratic polynomical (
)).
yvec Vector containing the -values of the data.
ndata Number of data points to take into account (ndata=-1 -> take all elements in yvec; if ndata > 0 only take the first ndata).
Description
Returns as function value the value of the fit.
See also