Return total standard deviation as described in paragraph 5.2 pag 200.
768471
def _get_stddevs(self, C, stddev_types, num_sites):

        

        # interevent stddev
        sigma_inter = C['tau'] + np.zeros(num_sites)
        # intraevent std
        sigma_intra = C['sigma'] + np.zeros(num_sites)
        std = []

        for stddev_type in stddev_types:
            if stddev_type == const.StdDev.TOTAL:
                # equation in section 5.2 page 200
                std += [np.sqrt(sigma_intra**2 + sigma_inter**2)]
            elif stddev_type == const.StdDev.INTRA_EVENT:
                std.append(sigma_intra)
            elif stddev_type == const.StdDev.INTER_EVENT:
                std.append(sigma_inter)

        return std
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
1228031
def _compute_std_dev(self, X):
        """"""

        self._sigma = []
        if X.shape[0] <= 1:
            self._sigma = [0.0]
        else:
            for x_mean in range(X.shape[0]):
                std_dev = np.sqrt(sum([np.linalg.norm(x - x_mean) ** 2 for x in X]) / float(X.shape[0]-1))
                self._sigma.append(std_dev)

        return self._sigma
1097799
def pstdev(data):
        """"""
        n = len(data)
        if n < 2:
            return 0
            # raise ValueError('variance requires at least two data points')
        ss = TableExtraction._ss(data)
        pvar = ss/n # the population variance
        return pvar**0.5
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
419283
def total_coverage(self):
        ''''''
        if 'COV' in self.FORMAT:
            return sum([int(x) for x in self.FORMAT['COV'].split(',')])
        else:
            return None
942912
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
        
        assert all(stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
                   for stddev_type in stddev_types)

        C = self.COEFFS[imt]
        mean = self._compute_mean(C, rup.mag, dists.rjb)
        stddevs = self._compute_stddevs(C, rup.mag, dists.rjb, imt,
                                        stddev_types)

        # apply decay factor for 3 and 4 seconds (not originally supported
        # by the equations)
        if imt.period == 3.0:
            mean /= 0.612
        if imt.period == 4.0:
            mean /= 0.559

        return mean, stddevs
566270
def standard_deviation(lengths = nil)
      if lengths.nil?
        lengths = @lengths.map { |x| Array.new(x[1], x[0]) }.flatten
      end

      cluster_mean = mean
      std_deviation = 0
      lengths.each do |len|
        std_deviation += (cluster_mean - len) * (cluster_mean - len)
      end
      std_deviation = Math.sqrt(std_deviation.to_f / (lengths.length - 1))
    end
669550
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)

        if self.DEFINED_FOR_INTENSITY_MEASURE_COMPONENT == 'Random horizontal':
            # Using equation 8 of the paper,
            # corrected as indicated in the erratum
            Sr = np.sqrt(C['SlZ']**2 + (C['S3']/np.sqrt(2))**2)
        else:
            Sr = C['SlZ']

        stddevs = [np.zeros(num_sites) + Sr for _ in stddev_types]
        return stddevs
1183718
def get_stddevs(self, mean, stddev_types):
        
        mean = np.exp(mean)
        sigma = 0.39 + np.zeros(mean.shape)
        sigma[mean < 0.068] = 0.55
        idx = np.logical_and(mean >= 0.068, mean <= 0.21)
        sigma[idx] = 0.173- 0.140 * np.log(mean[idx])
        stddevs = []
        for stddev in stddev_types:
            if stddev == const.StdDev.TOTAL:
                stddevs.append(sigma)
        return stddevs
8174
def postproc (stats_result):
    
    n, mean, scat = stats_result
    mean *= 180 / np.pi # rad => deg
    scat /= n # variance-of-samples => variance-of-mean
    scat **= 0.5 # variance => stddev
    scat *= 180 / np.pi # rad => deg
    return mean, scat
1251810
def _get_stddevs(self, stddev_types, rrup):
        
        assert all(stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
                   for stddev_type in stddev_types)
        std = np.zeros_like(rrup)
        std[rrup <= 20] = 0.23
        idx = (rrup > 20) & (rrup <= 30)
        std[idx] = 0.23 - 0.03 * np.log10(rrup[idx] / 20) / np.log10(30. / 20.)
        std[rrup > 30] = 0.20
        # convert from log10 to ln
        std = np.log(10 ** std)
        return [std for stddev_type in stddev_types]
198164
def _get_stddevs(self, stddev_types, pgv):
        
        assert all(stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
                   for stddev_type in stddev_types)
        std = np.zeros_like(pgv)
        std[pgv <= 25] = 0.20
        idx = (pgv > 25) & (pgv <= 50)
        std[idx] = 0.20 - 0.05 * (pgv[idx] - 25) / 25
        std[pgv > 50] = 0.15
        # convert from log10 to ln
        std = np.log(10 ** std)
        return [std for stddev_type in stddev_types]
245561
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
        
        assert all(stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
                   for stddev_type in stddev_types)

        # extract dictionaries of coefficients specific to required
        # intensity measure type
        C = self.COEFFS[imt]

        # Deltas for Tectonic Region Type and rake angles
        delta_R, delta_S, delta_V, delta_I = self._get_deltas(rup.rake)

        mean = self._compute_mean(C, rup.mag, dists.rrup, rup.hypo_depth,
                                  delta_R, delta_S, delta_V, delta_I,
                                  sites.vs30)

        stddevs = self._get_stddevs(C, stddev_types, sites.vs30.size)

        return mean, stddevs
461994
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
        
        mean = self._get_mean(sites, rup, dists, imt, stddev_types)
        stddevs = [np.ones(len(dists.rrup))*get_sigma(imt)]
        return mean, stddevs
1166730
def _get_stddevs(self, C, mag, stddev_types, num_sites):
        
        std = C['c16'] + np.zeros(num_sites)

        if mag < 7.4:
            std -= 0.07 * mag
        else:
            std -= 0.518

        # only the 'total' standard deviation is supported, therefore the
        # std is always the same for all types
        stddevs = [std for _ in stddev_types]

        return stddevs
378070
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
        
        C = self.COEFFS[imt]
        # Get the mean
        mean = self.get_mean(C, rup, sites, dists)
        if imt.name == "PGV":
            # Convert from log10 m/s to ln cm/s
            mean = np.log((10.0 ** mean) * 100.)
        else:
            # convert from log10 m/s/s to ln g
            mean = np.log((10.0 ** mean) / g)

        # Get the standard deviations
        stddevs = self.get_stddevs(C, mean.shape, stddev_types)
        return mean, stddevs