Return total standard deviation.
487021
def _get_stddevs(self, C, stddev_types, num_sites):
        
        stddevs = []
        for stddev_type in stddev_types:
            assert stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
            stddevs.append(np.log(10 ** C['sigma']) + np.zeros(num_sites))

        return stddevs
282451
function() {
			// Get the x and y coordinates
			var xCoords = this.pluck('x');
			var yCoords = this.pluck('y');

			// Get the means for the x and y coordinates
			var meanX = xCoords.mean();
			var meanY = yCoords.mean();

			// Get the standard deviations for the x and y coordinates
			var stdDevX = xCoords.stdDev();
			var stdDevY = yCoords.stdDev();

			// Map each element to the difference of the element and the mean
			// divided by the standard deviation
			xCoords.map(function(num) {
				return (num - meanX) / stdDevX;
			});
			yCoords.map(function(num) {
				return (num - meanY) / stdDevY;
			});

			// Multiply each element in the x by the corresponding value in
			// the y
			var nums = this.clone().map(function(num, index) {
				return xCoords.get(index) * yCoords.get(index);
			});

			// r is the sum of xCoords over the number of points minus 1
			return nums.sum() / (nums.size() - 1);
		}
1129318
def std(self) -> Optional[float]:  #, ddof=0):
        
        # TODO: Add DOF
        if self._stats:
            return np.sqrt(self.variance())
        else:
            return None
1266772
def _get_stddevs(self, C, rup, shape, stddev_types):
        
        weight = self._compute_weight_std(C, rup.mag)
        std_intra = weight * C["sd1"] * np.ones(shape)
        std_inter = weight * C["sd2"] * np.ones(shape)
        
        stddevs = []
        for stddev_type in stddev_types:
            assert stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
            if stddev_type == const.StdDev.TOTAL:
                stddevs.append(np.sqrt(std_intra ** 2. + std_inter ** 2.))
            elif stddev_type == const.StdDev.INTRA_EVENT:
                stddevs.append(std_intra)
            elif stddev_type == const.StdDev.INTER_EVENT:
                stddevs.append(std_inter)
        return stddevs
691473
def _get_stddevs(self, C, stddev_types, num_sites):
        
        # standard deviation is converted from log10 to ln
        std_total = np.log(10 ** C['sigma'])
        stddevs = []
        for _ in stddev_types:
            stddevs.append(np.zeros(num_sites) + std_total)

        return stddevs
678750
def calc_deviation(values, average):
    
    size = len(values)
    if size < 2:
        return 0
    calc_sum = 0.0

    for number in range(0, size):
        calc_sum += math.sqrt((values[number] - average) ** 2)
    return math.sqrt((1.0 / (size - 1)) * (calc_sum / size))
303646
def count(self):
        """"""
        if self._total_count is None:
            self._total_count = self._get_total_count()
        return self._total_count
1112025
def meanAndStdDev(self, limit=None):
        """"""
        if limit is None or len(self.values) < limit:
            limit = len(self.values)
        if limit > 0:
            mean = sum(self.values[-limit:]) / float(limit)
            sumSq = 0.
            for v in self.values[-limit:]:
                sumSq += (v - mean) * (v - mean)
            return mean, math.sqrt(sumSq / limit)
        else:
            return None
1319664
def get_mean_and_stddevs(self, sctx, rctx, dctx, imt, stddev_types):
        
        # Get original mean and standard deviations
        mean, stddevs = super().get_mean_and_stddevs(
            sctx, rctx, dctx, imt, stddev_types)
        # Return mean, increased by the adjustment factor,
        # and standard devation
        return mean + nga_west2_epistemic_adjustment(rctx.mag, dctx.rrup),\
            stddevs
1194566
def _get_stddevs(self, C, stddev_types, num_sites):
        
        assert all(stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
                   for stddev_type in stddev_types)

        # Using a frequency independent value of sigma as recommended
        # in the caption of Table 2 of Atkinson (2010)
        stddevs = [0.26/np.log10(np.e) + np.zeros(num_sites)]

        return stddevs
1355950
def _get_stddevs(self, C, stddev_types, num_sites):
        
        assert all(stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
            for stddev_type in stddev_types)
        stddevs = [np.zeros(num_sites) + C['SigmaTot'] for _ in stddev_types]
        return stddevs
514676
def _calc_dic(self):
        """"""

        # Find mean deviance
        mean_deviance = np.mean(self.db.trace('deviance')(), axis=0)

        # Set values of all parameters to their mean
        for stochastic in self.stochastics:

            # Calculate mean of paramter
            try:
                mean_value = np.mean(
                    self.db.trace(
                        stochastic.__name__)(
                    ),
                    axis=0)

                # Set current value to mean
                stochastic.value = mean_value

            except KeyError:
                print_(
                    "No trace available for %s. DIC value may not be valid." %
                    stochastic.__name__)
            except TypeError:
                print_(
                    "Not able to calculate DIC: invalid stochastic %s" %
                    stochastic.__name__)
                return None

        # Return twice deviance minus deviance at means
        return 2 * mean_deviance - self.deviance
1106855
def get_stddevs(self, C, stddev_shape, stddev_types, sites):
        
        stddevs = []
        tau = C["tau_event"]
        sigma_s = np.zeros(sites.vs30measured.shape, dtype=float)
        sigma_s[sites.vs30measured] += C["sigma_s_obs"]
        sigma_s[np.logical_not(sites.vs30measured)] += C["sigma_s_inf"]
        phi = np.sqrt(C["phi0"] ** 2.0 + sigma_s ** 2.)
        for stddev_type in stddev_types:
            assert stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
            if stddev_type == const.StdDev.TOTAL:
                stddevs.append(np.sqrt(tau ** 2. + phi ** 2.) +
                               np.zeros(stddev_shape))
            elif stddev_type == const.StdDev.INTRA_EVENT:
                stddevs.append(phi + np.zeros(stddev_shape))
            elif stddev_type == const.StdDev.INTER_EVENT:
                stddevs.append(tau + np.zeros(stddev_shape))
        return stddevs
606906
def ss_tot(self):
        """"""
        return np.sum(np.square(self.y - self.ybar), axis=0)
1362231
public double stdDev() {
        double avg = avgRate();
        double sum = 0.0;
        for (Sample s : samples) {
            sum += Math.pow((double) s.rate() - avg, 2);
        }
        double variance = sum / (double) samples.size();
        return Math.sqrt(variance);
    }
32106
def dev(self):
    """"""
    if self.num == 0:
      return 0
    return math.sqrt(max(0, self.sum_sq / self.num - (self.sum / self.num)**2))
215923
def mean(self):
    """"""
    if len(self) == 0:
      return float('NaN')
    arr = self.samples()
    return sum(arr) / float(len(arr))