Percent change measures the relative change between consecutive observations. For each index i beginning at 1, compute
pi=xi−1xi−xi−1The numerator is the current value minus the previous value, and the denominator is the previous value. If the previous value is zero, use 0.0 for that position. Return the consecutive fractional changes as a list.
Input: series = [100, 110, 105]
Output: [0.1, -0.045455]
Explanation: The first change is 10 / 100, and the second is -5 / 110.
Input: series = [50, 100, 200]
Output: [1.0, 1.0]
Begin the loop at index 1 so both the current and previous values exist.
Check the previous value before performing the division.
Sign in to take notes on this problem
Accepts: array
Percent change measures the relative change between consecutive observations. For each index i beginning at 1, compute
pi=xi−1xi−xi−1The numerator is the current value minus the previous value, and the denominator is the previous value. If the previous value is zero, use 0.0 for that position. Return the consecutive fractional changes as a list.
Input: series = [100, 110, 105]
Output: [0.1, -0.045455]
Explanation: The first change is 10 / 100, and the second is -5 / 110.
Input: series = [50, 100, 200]
Output: [1.0, 1.0]
Begin the loop at index 1 so both the current and previous values exist.
Check the previous value before performing the division.
Sign in to take notes on this problem
Accepts: array