Numpy exp函数

时间:2019-02-04 11:26:03

标签: python numpy exponential

为什么当我写expX = s0 * np.exp(XY)时,出现以下错误?传递值的长度为1440,索引表示1。 我希望将值S0乘以第一个XY,并将结果变成下一个S0,以便可以将其乘以下一个XY,依此类推,以1440为准。

谢谢

  T = 1                               #len(index_future)
  N = 1440                            #number of time steps (min in 
  1 day)
  dt = T / N                          #time steps
  mu = returns_log.mean(axis= 0)/N    #mean return  
  t = np.linspace(0, T, N)
  #print(mu)
  #sys.exit()
  sigma = returns_log.std(axis= 0)    #total vol
  #print(sigma)
  #S0 = close.tail(1)                  #last return observed
  S0 = close['ETHJPY'].sample()
  #print (S0)
  #sys.exit()
  dt = sigma/np.sqrt(N)               #local volatility
  print(dt)


  W = np.cumsum(d[0])*np.sqrt(dt[0])  
  print(W)
  np.savetxt("checkkk.csv", W, delimiter=",")
  #sys.exit()                 
  Y= (sigma[0]*W)                        #random shocks

  X = (mu[0] - 0.5 * sigma[0]**2) * t       #drift

  XY = sum(X,Y).T#[np.newaxis]                         #drift + random shocks

  #expX = np.exp(XY['ETHJPY'])
  expX = s0 * np.exp(XY)

0 个答案:

没有答案