File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -125,7 +125,27 @@ public function getMaxInterval(): int
125125 */
126126 public function getAverageInterval (): int
127127 {
128- $ total = array_sum ($ this ->intervals );
128+ sort ($ this ->intervals );
129+
130+ $ count = count ($ this ->intervals );
131+ if ($ count === 0 ) {
132+ return 0 ;
133+ }
134+
135+ // some feeds could have very old historic
136+ // articles so eliminate them with statistic
137+ $ q1 = $ this ->intervals [floor ($ count * 0.25 )];
138+ $ q3 = $ this ->intervals [floor ($ count * 0.75 )];
139+ $ iqr = $ q3 - $ q1 ;
140+
141+ $ lower_bound = $ q1 - 1.5 * $ iqr ;
142+ $ upper_bound = $ q3 + 1.5 * $ iqr ;
143+
144+ $ result = array_filter ($ this ->intervals , function ($ value ) use ($ lower_bound , $ upper_bound ) {
145+ return $ value >= $ lower_bound && $ value <= $ upper_bound ;
146+ });
147+
148+ $ total = array_sum ($ result );
129149
130150 return count ($ this ->intervals ) ? intval (floor ($ total / count ($ this ->intervals ))) : 0 ;
131151 }
You can’t perform that action at this time.
0 commit comments