Answer the question
In order to leave comments, you need to log in
How to calculate interval for dates of averages?
Please tell me how to calculate average values for dates.
For example, there are several arrays (two or more) with a date (in UNIX_TIMESTAMP format) and a value (int), for example:
Array 1:
array(
'1555349037' => 8,
'1555349027' => 11,
'1555349017' => 2 ,
...
)
array(
'1555349035' => 2,
'1555349029' => 5,
'1555349017' => 9 ,
...
)
Answer the question
In order to leave comments, you need to log in
1. You find the minimum and maximum values of dates in all arrays. (from 1555349000 to 1555349100, for example).
2. You build a new array according to the principle of min date to max date in 10 sec increments, or as much as you need.
3. You are looking for keys in all arrays according to the principle>=date, <date + 10 sec. (>=1555349000 && <1555349010)
4. Calculate the average value for all found data and save it under the desired key.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question