Home Segments Index Top Previous Next

668: Sidetrip

One way to implement predict is to use straight-line extrapolation. First, you determine values for the slope, s, and intercept, c, of a straight line fit to the prices already in the array. Then, you use the slope and intercept to predict the next price, pn, the one that would go into the array location n:

pn = s * n + c