HelperFunctions.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:gullikson-scripts 作者: kgullikson88 项目源码 文件源码
def integral(x, y, I, k=10):
    """
    Integrate y = f(x) for x = 0 to a such that the integral = I
    I can be an array.

    Returns the values a that are found.
    """
    I = np.atleast_1d(I)

    f = UnivariateSpline(x, y, s=k)

    # Integrate as a function of x
    F = f.antiderivative()
    Y = F(x)

    a = []
    for intval in I:
        F2 = UnivariateSpline(x, Y/Y[-1] - intval, s=0)
        a.append(F2.roots())

    return np.hstack(a)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号