Python scipy.special 模块,kv() 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用scipy.special.kv()

项目:CSB    作者:csb-toolbox    | 项目源码 | 文件源码
def testRandom(self):

        from scipy.special import kv
        from numpy import sqrt

        a = 2.
        b = 1.
        p = 1
        gig = GeneralizedInverseGaussian(a, b, p)
        samples = gig.random(10000)

        mu_analytical = sqrt(b) * kv(p + 1, sqrt(a * b)) / (sqrt(a) * kv(p, sqrt(a * b)))

        var_analytical = b * kv(p + 2, sqrt(a * b)) / a / kv(p, sqrt(a * b)) - mu_analytical ** 2

        mu = numpy.mean(samples)
        var = numpy.var(samples)

        self.assertAlmostEqual(mu_analytical, mu, delta=1e-1)
        self.assertAlmostEqual(var_analytical, var, delta=1e-1)
项目:pyGPGO    作者:hawk31    | 项目源码 | 文件源码
def K(self, X, Xstar):
        """
        Computes covariance function values over `X` and `Xstar`.

        Parameters
        ----------
        X: np.ndarray, shape=((n, nfeatures))
            Instances
        Xstar: np.ndarray, shape=((n, nfeatures))
            Instances

        Returns
        -------
        np.ndarray
            Computed covariance matrix.
        """
        r = l2norm_(X, Xstar)
        bessel = kv(self.v, np.sqrt(2 * self.v) * r / self.l)
        f = 2 ** (1 - self.v) / gamma(self.v) * (np.sqrt(2 * self.v) * r / self.l) ** self.v
        res = f * bessel
        res[np.isnan(res)] = 1
        res = self.sigmaf * res + self.sigman * kronDelta(X, Xstar)
        return (res)
项目:scikit-gstat    作者:mmaelicke    | 项目源码 | 文件源码
def matern(h, a, C0, s, b=0):
    """
    The Matérn model.

    For Matérn function see:
    Minasny, B., & McBratney, A. B. (2005). The Matérn function as a general model for soil variograms.
        Geoderma, 128(3–4 SPEC. ISS.), 192–207. http://doi.org/10.1016/j.geoderma.2005.04.003.

    :param h:   lag
    :param a:   range
    :param C0:  sill
    :param s:   smoothness parameter
    :param b:   nugget
    :return:
    """
    # prepare parameters
    r = a
    C0 -= b

    return b + C0 * (1 - ( (1 / (np.power(2, s - 1) * special.gamma(s))) * np.power(h / r, s) * special.kv(s, h / r) ))


# --- Adaptions using no nugget effect --- #
项目:bbho    作者:DarkElement75    | 项目源码 | 文件源码
def evaluate(self, x_i, x_j):
        dist = np.linalg.norm(x_i-x_j)
        return np.nan_to_num(((2**(1-self.v))/(ss.gamma(self.v))) * ((np.sqrt(2*self.v) * (dist/self.lengthscale))**self.v) * ss.kv(self.v, (np.sqrt(2*self.v) * (dist/self.lengthscale))))
项目:und_Sophie_2016    作者:SophieTh    | 项目源码 | 文件源码
def H2(self,y):
        K23=special.kv((2./3.),0.5*y)
        return (y*K23)**2
项目:und_Sophie_2016    作者:SophieTh    | 项目源码 | 文件源码
def radiation_theoric(self,omega,observation_angle):
        gamma=self.Lorentz_factor()
        X=gamma*observation_angle
        y=omega/self.critical_frequency()
        xi=y*0.5*np.sqrt((1.+X**2)**3)
        cst=(3.*codata.alpha*(gamma**2)*1e-3*1e-6*self.I_current()*y**2)/(codata.e*4.*np.pi**2)
        rad=((1.+X**2)**2)*((special.kv((2./3.),xi))**2+((X**2)/(1.+X**2))*(special.kv((2./3.),xi))**2)
        return rad*cst