Author: bugman Date: Fri Apr 19 19:53:06 2013 New Revision: 19495 URL: http://svn.gna.org/viewcvs/relax?rev=19495&view=rev Log: Merged revisions 19494 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk ........ r19494 | bugman | 2013-04-19 19:52:10 +0200 (Fri, 19 Apr 2013) | 7 lines Shifted the standard deviation code from the Monte Carlo error_analysis() function to the lib package. The new function lib.stats.std() is now used to simplify the error_analysis() function and allow the code to be reused. This will be useful for expanding the pipe_control.monte_carlo.error_analysis() function to handle parameters which are dictionaries, for example as in the relax_disp branch. ........ Added: branches/relax_disp/lib/stats.py - copied unchanged from r19494, trunk/lib/stats.py Modified: branches/relax_disp/ (props changed) branches/relax_disp/lib/__init__.py branches/relax_disp/pipe_control/monte_carlo.py Propchange: branches/relax_disp/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Fri Apr 19 19:53:06 2013 @@ -1,1 +1,1 @@ -/trunk:1-19489 +/trunk:1-19494 Modified: branches/relax_disp/lib/__init__.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/lib/__init__.py?rev=19495&r1=19494&r2=19495&view=diff ============================================================================== --- branches/relax_disp/lib/__init__.py (original) +++ branches/relax_disp/lib/__init__.py Fri Apr 19 19:53:06 2013 @@ -45,6 +45,7 @@ 'regex', 'selection', 'spectral_densities', + 'stats', 'structure', 'text', 'warnings' Modified: branches/relax_disp/pipe_control/monte_carlo.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/pipe_control/monte_carlo.py?rev=19495&r1=19494&r2=19495&view=diff ============================================================================== --- branches/relax_disp/pipe_control/monte_carlo.py (original) +++ branches/relax_disp/pipe_control/monte_carlo.py Fri Apr 19 19:53:06 2013 @@ -24,14 +24,14 @@ # Python module imports. from copy import deepcopy -from math import sqrt from numpy import ndarray from random import gauss # relax module imports. +from lib.errors import RelaxError, RelaxNoSequenceError +from lib import stats from pipe_control.mol_res_spin import exists_mol_res_spin_data from pipe_control import pipes -from lib.errors import RelaxError, RelaxNoSequenceError from specific_analyses.setup import get_specific_fn @@ -156,49 +156,9 @@ if param_array == None: break - # Simulation parameters with values (ie not None). + # SD of simulation parameters with values (ie not None). if param_array[0] != None: - # The total number of simulations. - n = 0 - for i in range(len(param_array)): - # Skip deselected simulations. - if not select_sim[i]: - continue - - # Increment n. - n = n + 1 - - # Calculate the sum of the parameter value for all simulations. - Xsum = 0.0 - for i in range(len(param_array)): - # Skip deselected simulations. - if not select_sim[i]: - continue - - # Sum. - Xsum = Xsum + param_array[i] - - # Calculate the mean parameter value for all simulations. - if n == 0: - Xav = 0.0 - else: - Xav = Xsum / float(n) - - # Calculate the sum part of the standard deviation. - sd = 0.0 - for i in range(len(param_array)): - # Skip deselected simulations. - if not select_sim[i]: - continue - - # Sum. - sd = sd + (param_array[i] - Xav)**2 - - # Calculate the standard deviation. - if n <= 1: - sd = 0.0 - else: - sd = sqrt(sd / (float(n) - 1.0)) + sd = stats.std(values=param_array, skip=select_sim) # Simulation parameters with the value None. else: