mailr4781 - in /branches/N_state_model: ./ generic_fns/palmer.py maths_fns/chi2.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on January 16, 2008 - 12:05:
Author: bugman
Date: Wed Jan 16 12:05:48 2008
New Revision: 4781

URL: http://svn.gna.org/viewcvs/relax?rev=4781&view=rev
Log:
Merged revisions 4759-4780 via svnmerge from 
svn+ssh://bugman@xxxxxxxxxxx/svn/relax/1.3

........
  r4759 | semor | 2008-01-15 19:11:09 +0100 (Tue, 15 Jan 2008) | 8 lines
  
  Changed the precision for gX in the mfpar file for use of ModelFree with 
the palmer.py script.
  
  The change was from a three decimal precision (-2.713) to a four decimal 
precision (-2.7126).
  
  This was discussed in thread starting at:
  https://mail.gna.org/public/relax-devel/2008-01/msg00040.html
........
  r4778 | bugman | 2008-01-16 11:30:55 +0100 (Wed, 16 Jan 2008) | 3 lines
  
  Converted the maths_fns.chi2 module from Numeric to numpy.
........
  r4779 | bugman | 2008-01-16 12:00:28 +0100 (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 12:04:34 +0100 (Wed, 16 Jan 2008) | 3 lines
  
  Added a module docstring to the chi2 module.
........

Modified:
    branches/N_state_model/   (props changed)
    branches/N_state_model/generic_fns/palmer.py
    branches/N_state_model/maths_fns/chi2.py

Propchange: branches/N_state_model/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: branches/N_state_model/generic_fns/palmer.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/N_state_model/generic_fns/palmer.py?rev=4781&r1=4780&r2=4781&view=diff
==============================================================================
--- branches/N_state_model/generic_fns/palmer.py (original)
+++ branches/N_state_model/generic_fns/palmer.py Wed Jan 16 12:05:48 2008
@@ -388,7 +388,7 @@
         file.write('%-14s' % "constants")
         file.write('%-6i' % relax_data_store.res[self.run][i].num)
         file.write('%-7s' % self.nucleus)
-        file.write('%-8.3f' % (relax_data_store.gx / 1e7))
+        file.write('%-8.4f' % (relax_data_store.gx / 1e7))
         file.write('%-8.3f' % (relax_data_store.res[self.run][i].r * 1e10))
         file.write('%-8.3f\n' % (relax_data_store.res[self.run][i].csa * 
1e6))
 

Modified: branches/N_state_model/maths_fns/chi2.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/N_state_model/maths_fns/chi2.py?rev=4781&r1=4780&r2=4781&view=diff
==============================================================================
--- branches/N_state_model/maths_fns/chi2.py (original)
+++ branches/N_state_model/maths_fns/chi2.py Wed Jan 16 12:05:48 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.




Related Messages


Powered by MHonArc, Updated Wed Jan 16 16:00:15 2008