O
O
olezhenka2017-08-29 02:17:39
Algorithms
olezhenka, 2017-08-29 02:17:39

Who can help with the algorithm?

$count = 10000;
$now = 20000;
$start = 5000;
$end = 90000;
$count is the number of likes;
$now - current time;
$start - initial time segments;
$end - end time interval;
I need to file an algorithm for predicting the number of likes for a finite period of time.
Let's say 8 hours have passed, 16 hours left, and you need to increase $count by a percentage of the remaining time.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
SolidMinus, 2017-08-29
@olezhenka

it is described by a linear equation, bro (in reality, it is polynomial, because views go down over time, but if you need a linear one, then read on)
f($end, $start, $now, $count) = ($count * $end- $start * $count) / ($now - $start)
f($end, $start, $now, $count) = ($count * ($end- $start)) / ($now - $start)
f(x) = ax + b, f(x) - number of predicted likes, x - time a, b - coefficients
It is assumed that there are no likes at the very beginning:
20000a + b = 10000
5000a + b = 0
b = -5000a
20000a - 5000a =10000
15000a = 10000
a = 0.666
b = -3333.3
Therefore:
likes(time) = 0.666 * time - 3333.3
likes($end) = 56607
In general:
$now * a + b = $count
$start * a + b = 0
-b = $start * a
$now * a - $start * a = $count
a($now - $start) = $count
a = $count / ($now - $start)
b = - ($start * $count) / ($now - $start)
f($time) = ($count * $time - $start * $count) / ($now - $start)
f($time) = ($count * ($time - $start)) / ($now - $start)

B
Boris Korobkov, 2017-08-29
@BorisKorobkov

math-prosto.ru/?page=pages/function/function_y_kx_b.php

S
Sinnk, 2017-08-29
@Sinnk

wov = (All time span)/100;
fpp = $now / $wow;
$count * $fpp

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question