Author: semor Date: Wed Jan 16 17:31:11 2008 New Revision: 4795 URL: http://svn.gna.org/viewcvs/relax?rev=4795&view=rev Log: Merged revisions 4778-4780,4785,4787,4792 via svnmerge from svn+ssh://semor@xxxxxxxxxxx/svn/relax/1.3 ........ r4778 | bugman | 2008-01-16 05:30:55 -0500 (Wed, 16 Jan 2008) | 3 lines Converted the maths_fns.chi2 module from Numeric to numpy. ........ r4779 | bugman | 2008-01-16 06:00:28 -0500 (Wed, 16 Jan 2008) | 5 lines Updated the docstrings of the chi-squared value, gradient, and Hessian functions. They are now in epydoc format. ........ r4780 | bugman | 2008-01-16 06:04:34 -0500 (Wed, 16 Jan 2008) | 3 lines Added a module docstring to the chi2 module. ........ r4785 | semor | 2008-01-16 10:08:42 -0500 (Wed, 16 Jan 2008) | 5 lines Corrected a function spacing so it has 2 preceding empty lines. This was pointed by the 'code_validator' script. ........ r4787 | bugman | 2008-01-16 10:37:07 -0500 (Wed, 16 Jan 2008) | 3 lines Shifted all the dummy return_conversion_factor() methods which return 1 into the base class. ........ r4792 | bugman | 2008-01-16 11:01:15 -0500 (Wed, 16 Jan 2008) | 3 lines Temporarily shifted the model-free code from using the 'minimise' directory to using minfx. ........ Modified: branches/consistency_tests_1.3/ (props changed) branches/consistency_tests_1.3/maths_fns/chi2.py branches/consistency_tests_1.3/specific_fns/base_class.py branches/consistency_tests_1.3/specific_fns/jw_mapping.py branches/consistency_tests_1.3/specific_fns/model_free/mf_minimise.py branches/consistency_tests_1.3/specific_fns/noe.py branches/consistency_tests_1.3/specific_fns/relax_fit.py Propchange: branches/consistency_tests_1.3/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Wed Jan 16 17:31:11 2008 @@ -1,1 +1,1 @@ -/1.3:1-3320,3333-4175,4223,4241-4335,4338-4433,4440-4461,4473,4476-4493,4523-4551,4567-4577,4579,4585-4586,4618-4623,4659,4662-4693,4698-4759 +/1.3:1-3320,3333-4175,4223,4241-4335,4338-4433,4440-4461,4473,4476-4493,4523-4551,4567-4577,4579,4585-4586,4618-4623,4659,4662-4693,4698-4759,4778-4792 Modified: branches/consistency_tests_1.3/maths_fns/chi2.py URL: http://svn.gna.org/viewcvs/relax/branches/consistency_tests_1.3/maths_fns/chi2.py?rev=4795&r1=4794&r2=4795&view=diff ============================================================================== --- branches/consistency_tests_1.3/maths_fns/chi2.py (original) +++ branches/consistency_tests_1.3/maths_fns/chi2.py Wed Jan 16 17:31:11 2008 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2003, 2004 Edward d'Auvergne # +# Copyright (C) 2003, 2004, 2008 Edward d'Auvergne # # # # This file is part of the program relax. # # # @@ -20,9 +20,10 @@ # # ############################################################################### +"""Module containing functions for calculating the chi-squared value, gradient, and Hessian.""" # Python module imports. -from Numeric import Float64, sum, transpose, zeros +from numpy import sum # Chi-squared value. @@ -33,19 +34,29 @@ """Function to calculate the chi-squared value. The chi-sqared equation - ~~~~~~~~~~~~~~~~~~~~~~~ - _n_ - \ (yi - yi()) ** 2 - Chi2 = > ---------------- - /__ sigma_i ** 2 - i=1 + ======================= + + _n_ + \ (yi - yi(theta)) ** 2 + chi^2(theta) = > --------------------- + /__ sigma_i ** 2 + i=1 where: + theta is the parameter vector. yi are the values of the measured data set. - yi() are the values of the back calculated data set. + yi(theta) are the values of the back calculated data set. sigma_i are the values of the error set. - The chi-squared value is returned. + + @param data: The vector of yi values. + @type data: numpy array + @param back_calc_vals: The vector of yi(theta) values. + @type back_calc_vals: numpy array + @param errors: The vector of sigma_i values. + @type errors: numpy array + @return: The chi-squared value. + @rtype: float """ # Calculate the chi-squared statistic. @@ -60,19 +71,31 @@ """Function to create the chi-squared gradient. The chi-sqared gradient - ~~~~~~~~~~~~~~~~~~~~~~~ - _n_ - dChi2 \ / yi - yi() dyi() \ - ------- = -2 > | ---------- . ------- | - dthetaj /__ \ sigma_i**2 dthetaj / - i=1 + ======================= + + _n_ + dchi^2(theta) \ / yi - yi(theta) dyi(theta) \ + ------------- = -2 > | -------------- . ---------- | + dthetaj /__ \ sigma_i**2 dthetaj / + i=1 where: + theta is the parameter vector. yi are the values of the measured data set. - yi() are the values of the back calculated data set. + yi(theta) are the values of the back calculated data set. + dyi(theta)/dthetaj are the values of the back calculated gradient. sigma_i are the values of the error set. - The chi-squared gradient vector is returned. + @param data: The vector of yi values. + @type data: numpy array + @param back_calc_vals: The vector of yi(theta) values. + @type back_calc_vals: numpy array + @param back_calc_grad: The matrix of dyi(theta)/dthetaj values. + @type back_calc_grad: numpy matrix + @param errors: The vector of sigma_i values. + @type errors: numpy array + @return: The chi-squared gradient. + @rtype: numpy array """ # Calculate the chi-squared gradient. @@ -87,17 +110,37 @@ """Function to create the chi-squared Hessian. The chi-squared Hessian - ~~~~~~~~~~~~~~~~~~~~~~~ + ======================= + _n_ - d2chi2 \ 1 / dyi() dyi() d2yi() \ - --------------- = 2 > ---------- | ------- . ------- - (yi - yi()) . --------------- | - dthetaj.dthetak /__ sigma_i**2 \ dthetaj dthetak dthetaj.dthetak / + d2chi^2(theta) \ 1 / dyi(theta) dyi(theta) d2yi(theta) \ + --------------- = 2 > ---------- | ---------- . ---------- - (yi-yi(theta)) . --------------- | + dthetaj.dthetak /__ sigma_i**2 \ dthetaj dthetak dthetaj.dthetak / i=1 where: + theta is the parameter vector. yi are the values of the measured relaxation data set. - yi() are the values of the back calculated relaxation data set. + yi(theta) are the values of the back calculated relaxation data set. + dyi(theta)/dthetaj are the values of the back calculated gradient. + d2yi(theta)/dthetaj.dthetak are the values of the back calculated Hessian. sigma_i are the values of the error set. + + + @param data: The vector of yi values. + @type data: numpy array + @param back_calc_vals: The vector of yi(theta) values. + @type back_calc_vals: numpy array + @param back_calc_grad_j: The matrix of dyi(theta)/dthetaj values. + @type back_calc_grad_j: numpy matrix + @param back_calc_grad_k: The matrix of dyi(theta)/dthetak values. + @type back_calc_grad_k: numpy matrix + @param back_calc_hess: The 3rd rank tensor of d2yi(theta)/dthetaj.dthetak values. + @type back_calc_hess: numpy matrix + @param errors: The vector of sigma_i values. + @type errors: numpy array + @return: The chi-squared Hessian. + @rtype: numpy 3rd rank tensor """ # Calculate the chi-squared Hessian. Modified: branches/consistency_tests_1.3/specific_fns/base_class.py URL: http://svn.gna.org/viewcvs/relax/branches/consistency_tests_1.3/specific_fns/base_class.py?rev=4795&r1=4794&r2=4795&view=diff ============================================================================== --- branches/consistency_tests_1.3/specific_fns/base_class.py (original) +++ branches/consistency_tests_1.3/specific_fns/base_class.py Wed Jan 16 17:31:11 2008 @@ -70,6 +70,12 @@ def overfit_deselect(self): """Dummy function, nornally for deselecting spins with insufficient data for minimisation.""" + + + def return_conversion_factor(self, stat_type): + """Dummy function for returning 1.0.""" + + return 1.0 def return_data(self, spin): Modified: branches/consistency_tests_1.3/specific_fns/jw_mapping.py URL: http://svn.gna.org/viewcvs/relax/branches/consistency_tests_1.3/specific_fns/jw_mapping.py?rev=4795&r1=4794&r2=4795&view=diff ============================================================================== --- branches/consistency_tests_1.3/specific_fns/jw_mapping.py (original) +++ branches/consistency_tests_1.3/specific_fns/jw_mapping.py Wed Jan 16 17:31:11 2008 @@ -272,12 +272,6 @@ continue - def return_conversion_factor(self, stat_type): - """Dummy function for returning 1.0.""" - - return 1.0 - - def return_data_name(self, name): """ Reduced spectral density mapping data type string matching patterns Modified: branches/consistency_tests_1.3/specific_fns/model_free/mf_minimise.py URL: http://svn.gna.org/viewcvs/relax/branches/consistency_tests_1.3/specific_fns/model_free/mf_minimise.py?rev=4795&r1=4794&r2=4795&view=diff ============================================================================== --- branches/consistency_tests_1.3/specific_fns/model_free/mf_minimise.py (original) +++ branches/consistency_tests_1.3/specific_fns/model_free/mf_minimise.py Wed Jan 16 17:31:11 2008 @@ -31,13 +31,14 @@ from float import isNaN, isInf from generic_fns.selection import spin_loop from maths_fns.mf import Mf -from minimise.generic import generic_minimise +from minfx.generic import generic_minimise from relax_errors import RelaxError, RelaxInfError, RelaxLenError, RelaxNaNError, RelaxNoModelError, RelaxNoPdbError, RelaxNoResError, RelaxNoSequenceError, RelaxNoTensorError, RelaxNoValueError, RelaxNoVectorsError, RelaxNucleusError class Mf_minimise: """Class containing functions specific to model-free optimisation.""" + def back_calc(self, run=None, index=None, ri_label=None, frq_label=None, frq=None): """Back-calculation of relaxation data from the model-free parameter values.""" Modified: branches/consistency_tests_1.3/specific_fns/noe.py URL: http://svn.gna.org/viewcvs/relax/branches/consistency_tests_1.3/specific_fns/noe.py?rev=4795&r1=4794&r2=4795&view=diff ============================================================================== --- branches/consistency_tests_1.3/specific_fns/noe.py (original) +++ branches/consistency_tests_1.3/specific_fns/noe.py Wed Jan 16 17:31:11 2008 @@ -231,12 +231,6 @@ data.noe_err = None - def return_conversion_factor(self, stat_type): - """Dummy function for returning 1.0.""" - - return 1.0 - - def return_data_name(self, name): """ NOE calculation data type string matching patterns Modified: branches/consistency_tests_1.3/specific_fns/relax_fit.py URL: http://svn.gna.org/viewcvs/relax/branches/consistency_tests_1.3/specific_fns/relax_fit.py?rev=4795&r1=4794&r2=4795&view=diff ============================================================================== --- branches/consistency_tests_1.3/specific_fns/relax_fit.py (original) +++ branches/consistency_tests_1.3/specific_fns/relax_fit.py Wed Jan 16 17:31:11 2008 @@ -883,12 +883,6 @@ self.relax.generic.intensity.read(run=run, file=file, dir=dir, format=format, heteronuc=heteronuc, proton=proton, int_col=int_col, assign_func=self.assign_function) - def return_conversion_factor(self, stat_type): - """Dummy function for returning 1.0.""" - - return 1.0 - - def return_data(self, run, i): """Function for returning the peak intensity data structure."""