当前位置: 首页>>代码示例>>Python>>正文


Python special.iv方法代码示例

本文整理汇总了Python中scipy.special.iv方法的典型用法代码示例。如果您正苦于以下问题:Python special.iv方法的具体用法?Python special.iv怎么用?Python special.iv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scipy.special的用法示例。


在下文中一共展示了special.iv方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: kaiser_bessel_ft

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import iv [as 别名]
def kaiser_bessel_ft(om, npts, alpha, order, d):
    """Computes FT of KB function for scaling in image domain.

    Args:
        om (ndarray): An array of coordinates to interpolate to.
        npts (int): Number of points to use for interpolation in each
            dimension.
        order (ind, default=0): Order of Kaiser-Bessel kernel.
        alpha (double or array of doubles): KB parameter.

    Returns:
        ndarray: The scaling coefficients.
    """
    z = np.sqrt((2 * np.pi * (npts / 2) * om)**2 - alpha**2 + 0j)
    nu = d / 2 + order
    scaling_coef = (2 * np.pi)**(d / 2) * ((npts / 2)**d) * (alpha**order) / \
        special.iv(order, alpha) * special.jv(nu, z) / (z**nu)
    scaling_coef = np.real(scaling_coef)

    return scaling_coef 
开发者ID:mmuckley,项目名称:torchkbnufft,代码行数:22,代码来源:utils.py

示例2: KL_davidson

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import iv [as 别名]
def KL_davidson(k, d):
    vmf_entropy = k * ive(d / 2, k) / ive((d / 2) - 1, k) + \
                  (d / 2 - 1) * np.log(k) \
                  - (d / 2) * np.log(2 * np.pi) - np.log(iv(d / 2 - 1, k))

    hyu_ent = np.log(2) + (d / 2) * np.log(np.pi) - sp.loggamma(
        d / 2)

    kl = vmf_entropy + hyu_ent
    return kl
#
# first = k * bessel(d / 2, k) / bessel(d / 2 - 1, k)
# second = (d / 2 - 1) * torch.log(k) - torch.log(bessel(d / 2 - 1, k))
# const = torch.tensor(
#            np.log(3.1415926) * d / 2 + np.log(2) - sp.loggamma(d / 2).real - (d / 2) * np.log(2 * 3.1415926)).to(
#            devic

# for kappa in range(10, 150, 20):
#     for d in range(50, 150, 50):
#         print("Davidson:{}\t\tGuu:{}".format(KL_davidson(kappa, d), KL_guu(kappa, d))) 
开发者ID:jiacheng-xu,项目名称:vmf_vae_nlp,代码行数:22,代码来源:vmf_hypvae.py

示例3: test_ticket_854

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import iv [as 别名]
def test_ticket_854(self):
        """Real-valued Bessel domains"""
        assert_(isnan(special.jv(0.5, -1)))
        assert_(isnan(special.iv(0.5, -1)))
        assert_(isnan(special.yv(0.5, -1)))
        assert_(isnan(special.yv(1, -1)))
        assert_(isnan(special.kv(0.5, -1)))
        assert_(isnan(special.kv(1, -1)))
        assert_(isnan(special.jve(0.5, -1)))
        assert_(isnan(special.ive(0.5, -1)))
        assert_(isnan(special.yve(0.5, -1)))
        assert_(isnan(special.yve(1, -1)))
        assert_(isnan(special.kve(0.5, -1)))
        assert_(isnan(special.kve(1, -1)))
        assert_(isnan(special.airye(-1)[0:2]).all(), special.airye(-1))
        assert_(not isnan(special.airye(-1)[2:4]).any(), special.airye(-1)) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:18,代码来源:test_basic.py

示例4: nena

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import iv [as 别名]
def nena(locs, info, callback=None):
    bin_centers, dnfl_ = next_frame_neighbor_distance_histogram(locs, callback)

    def func(d, a, s, ac, dc, sc):
        f = a * (d / s ** 2) * _np.exp(-0.5 * d ** 2 / s ** 2)
        fc = (
            ac
            * (d / sc ** 2)
            * _np.exp(-0.5 * (d ** 2 + dc ** 2) / sc ** 2)
            * _iv(0, d * dc / sc)
        )
        return f + fc

    pdf_model = _lmfit.Model(func)
    params = _lmfit.Parameters()
    area = _np.trapz(dnfl_, bin_centers)
    median_lp = _np.mean([_np.median(locs.lpx), _np.median(locs.lpy)])
    params.add("a", value=area / 2, min=0)
    params.add("s", value=median_lp, min=0)
    params.add("ac", value=area / 2, min=0)
    params.add("dc", value=2 * median_lp, min=0)
    params.add("sc", value=median_lp, min=0)
    result = pdf_model.fit(dnfl_, params, d=bin_centers)
    return result, result.best_values["s"] 
开发者ID:jungmannlab,项目名称:picasso,代码行数:26,代码来源:postprocess.py

示例5: _G_integrand

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import iv [as 别名]
def _G_integrand(xip, B):
    try:
        from scipy.special import iv as besseli
    except:
        """ [PHIDL] To run this function you need scipy, please install it with
        pip install scipy """
    return besseli(0, B*sqrt(1-xip**2)) 
开发者ID:amccaugh,项目名称:phidl,代码行数:9,代码来源:geometry.py

示例6: forward

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import iv [as 别名]
def forward(ctx, dim, kappa):
        """
        In the forward pass we receive a Tensor containing the input and return
        a Tensor containing the output. ctx is a context object that can be used
        to stash information for backward computation. You can cache arbitrary
        objects for use in the backward pass using the ctx.save_for_backward method.
        """
        ctx.save_for_backward(dim, kappa)

        kappa_copy = kappa.clone()
        m = sp.iv(dim, kappa_copy)
        x = torch.tensor(m).to(device)
        return x.clone() 
开发者ID:jiacheng-xu,项目名称:vmf_vae_nlp,代码行数:15,代码来源:try_bessel.py

示例7: KL_guu

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import iv [as 别名]
def KL_guu(k, d):
    kld = k * ((sp.iv(d / 2.0 + 1.0, k) \
                + sp.iv(d / 2.0, k) * d / (2.0 * k)) / sp.iv(d / 2.0, k) - d / (2.0 * k)) \
          + d * np.log(k) / 2.0 - np.log(sp.iv(d / 2.0, k)) \
          - sp.loggamma(d / 2 + 1) - d * np.log(2) / 2

    return kld 
开发者ID:jiacheng-xu,项目名称:vmf_vae_nlp,代码行数:9,代码来源:vmf_hypvae.py

示例8: mod_Bessel_first_kind

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import iv [as 别名]
def mod_Bessel_first_kind(kappa, d):
    # Modified Bessel function of the first kind
    return sp.iv(d, kappa) 
开发者ID:jiacheng-xu,项目名称:vmf_vae_nlp,代码行数:5,代码来源:archived_vmf.py

示例9: _vmf_kld

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import iv [as 别名]
def _vmf_kld(k, d):
        tmp = (k * ((sp.iv(d / 2.0 + 1.0, k) + sp.iv(d / 2.0, k) * d / (2.0 * k)) / sp.iv(d / 2.0, k) - d / (2.0 * k)) \
               + d * np.log(k) / 2.0 - np.log(sp.iv(d / 2.0, k)) \
               - sp.loggamma(d / 2 + 1) - d * np.log(2) / 2).real
        if tmp != tmp:
            exit()
        return np.array([tmp]) 
开发者ID:jiacheng-xu,项目名称:vmf_vae_nlp,代码行数:9,代码来源:vmf_only.py

示例10: _vmf_kld

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import iv [as 别名]
def _vmf_kld(k, d):
    tmp = (k * ((sp.iv(d / 2.0 + 1.0, k) + sp.iv(d / 2.0, k) * d / (2.0 * k)) / sp.iv(d / 2.0, k) - d / (2.0 * k)) \
           + d * np.log(k) / 2.0 - np.log(sp.iv(d / 2.0, k)) \
           - sp.loggamma(d / 2 + 1) - d * np.log(2) / 2).real

    return str(tmp) 
开发者ID:jiacheng-xu,项目名称:vmf_vae_nlp,代码行数:8,代码来源:kl_cost_sheet.py

示例11: _vmf_kld_davidson

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import iv [as 别名]
def _vmf_kld_davidson(k, d):
        """
        This should be the correct KLD.
        Empirically we find that _vmf_kld (as in the Guu paper) only deviates a little (<2%) in most cases we use.
        """
        tmp = k * sp.iv(d / 2, k) / sp.iv(d / 2 - 1, k) + (d / 2 - 1) * torch.log(k) - torch.log(
            sp.iv(d / 2 - 1, k)) + np.log(np.pi) * d / 2 + np.log(2) - sp.loggamma(d / 2).real - (d / 2) * np.log(
            2 * np.pi)
        if tmp != tmp:
            exit()
        return np.array([tmp]) 
开发者ID:jiacheng-xu,项目名称:vmf_vae_nlp,代码行数:13,代码来源:vmf_batch.py

示例12: _vmf_kld

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import iv [as 别名]
def _vmf_kld(k, d):
        tmp = (k * ((sp.iv(d / 2.0 + 1.0, k) + sp.iv(d / 2.0, k) * d / (2.0 * k)) / sp.iv(d / 2.0, k) - d / (2.0 * k)) \
               + d * np.log(k) / 2.0 - np.log(sp.iv(d / 2.0, k)) \
               - sp.loggamma(d / 2 + 1) - d * np.log(2) / 2).real
        return tmp 
开发者ID:jiacheng-xu,项目名称:vmf_vae_nlp,代码行数:7,代码来源:vmf_unif.py

示例13: test_iv

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import iv [as 别名]
def test_iv(self):
        assert_equal(cephes.iv(1,0),0.0) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:4,代码来源:test_basic.py

示例14: test_negv_iv

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import iv [as 别名]
def test_negv_iv(self):
        assert_equal(special.iv(3,2), special.iv(-3,2)) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:4,代码来源:test_basic.py

示例15: _cephes_vs_amos_points

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import iv [as 别名]
def _cephes_vs_amos_points(self):
        """Yield points at which to compare Cephes implementation to AMOS"""
        # check several points, including large-amplitude ones
        for v in [-120, -100.3, -20., -10., -1., -.5,
                  0., 1., 12.49, 120., 301]:
            for z in [-1300, -11, -10, -1, 1., 10., 200.5, 401., 600.5,
                      700.6, 1300, 10003]:
                yield v, z

        # check half-integers; these are problematic points at least
        # for cephes/iv
        for v in 0.5 + arange(-60, 60):
            yield v, 3.5 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:15,代码来源:test_basic.py


注:本文中的scipy.special.iv方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。