spl.py 文件源码

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

项目:PyCS 作者: COSMOGRAIL 项目源码 文件源码
def tv(self):
        """
        Returns the total variation of the spline. Simple !
        http://en.wikipedia.org/wiki/Total_variation

        """

        # Method 1 : linear approximation

        ptd = 5 # point density in days ... this is enough !

        a = self.t[0]
        b = self.t[-1]
        x = np.linspace(a, b, int((b-a) * ptd))
        y = self.eval(jds = x)
        tv1 = np.sum(np.fabs(y[1:] - y[:-1]))
        #print "TV1 : %f" % (tv1)

        return tv1  

        # Method 2 : integrating the absolute value of the derivative ... hmm, splint does not integrate derivatives ..     
        #si.splev(jds, (self.t, self.c, self.k))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号