map to parameters e, w, a
        :param mu: mean
        :param sigma: standard deviation
        :param skw: skewness
        :return: e, w, a
164250
def map_mu_sigma_skw(self, mu, sigma, skw):
        
        delta = self._delta_skw(skw)
        a = self._alpha_delta(delta)
        w = self._w_sigma_delta(sigma, delta)
        e = self._e_mu_w_delta(mu, w, delta)
        return e, w, a
648627
def normal_prior(value, mean, sigma):
    
    return -0.5 * (2 * np.pi * sigma) - (value - mean) ** 2 / (2.0 * sigma)
24797
def get_stddevs(self, mag, imt, stddev_types, num_sites):
        
        tau = self._get_tau(imt, mag)
        phi = self._get_phi(imt, mag)
        sigma = np.sqrt(tau ** 2. + phi ** 2.)
        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(sigma + np.zeros(num_sites))
            elif stddev_type == const.StdDev.INTRA_EVENT:
                stddevs.append(phi + np.zeros(num_sites))
            elif stddev_type == const.StdDev.INTER_EVENT:
                stddevs.append(tau + np.zeros(num_sites))
        return stddevs
960558
def _get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
        
        # distances
        distsl = copy.copy(dists)
        distsl.rjb, distsl.rrup = \
            utils.get_equivalent_distances_east(rup.mag, dists.repi)
        #
        # Pezeshk et al. 2011 - Rrup
        mean1, stds1 = super().get_mean_and_stddevs(sites, rup, distsl, imt,
                                                    stddev_types)
        mean1 = self.apply_correction_to_BC(mean1, imt, distsl)
        #
        # Atkinson 2008 - Rjb
        gmpe = Atkinson2008prime()
        mean2, stds2 = gmpe.get_mean_and_stddevs(sites, rup, distsl, imt,
                                                 stddev_types)
        #
        # Silva et al. 2002 - Rjb
        gmpe = SilvaEtAl2002SingleCornerSaturation()
        mean4, stds4 = gmpe.get_mean_and_stddevs(sites, rup, distsl, imt,
                                                 stddev_types)
        mean4 = self.apply_correction_to_BC(mean4, imt, distsl)
        #
        # Silva et al. 2002 - Rjb
        gmpe = SilvaEtAl2002DoubleCornerSaturation()
        mean5, stds5 = gmpe.get_mean_and_stddevs(sites, rup, distsl, imt,
                                                 stddev_types)
        mean5 = self.apply_correction_to_BC(mean5, imt, distsl)
        #
        # distances
        distsl.rjb, distsl.rrup = \
            utils.get_equivalent_distances_east(rup.mag, dists.repi, ab06=True)
        #
        # Atkinson and Boore 2006 - Rrup
        gmpe = AtkinsonBoore2006Modified2011()
        mean3, stds3 = gmpe.get_mean_and_stddevs(sites, rup, distsl, imt,
                                                 stddev_types)
        # Computing adjusted mean and stds
        mean_adj = mean1*0.2 + mean2*0.2 + mean3*0.2 + mean4*0.2 + mean5*0.2

        # Note that in this case we do not apply a triangular smoothing on
        # distance as explained at page 996 of Atkinson and Adams (2013)
        # for the calculation of the standard deviation
        stds_adj = np.log(np.exp(stds1)*0.2 + np.exp(stds2)*0.2 +
                          np.exp(stds3)*0.2 + np.exp(stds4)*0.2 +
                          np.exp(stds5)*0.2)
        #
        return mean_adj, stds_adj
1249996
function rnorm(mu, sigma) {
      return function() {
         var v1, v2, rsq;

         do {
            v1 = 2 * rgen.random() - 1;
            v2 = 2 * rgen.random() - 1;
            rsq = v1 * v1 + v2 * v2;
         } while (rsq >= 1);
         return mu + sigma * v1 * Math.sqrt(-2 * Math.log(rsq) / rsq);
      };
   }
626532
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
        

        # get original values
        hslab = 50  # See info in GMPEt_Inslab_med.dat
        rjb, rrup = utils.get_equivalent_distance_inslab(rup.mag, dists.repi,
                                                         hslab)
        dists.rjb = rjb
        dists.rrup = rrup
        mean, stddevs = super().get_mean_and_stddevs(sites, rup, dists, imt,
                                                     stddev_types)
        cff = self.SITE_COEFFS[imt]
        mean_adj = np.log(np.exp(mean) * 10**cff['mf'])
        stddevs = [np.ones(len(dists.rrup))*get_sigma(imt)]
        return mean_adj, stddevs
864005
def _sigmainf(N, h, m, dW, Km0, Pm0):
    """"""
    M = m*(m-1)//2
    Im = broadcast_to(np.eye(m), (N, m, m))
    IM = broadcast_to(np.eye(M), (N, M, M))
    Ims0 = np.eye(m**2)
    factor1 = broadcast_to((2.0/h)*np.dot(Km0, Ims0 - Pm0), (N, M, m**2))
    factor2 = _kp2(Im, _dot(dW, _t(dW)))
    factor3 = broadcast_to(np.dot(Ims0 - Pm0, Km0.T), (N, m**2, M))
    return 2*IM + _dot(_dot(factor1, factor2), factor3)
615885
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
        
        mean, stddevs = super().get_mean_and_stddevs(
            sites, rup, dists, imt, stddev_types)

        # this is the firm ground adjustment
        mean += np.log(1.162)

        return mean, stddevs
379393
def _gauss(mean: int, sigma: int) -> int:
        
        return int(random.gauss(mean, sigma))
1063321
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
        
        C = self.COEFFS[imt]
        C_SIG = self.SIGMA_COEFFS[imt]

        mean = (self.get_magnitude_scaling_term(C, rup.mag) +
                self.get_distance_scaling_term(C, dists.rhypo))

        std_devs = self.get_stddevs(C_SIG, stddev_types, len(dists.rhypo))

        #: Mean ground motions initially returned in cm/s/s (for PGA, SA)
        #: and cm/s for PGV
        if not imt.name == "PGV":
            # Convert mean from log(cm/s/s) to g
            mean = np.log(np.exp(mean) / (100. * g))

        return mean, std_devs
110424
def _get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types, 
        mag_conversion_sigma=0.0):
        
        # extract dictionaries of coefficients specific to required
        # intensity measure type
        C = self.COEFFS[imt]

        # clip distance at 4 km, minimum distance for which the equation is
        # valid (see section 2.2.4, page 201). This also avoids singularity
        # in the equation
        rhypo = dists.rhypo
        rhypo[rhypo < 4.] = 4.

        mean = C['a'] * rup.mag + C['b'] * rhypo - np.log10(rhypo)

        mean[sites.vs30 >= 800] += C['c1']
        mean[sites.vs30 < 800] += C['c2']

        # convert from log10 to ln, and from cm/s2 to g
        mean = mean * np.log(10) - 2 * np.log(10) - np.log(g)

        stddevs = self._get_stddevs(C, stddev_types, rhypo.shape[0], 
            mag_conversion_sigma=mag_conversion_sigma)

        return mean, stddevs
1211059
def plot_dist_normal(s, mu, sigma):
    
    import matplotlib.pyplot as plt
    count, bins, ignored = plt.hist(s, 30, normed=True)
    plt.plot(bins, 1/(sigma * np.sqrt(2 * np.pi)) \
            * np.exp( - (bins - mu)**2 / (2 * sigma**2) ), \
            linewidth = 2, color = 'r')
    plt.show()
822092
def describe(inlist):
    
    n = len(inlist)
    mm = (min(inlist), max(inlist))
    m = mean(inlist)
    sd = stdev(inlist)
    sk = skew(inlist)
    kurt = kurtosis(inlist)
    return n, mm, m, sd, sk, kurt
372682
def _get_mean(self, sites, rup, dists, imt, stddev_types):
        
        # Zhao et al. 2006 - Vs30 + Rrup
        mean_zh06, stds1 = super().get_mean_and_stddevs(sites, rup, dists, imt,
                                                        stddev_types)
        #
        # Atkinson and Macias (2009) - Rrup
        gmpe = AtkinsonMacias2009()
        mean_am09, stds2 = gmpe.get_mean_and_stddevs(sites, rup, dists, imt,
                                                     stddev_types)
        #
        # Abrahamson et al. (2015) - Rrup + vs30 + backarc
        gmpe = AbrahamsonEtAl2015SInter()
        mean_ab15, stds3 = gmpe.get_mean_and_stddevs(sites, rup, dists, imt,
                                                     stddev_types)
        #
        # Ghofrani and Atkinson (2014) - Rrup + vs30
        gmpe = GhofraniAtkinson2014()
        mean_ga14, stds4 = gmpe.get_mean_and_stddevs(sites, rup, dists, imt,
                                                     stddev_types)
        # Computing adjusted mean and stds
        cff = self.SITE_COEFFS[imt]
        mean_adj = (np.log(np.exp(mean_zh06)*cff['mf'])*0.1 +
                    mean_am09*0.5 + mean_ab15*0.2 +
                    np.log(np.exp(mean_ga14)*cff['mf'])*0.2)
        return mean_adj
695855
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
        
        C = self.COEFFS[imt]
        mean = (np.log(self.get_magnitude_term(C, rup) +
                       self.get_distance_term(C, dists.rrup)) +
                self.get_site_amplification(C, sites))
        stddevs = self.get_stddevs(C, sites.vs30.shape, rup.mag, stddev_types)
        return mean, stddevs
293024
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
        
        # extracting dictionary of coefficients specific to required
        # intensity measure type.

        C = self.COEFFS[imt]
        mean = (self._get_magnitude_scaling(C, rup.mag) +
                self._get_distance_scaling(C, dists, rup.mag) +
                self._get_site_term(C, sites.vs30))

        # Mean is returned in terms of m/s^2. Need to convert to g
        mean -= np.log(g)
        stddevs = self.get_stddevs(C, sites.vs30.shape, stddev_types)
        return mean + self.adjustment_factor, stddevs
1045021
def rskew_normal(mu, tau, alpha, size=()):
    
    size_ = size or (1,)
    len_ = np.prod(size_)
    return flib.rskewnorm(
        len_, mu, tau, alpha, np.random.normal(size=2 * len_)).reshape(size)