本文整理汇总了Python中scipy.signal.html方法的典型用法代码示例。如果您正苦于以下问题:Python signal.html方法的具体用法?Python signal.html怎么用?Python signal.html使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scipy.signal
的用法示例。
在下文中一共展示了signal.html方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: discount_cumsum
# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import html [as 别名]
def discount_cumsum(x, discount):
"""Discounted cumulative sum.
See https://docs.scipy.org/doc/scipy/reference/tutorial/signal.html#difference-equation-filtering # noqa: E501
Here, we have y[t] - discount*y[t+1] = x[t]
or rev(y)[t] - discount*rev(y)[t-1] = rev(x)[t]
Args:
x (np.ndarrary): Input.
discount (float): Discount factor.
Returns:
np.ndarrary: Discounted cumulative sum.
"""
return scipy.signal.lfilter([1], [1, float(-discount)], x[::-1],
axis=0)[::-1]
示例2: batch_discounted_cumsum
# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import html [as 别名]
def batch_discounted_cumsum(values, discount):
"""
Return a matrix of discounted returns.
output[i, j] = discounted sum of returns of rewards[i, j:]
So
output[i, j] = rewards[i, j] + rewards[i, j+1] * discount
+ rewards[i, j+2] * discount**2 + ...
Based on rllab.misc.special.discounted_cumsum
:param rewards: FloatTensor, size [batch_size, sequence_length, 1]
:param discount: float, discount factor
:return FloatTensor, size [batch_size, sequence_length, 1]
"""
# See https://docs.scipy.org/doc/scipy/reference/tutorial/signal.html#difference-equation-filtering
# Here, we have y[t] - discount*y[t+1] = x[t]
# or reverse(y)[t] - discount*reverse(y)[t-1] = reverse(x)[t]
return scipy.signal.lfilter(
[1], [1, float(-discount)], values.T[::-1], axis=0,
)[::-1].T
示例3: discount_cumsum
# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import html [as 别名]
def discount_cumsum(x, discount):
# See https://docs.scipy.org/doc/scipy/reference/tutorial/signal.html#difference-equation-filtering
# Here, we have y[t] - discount*y[t+1] = x[t]
# or rev(y)[t] - discount*rev(y)[t-1] = rev(x)[t]
return scipy.signal.lfilter([1], [1, -discount], x[::-1], axis=0)[::-1]
示例4: discount_cumsum
# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import html [as 别名]
def discount_cumsum(x, discount):
# See https://docs.scipy.org/doc/scipy/reference/tutorial/signal.html#difference-equation-filtering # noqa: E501
# Here, we have y[t] - discount*y[t+1] = x[t]
# or rev(y)[t] - discount*rev(y)[t-1] = rev(x)[t]
return scipy.signal.lfilter(
[1], [1, float(-discount)], x[::-1], axis=0)[::-1]
示例5: discount_cumsum
# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import html [as 别名]
def discount_cumsum(x, gamma):
"""Compute the discounted cumulative summation of an 1-d array.
From https://github.com/rll/rllab/blob/master/rllab/misc/special.py"""
# See https://docs.scipy.org/doc/scipy/reference/tutorial/signal.html#difference-equation-filtering
# Here, we have y[t] - discount*y[t+1] = x[t]
# or rev(y)[t] - discount*rev(y)[t-1] = rev(x)[t]
return scipy.signal.lfilter([1], [1, float(-gamma)], x[::-1], axis=0)[::-1]
示例6: discount_cumsum
# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import html [as 别名]
def discount_cumsum(x, discount):
"""
See https://docs.scipy.org/doc/scipy/reference/tutorial/signal.html#difference-equation-filtering
Returns:
(float) : y[t] - discount*y[t+1] = x[t] or rev(y)[t] - discount*rev(y)[t-1] = rev(x)[t]
"""
return scipy.signal.lfilter([1], [1, float(-discount)], x[::-1], axis=0)[::-1]
示例7: discount_cumsum
# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import html [as 别名]
def discount_cumsum(x, discount):
# See https://docs.scipy.org/doc/scipy/reference/tutorial/signal.html#difference-equation-filtering
# Here, we have y[t] - discount*y[t+1] = x[t]
# or rev(y)[t] - discount*rev(y)[t-1] = rev(x)[t]
return scipy.signal.lfilter([1], [1, float(-discount)], x[::-1], axis=0)[::-1]