2016-05-12 54 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