conversation.py 文件源码

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

项目:facebook-message-analysis 作者: szheng17 项目源码 文件源码
def exp_damped_day_difference(self, dt1, dt2, alpha):
        """
        Computes exp(-alpha * t), where t is the difference between two
        datetimes in days.

        Args:
            dt1: A datetime such that dt1 >= dt2.
            dt2: A datetime such that dt1 >= dt2.
            alpha: A nonnegative float representing the damping factor.

        Returns:
            A float equal to exp(-alpha * t), where t is the difference between
                two datetimes in days.

        """
        if dt1 < dt2:
            raise ValueError('Must have dt1 >= dt2')
        if alpha < 0:
            raise ValueError('Must have alpha >= 0')
        minute_diff = self.minute_difference(dt1, dt2)
        day_diff = float(minute_diff) / (self.HOURS_PER_DAY * self.MINUTES_PER_HOUR)
        return math.exp(-alpha * day_diff)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号