FUNCTION fit_proportional, xdata, ydata, ysigdata ; Description: This function fits a single parameter proportional model to a set of input data. ; The model used is: ; ; y = G*x ; ; where x is the independent variable, y is the dependent variable and G is the ; gradient of the proportional relationship. The function returns both the ; gradient and its uncertainty, based on the input uncertainties on the dependent ; variable. ; ; Input Parameters: ; ; xdata - FLOAT/DOUBLE VECTOR - The one dimensional vector of input data for the independent ; variable. ; ydata - FLOAT/DOUBLE VECTOR - The one dimensional vector of input data for the dependent ; variable. If this vector is not of the same length as "xdata", ; then the function will return the output vector [0.0D, -1.0D]. ; ysigdata - FLOAT/DOUBLE VECTOR - The one dimensional vector of uncertainties on the input ; data for the dependent variable. If this vector is not of ; the same length as "xdata", then the function will return ; the output vector [0.0D, -1.0D]. Any values in this vector ; which are zero or negative will cause the corresponding ; data points to be ignored in the fit. ; ; Return value: ; ; The function returns a 2-element vector of DOUBLES. The first element is the fitted gradient, ; and the second element is the uncertainty on the gradient. If the fit has failed for any ; reason, then the output vector is returned as [0.0D, -1.0D], such that the returned ; uncertainty on the gradient of -1.0 does not make sense. ; ; Author: Dan Bramich (dan.bramich@hotmail.co.uk) ; ; History: ; ; 24/04/2009 - Further module optimisation performed (dmb). ; 05/05/2008 - Module created (dmb). ;Check that "xdata", "ydata" and "ysigdata" are one dimensional vectors of the same length ;Determine the set of data points for which the uncertainties on the dependent variable are ;positive, and return a failed fit if none of the uncertainties are positive ;Calculate the gradient and its uncertainty via the optimal scaling formula. If the calculated ;gradient is infinity, then return a failed fit. ;Return the gradient and its uncertainty