【问题标题】:how to set scale and size in np.random.exponential如何在 np.random.exponential 中设置比例和大小
【发布时间】:2016-05-12 16:03:57
【问题描述】:

我该如何实现:

库存损失错误被建模为发生在之间的更新过程 时间间隔。时间间隔基于指数 库存损失事件之间的平均时间分布 (TBSLE)。这 库存损失发生的频率是 TBSLE 的倒数。这 平均库存损失量的期望值可以估计为 2.05.

我尝试像这样实现它,但我不知道如何以指数方式设置比例和大小,或者这种方法是否正确。

def stockLossError(self):
    stockLossErrorProbability = 0
    inverseLambda = 0.5
    errors = 0

    randomnumber = np.random.exponential(inverseLambda,none)
    if(randomnumber > stockLossErrorProbability):
        self.daysSinceLastError += 1
        self.errors += 2.05

【问题讨论】:

    标签: python numpy random distribution exponential


    【解决方案1】:

    就像the docs说的那样

    >>> import numpy as np
    >>> np.random.seed(42)
    >>> np.random.exponential(scale=4, size=(2, 3))
    array([[  1.87707236,  12.04048572,   5.26698277],
           [  3.65177022,   0.67849948,   0.67838517]])
    

    【讨论】:

    • 谢谢,现在我对指数函数的工作原理有了更深入的了解!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-04-04
    • 2015-06-20
    • 2020-04-10
    • 2020-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多