Look at the following network example:
Assume S
wants to send 3
sats to R
. You can further assume that S
has enough liquidity in each of its local channels to send up to 3
sats. Also assume the liquidity in channels (A,R), (B,R)
and (C,R)
is uniformly distributed.
one optimally reliable payment flow in this diagram looks like this:
1 sat: S --> A --> R probability: 2/3
2 sats: S --> B --> R probability: 3/5
This flow has a total probability of 2/3*3/5 = 2/5 = 0.4 = 40%
The question:
How to compute the expected value of Satoshis to arrive at R
if S
sends 3
?
Option A
(which I already know is wrong but I write it down because I suspect some people might have a similar first thought)
Initially I thought this would just be 3 sats * 2/5 = 6/5 sats = 1.2 sats
which is what one gets from multiplying the amount to send with the probability of the flow. This seems strange as sending 2 sats along S-->B-->R
has a probability of 3/5
and with the reasoning of above an expectation value of 2 sats * 3/5 = 6/5 sats = 1.2 sats
. as the expected value for 1 sat along the S-->A-->B
path is larger than 0
this would be a contradiction to the additivity of the expected value.
Option B
Starting from the above reasoning we add the expected values for the disjoint paths so:
E[3 sats] = 1 sat * 2/3 + 2 sat * 3/5 = 10/15 sats + 18/15 sats = 28/15 sats
Option C
Of course the 2 satoshi path S-->B-->R
does not have to be sent as one onion but could be sent as two onions with 1 sat each:
The first has a probability of 4/5
and the second has a conditional probability of 3/4
which is extensively explained at this issue. With the logic from option B one should be able to add those expected values.
so we have the expected value for sending two sats in two seperate 1 sat onions along S--> B --> R
would be computed as:
E[2 sats] = 1 sat * 4/5 + 1 sat * 3/4 = 31/20 sats
If we add the 1 sat onion from the S-->A-->R
which was 2/3
sats
we would expect to have
E[3 sats] = 31/20 sats + 2/3 sats = 93/60 sats + 40/60 sats = 132/60 sats = 33/15 sats
This is 5/15 sats = 1/3 sats
more than the answer in option B
Option D
To make things worse I am confused if the expected values of dissecting the 2 sat onion in option C into two 1 sat onions can just linearly added up as the second onion is conditioned on having 2 sats of liquidity in the channel. If the first onion has failed the second one will certainly fail. Thus one would have to compute expected value for sending two 1 sat onions like this:
E[2 sats] = 1 sat * 4/5 + 1 sat * 3/5 = 7/5 sats
this would result in a total expected value of:
E[3 sats] = 2/3 sats + 7/5 sats = 10/30 sats + 21/15 sats = 31/15 sats
Thoughts
just for comparison here are the results
- Option A:
18/15
- Option B:
28/15
- Option C:
33/15
- Option D:
31/15
While Option B seems certainly right it makes sense to further dissect the 2 sats onion. In simulations I did it seems that Option D is correct which is a bit surprising for me. Using the formalism of probability theory the difference for the 2 sat path is:
- Option C:
E[2 sats] = 1 sat * P(X>=1) + 1 sat * P(X>=2 | X >= 1)
- Option D:
E[2 sats] = 1 sat * P(X>=1) + 1 sat * P(X>=2)
As said the simulated setting indicates that Option D is the correct answer but that is highly surprising to me as I would expect the second term to be a conditional probabilty.