control_and_filter.py 文件源码

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

项目:QuantEcon.lectures.code 作者: QuantEcon 项目源码 文件源码
def roots_of_characteristic(self):
        """
        This function calculates z_0 and the 2m roots of the characteristic equation 
        associated with the Euler equation (1.7)

        Note:
        ------
        numpy.poly1d(roots, True) defines a polynomial using its roots that can be
        evaluated at any point. If x_1, x_2, ... , x_m are the roots then 
            p(x) = (x - x_1)(x - x_2)...(x - x_m)

        """
        m = self.m
        ? = self.?

        # Calculate the roots of the 2m-polynomial
        roots = np.roots(?)
        # sort the roots according to their length (in descending order) 
        roots_sorted = roots[np.argsort(abs(roots))[::-1]]    

        z_0 = ?.sum() / np.poly1d(roots, True)(1)
        z_1_to_m = roots_sorted[:m]     # we need only those outside the unit circle

        ? = 1 / z_1_to_m

        return z_1_to_m, z_0, ?
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号