2016-05-12 253 views
-1

我怎样才能实现这一点:如何设置规模和大小np.random.exponential

库存损失误差建模为 时间间隔之间发生的更新过程。时间间隔基于股票损失事件之间的平均时间(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 

回答

4

就像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]]) 
+0

谢谢你,现在我有一个更好的了解指数函数是如何工作的! – fumo21