I'm modeling viral growth for a product. Let's say user A brings (on average) the following number of users each day:
- day 1 = 0.5
- day 2 = 0.3
- day 3 = 0.4
- day 4 = 0.1
In turn, each user referred by A brings the same amount of users (i.e., 0.5, 0.3, 0.4, 0.1), but with a 1 day lag.
So, after 1 day, the number of users is just:
$0.5$
But after 2 days, the number of users is:
$0.5 + 0.3 + (0.5\times0.5)$
Because the first user that A brought, also brings users.
And after 3 days, the number of users is:
$0.5 + 0.3 + 0.4 + (0.5\times0.5) + (0.5\times0.3) + (0.3\times0.5) + (0.5\times0.5\times0.5)$
As you can see, after 3 days, the number of terms to be added is already quite big, because new users keep bringing new users.
How can I model the total number of users by the end of X days?
I found a similar question, but it's not the same, as in this question the growth is always decreasing.
Thanks a lot in advance!!!!
Let's say that on the $k$-th day you have the following distribution of users:
$n_k^4$ - number of users with 4 more days to bring new users
$n_k^3$ - number of users with 3 more days to bring new users
$n_k^2$ - number of users with 2 more days to bring new users
$n_k^1$ - number of users with 1 more day to bring new users
$n_k^0$ - number of users the no longer bring new users
The total number of users on the $k$-th day is $\sum_{i=0}^4n_k^i$.
On the next day:
$n_{k+1}^4 = 0.5 n_{k}^4 + 0.3 n_{k}^3 + 0.4 n_{k}^2 + 0.1 n_{k}^1$
$n_{k+1}^3 = n_{k}^4$
$n_{k+1}^2 = n_{k}^3$
$n_{k+1}^1 = n_{k}^2$
$n_{k+1}^0 = n_{k}^0 + n_{k}^1$
Inital conditions are:
$n_0^4=1$, $n_0^3=n_0^2=n_0^1=n_0^0=0$
The above set of rules can be converted into a fairly simple code that will calculate the number of users on any given day.