[prev] 34 [next]

Example: Computing Prefix Averages

  • The i-th prefix average of an array X is the average of the first i elements:

    A[i] = (X[0] + X[1] + … + X[i]) / (i+1)

    [Diagram:Pic/prefixAverage.jpg]

    NB. computing the array A of prefix averages of another array X has applications in financial analysis