title: create loop using values from an array
body: <p>I have an array D of variable length,</p>
  
  <p>I want to create a loop that performs a sum based on the value of D corresponding to the number of times looped</p>
  
  <p>i.e. the 5th run through the loop would use the 5th value in my array.</p>
  
  <p>My code is:</p>
  
  <pre><code>period = 63 # can be edited to an input() command for variable periods.
  Mrgn_dec = .10 # decimal value of 10%, can be manipulated to produce a 10% increase/decrease
  rtn_annual = np.arange(0.00,0.15,0.05) # creates an array ??? not sure if helpful
  sig_annual = np.arange(0.01,0.31,0.01) #use .31 as python doesnt include the upper range value.
  
  
  #functions for variables of daily return and risk.
  rtn_daily = (1/252)*rtn_annual
  sig_daily = (1/(np.sqrt(252)))*sig_annual
  D=np.random.normal(size=period) # unsure of range to use for standard distribution
  
  for i in range(period):
      r=(rtn_daily+sig_daily*D)
  </code></pre>
  
  <p>I'm trying to make it so my for loop is multiplied by the value for D of each step.</p>
  
  <p>So D has a random value for every value of period, where period represents a day. </p>
  
  <p>So for the 8th day I want the loop value for r to be multiplied by the 8th value in my array, is there a way to select the specific value or not?</p>
  
  <p>Does the numpy.cumprod command offer any help, I'm not sure how it works but it has been suggested to help the problem.</p>