Uncumulate

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Uncumulate(x, i, firstElement)

Finds the difference between each element of «x» and its predecessor along «i».

Uncumulate(x, i) returns an array whose first element (along «i») is the first element of «x», and each other element is the difference between the corresponding element of «x» and the previous element of «x».

Uncumulate(x, i, firstElement) returns an array with the first element along «i» equal to «firstElement», and each other element equal to the difference between the corresponding element of «x» and the previous element of «x».

Uncumulate(x, i) is the inverse of Cumulate(x, i). Uncumulate(x, i, 0) is similar to a discrete differential operator.

Examples

The following example returns a table that shows an increase in the cost ownership of certain car types over a certain period of time.

Uncumulate (Cost_of_ownership, Time) →
Time ▶
Car_type ▼ 0 1 2 3 4
VW 2810 141 147 155 163
Honda 3535 312 50 269 199
BMW 3185 109 115 120 127

The next example returns a table that shows the increase in the cost of ownership of cars compared to the previous time period and also sets the first value to 0.

Uncumulate (Cost_of_ownership, Time, 0) →
Time ▶
Car_type ▼ 0 1 2 3 4
VW 0 141 147 155 163
Honda 0 312 50 269 199
BMW 0 109 115 120 127