dynamical list problem
|
01-05-2019, 05:13 PM
Post: #19
|
|||
|
|||
RE: dynamical list problem
(01-03-2019 02:11 PM)peacecalc Wrote: But Albert, you gave me the hint for a solution: Every value is a starting point of a new 5m distance, the only difficulty will be then values where are 5m is not arrived exactly (means: it is more then 5m). (01-05-2019 12:54 PM)Thomas Klemm Wrote: Either calculate the partial sum of the times (as suggested by Albert) and then calculate the difference or then add up 5 time entries (as I suggested). With the above in mind, DOSUBS could be a key part of your implementation. It "feeds" each contiguous subgroup of list elements to a subroutine for processing, then takes whatever you left on the stack and returns it to you in a new list. Using a simple list for illustrative purposes, imagine that your data exists as follows: \(\left \{ \ 1 \ 1 \ 1 \ 1 \ 1 \ 2 \ 2 \ 2 \ 2 \ 2 \ 3 \ 3 \ 3 \ 3 \ 3 \ \right \}\) DOSUBS could be used to obtain a list of averages of each subgroup of 5 as follows: Code: « DOSUBS operates in a loop to "pre-load" the stack with (in this case) 5 elements from the source list, then runs the provided subroutine. This process is repeated until the final group of elements has been exhausted, and whatever your subroutine left on the stack is gathered into a new list result. If it helps to visualize the process, you can think of it this way: Code: 1 1 1 1 1 « + + + + 5 / » The result of the above code (assuming exact mode) is: \(\left \{ \ 1 \ \frac {6} {5} \ \frac {7} {5} \ \frac {8} {5} \ \frac {9} {5} \ 2 \ \frac {11} {5} \ \frac {12} {5} \ \frac {13} {5} \ \frac {14} {5} \ 3 \ \right \}\) ...thus allowing you to conveniently perform the averaging using a "sliding window" of values from the source list. The more challenging part, of course, is in converting your source data into the proper format before determining the averages. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)