Vessel Availability

Matt907907

New member
Joined
Nov 3, 2020
Messages
6
Here is a problem for you all. We have five vessels (A, B, C, D, and E), each with a different probability that they might be available at any one time. What is the probability that out of the five vessels, one is actually available? Two? Three? Four? or all Five?

The probability that at least one is available is: 1 - (1-P(A))*(1-P(B))*(1-P(C))*(1-P(D))*(1-P(E)) i.e. 1 - P(none available)
The probability that all five are available is: P(A)*P(B)*P(C)*P(D)*P(D)*P(E)

QUESTION: What is the general formula to calculate if 2, 3, or 4 vessels are available?

See table below for an example calculation:

VesselProbability of Availability of Each Vessel
A20%
B40%
C80%
D60%
E10%
Probability at least 1 vessel available 96.5%
Probability 2 vessels available????
Probability 3 vessels available????
Probability 4 vessels available????
Probability 5 vessels available0.4%
 
I have enough problems to do. I am more concerned about how you would answer your question. Please post back showing your work.
 
I have enough problems to do. I am more concerned about how you would answer your question. Please post back showing your work.
Hi Jomo, to be honest I don't know what probability distribution I should be using here. To calculate the probability that at least one vessel is available using the sample numbers is easy:
P(at least 1 available) = 1-P(none available) = 1 - (1-0.2) * (1-0.4)* (1-0.8) * (1-0.6) * (1-0.1) = 0.965 = 96.5%

To calculate if exactly one vessel is available longhand, it rapidly becomes very complicated.
P(1) = P(A) or P(B) or P(C) or P(D) or P(E)
= P(A available; B, C, D, and E not available) P(A)*(1-P(B))*(1-P(C))*(1-P(D))*(1-P(E))
+ P(B available; A, C, D, and E not available) P(B)*(1-P(A))*(1-P(C))*(1-P(D))*(1-P(E))
+ etc....
It gets evens worse for P(2). This is where I gave up. There must be an easier way......

I work for a spill response company, and we need to work out how many vessels with various availabilities we need to reach say 90% overall availability for two or three vessels in our fleet.

Cheers!

Matt
 
Are you familiar with the binomial probability distribution?
 
Yes, but it has been awhile. I will have to investigate that further. Thank you for the tip.
 
Here is a problem for you all. We have five vessels (A, B, C, D, and E), each with a different probability that they might be available at any one time. What is the probability that out of the five vessels, one is actually available? Two? Three? Four? or all Five?
The probability that at least one is available is: 1 - (1-P(A))*(1-P(B))*(1-P(C))*(1-P(D))*(1-P(E)) i.e. 1 - P(none available)
The probability that all five are available is: P(A)*P(B)*P(C)*P(D)*P(D)*P(E)
QUESTION: What is the general formula to calculate if 2, 3, or 4 vessels are available?
See table below for an example calculation:
Here is a table for reference:
\(\begin{array}{*{20}{c}} {vessel}&{available}&{not\,available} \\ \hline A&{0.2}&{0.8} \\ B&{0.4}&{0.6} \\ C&{0.8}&{0.2} \\ D&{0.6}&{0.4} \\
E&{0.1}&{0.9} \end{array}\)
I find this table good for quick reference. \(\mathcal{P}(AB'CD'E')=(0.2)(0.6)(0.8)(0.4)(0.9)\)
That is the probability that vessels \(A~\&~C\) are available while \(B,~D,~\&~E\) are not-available.
You have said how tedious this will be to calculate that exactly two vessels are available
The above is just one of ten cases. This is a good programming question for either a standard programming language or Excel.
 
I have re-read your problem and see I have given you a bum steer. Sorry. I apologize.

Let p1 be the probability that vessel A is ready, p2 the probability that vessel B is ready, and so on.

0 < p1 < 1, 0 < p2 < 1, and so on.

Let q1= 1 - p1, q2 = 1 - p2, and so on.

Let r0 be the probability that zero vessels are ready, r1 the probability that exactly one vessel is ready, and so on.

[MATH]r_0 = \prod_{j=1}^5 q_j[/MATH]
[MATH]r_5 = \prod_{j=1}^5 p_j.[/MATH]
[MATH]r_1 = r_0 * \sum_{j=1}^5 \dfrac{p_j}{q_j}.[/MATH]
[MATH]r_4 = r_5 * \sum_{j=1}^5 \dfrac{q_j}{p_j}.[/MATH]
[MATH]r_2 = r_0 * \left ( \sum_{j=1}^4 \dfrac{p_j}{q_j} \prod_{k=j+1}^5 \dfrac{p_k}{q_k} \right ).[/MATH]
[MATH]r_3 = r_5 * \left ( \sum_{j=1}^4 \dfrac{q_j}{p_j} * \sum_{k=j+1}^5 \dfrac{q_k}{p_k} \right ).[/MATH]
If I have done this correctly, it should (1) REDUCE to the binomial distribution if all the p’s are equal, and (2) have a sum of 1 if you add up the r’s.

Do you know what [MATH]\Sigma[/MATH] and [MATH]\Pi[/MATH] mean?

And as pka says, this is computationally tedious and best done by machine.
 
Last edited:
CORRECTION

if I am track at all

[MATH]r_3 =r_0 * \left ( \sum_{j=1}^4 \dfrac{q_j}{p_j} * \prod_{k=j+1}^5 \dfrac{q_k}{p_k} \right ).[/MATH]
 
A very clever method by @JeffM but I thought that r3 was correct and r2 incorrect. I think r2 should be...

[MATH]r_2 = r_0 * \left ( \sum_{j=1}^4 \dfrac{p_j}{q_j} * \sum_{k=j+1}^5 \dfrac{p_k}{q_k} \right )[/MATH]
Which is equivalent to

[MATH]r_2 = r_0 * \sum_{j=1}^4 \left( \dfrac{p_j}{q_j} * \sum_{k=j+1}^5 \dfrac{p_k}{q_k} \right) [/MATH]
BTW: This is how I'd implement it in code...
Code:
s=0
for (j=1;j<=4;++j) {
  s1=0
  for (k=j+1;k<=5;++k) {
    s1=s1+p[k]/q[k]
  }
  s=s+s1*p[j]/q[j]
}
r2=s*r0

After calculating your figures for r0 to r5 you can check them because they should obviously sum to 1.
 
Last edited:
I'm a programmer, therefore it was easy enough for me to write the following python code that generates "expanded" expressions to calculate r0 to r5. You can easily change the number of ships. Most of the code is concerned with printing the results

Python:
import itertools
import numpy as np

total=5 # total number of ships

allShips=range(1,total+1)
for numAvail in range(total+1):
    print()
    print("r"+str(numAvail)+" = ")
    # iterate through combinations of available ships...
    for avail in itertools.combinations(allShips, numAvail):
        # Find all ships that aren't in "avail"
        notAvail=np.setdiff1d(allShips, avail)

        # Print the results
        s="  + "
        first=1
        for i in avail:
            if first==1:
                first=0
            else:
                s+="*"
            s+="p"+str(i)
        s+="  "
        for i in notAvail:
            if first==1:
                first=0
            else:
                s+="*"
            s+="(1-p"+str(i)+")"
        print(s)
               
    numAvail+=1

The output is below. You should be able to customise the output (by changing the code) to suit your purposes. You could output spreadsheet cell references or whatever. Or you could even adapt the code to simply perform the calculation within python. There are several online sites where you can run python without installing it.

Code:
r0 =
  +   (1-p1)*(1-p2)*(1-p3)*(1-p4)*(1-p5)

r1 =
  + p1  *(1-p2)*(1-p3)*(1-p4)*(1-p5)
  + p2  *(1-p1)*(1-p3)*(1-p4)*(1-p5)
  + p3  *(1-p1)*(1-p2)*(1-p4)*(1-p5)
  + p4  *(1-p1)*(1-p2)*(1-p3)*(1-p5)
  + p5  *(1-p1)*(1-p2)*(1-p3)*(1-p4)

r2 =
  + p1*p2  *(1-p3)*(1-p4)*(1-p5)
  + p1*p3  *(1-p2)*(1-p4)*(1-p5)
  + p1*p4  *(1-p2)*(1-p3)*(1-p5)
  + p1*p5  *(1-p2)*(1-p3)*(1-p4)
  + p2*p3  *(1-p1)*(1-p4)*(1-p5)
  + p2*p4  *(1-p1)*(1-p3)*(1-p5)
  + p2*p5  *(1-p1)*(1-p3)*(1-p4)
  + p3*p4  *(1-p1)*(1-p2)*(1-p5)
  + p3*p5  *(1-p1)*(1-p2)*(1-p4)
  + p4*p5  *(1-p1)*(1-p2)*(1-p3)

r3 =
  + p1*p2*p3  *(1-p4)*(1-p5)
  + p1*p2*p4  *(1-p3)*(1-p5)
  + p1*p2*p5  *(1-p3)*(1-p4)
  + p1*p3*p4  *(1-p2)*(1-p5)
  + p1*p3*p5  *(1-p2)*(1-p4)
  + p1*p4*p5  *(1-p2)*(1-p3)
  + p2*p3*p4  *(1-p1)*(1-p5)
  + p2*p3*p5  *(1-p1)*(1-p4)
  + p2*p4*p5  *(1-p1)*(1-p3)
  + p3*p4*p5  *(1-p1)*(1-p2)

r4 =
  + p1*p2*p3*p4  *(1-p5)
  + p1*p2*p3*p5  *(1-p4)
  + p1*p2*p4*p5  *(1-p3)
  + p1*p3*p4*p5  *(1-p2)
  + p2*p3*p4*p5  *(1-p1)

r5 =
  + p1*p2*p3*p4*p5
 
Thank you so much for the help, Cubist and JeffM. I understand the maths and will try to implement in either Excel or Python. It looks like I can expand the code for any number of vessels. In reality, I am really just interested in r2 and r3 for perhaps up to 10 vessels, so hopefully that should not be too hard to work out. Cheers, Matt
 
Follow up.

Cubist sent me a private message last night saying that he thought my formula for r3 was correct and my formula for r2 was incorrect. I told him that I was way too tired to think it through and welcomed him to make corrections, which he very kindly did.

Let's think about r3. How many ways can we select 3 out of the 5 vessels, obviously 10: ABC, ABD, ABE, ACD, ACE, ADE, BCD, BCE, BDE, CDE. Each choice uniquely determine the p's and q's.

And quite obviously

[MATH]\sum_{j=1}^4 x_j \left ( \sum_{k=j+1}^5 x_k\right)[/MATH]
gives 4 + 3 + 2 + 1 = 10 summands. That is reassuring.

Now let's expand my original formula for r_3:

[MATH]r_3 = r_5 * \left \{ \sum_{j=1}^4 \dfrac{q_j}{p_j} * \left ( \sum_{k=j+1}^5 \dfrac{q_k}{p_k} \right ) \right \} = \left ( \prod_{i=1}^5 p_i \right ) *[/MATH]
[MATH]\left \{ \left (\dfrac{q_1}{p_1} * \sum_{k=2}^5 \dfrac{q_k}{p_k} \right ) + \left ( \dfrac{q_2}{p_2} * \sum_{k=3}^5 \dfrac{q_k}{p_k} \right ) + \left ( \dfrac{q_3}{p_3} * \sum_{k=4}^5 \dfrac{q_k}{p_k} \right ) + \dfrac{q_4}{p_4} * \dfrac{q_5}{p_5} \right \} =[/MATH]
[MATH]\left ( \prod_{i=1}^5 p_i \right ) * \left ( \dfrac{q_1q_2}{p_1p_2} + \dfrac{q_1q_3}{p_1p_3} + \dfrac{q_1q_4}{p_1p_4} + \dfrac{q_1q_5}{p_1p_5} + \dfrac{q_2q_3}{p_2p_3} + \dfrac{q_2q_4}{p_2p_4} + \dfrac{q_2q_5}{p_2p_5} +\dfrac{q_3q_4}{p_3p_4} + \dfrac{q_3q_5}{p_3p_5} + \dfrac{q_4q_5}{p_4p_5} \right ) =[/MATH]
[MATH]q_1q_2p_3p_4p_5 + q_1q_3p_2p_4p_5 + q_1q_4p_2p_3p_5 + q_1q_5p_2p_3p_4 + \\ q_2q_3p_1p_4p_5 + q_2q_4p_1p_3p_5 +q_2q_5p_1p_3p_4 + \\ q_3q_4p_1p_2p_5 + q_3q_5p_1p_2p_4 + \\ q_4q_5p_1p_2p_3.[/MATH]And that is what we want. And of course r2 will be similar in form. So, Cubist was correct, and I am most appreciative for his perception.

Thus the correct answers are

[MATH]r_0 = \prod_{j=1}^5 q_i;[/MATH]
[MATH]r_1 = r_0 * \sum_{j=1}^5 \dfrac{p_i}{q_i};[/MATH]
[MATH]r_2 = r_0 * \left \{ \sum_{j=1}^4 \dfrac{p_j}{q_j} * \left ( \sum_{k=j+1}^5 \dfrac{p_k}{q_k} \right ) \right \};[/MATH]
[MATH]r_3 = r_5 * \left \{ \sum_{j=1}^4 \dfrac{q_j}{p_j} * \left ( \sum_{k=j+1}^5 \dfrac{q_k}{p_k} \right ) \right \};[/MATH]
[MATH]r_4 = r_5 * \sum_{j=1}^5 \dfrac{q_i}{p_i}; \text { and}[/MATH]
[MATH]r_5 = \prod_{j=1}^5 p_i.[/MATH]
If all the p's are equal, then so are all the q's, and we get

[MATH]r_0 = \prod_{j=1}^5 q = q^5 = \dbinom{5}{0} * p^0q^5;[/MATH]
[MATH]r_1 = q^5 * \sum_{j=1}^5 \dfrac{p}{q} = 5pq^4 = \dbinom{5}{1} * p^1q^4;[/MATH]
[MATH]r_2 = q^5 * \left \{ \sum_{j=1}^4 \dfrac{p}{q} * \left ( \sum_{k=j+1}^5 \dfrac{p}{q} \right ) \right \} = 10p^2q^3 = \dbinom{5}{2} * p^2q^3;[/MATH]
[MATH]r_3 = p^5 * \left \{ \sum_{j=1}^4 \dfrac{q}{p} * \left ( \sum_{k=j+1}^5 \dfrac{q}{p} \right ) \right \} = 10p^3q^2 = \dbinom{5}{3} * p^3q^2;[/MATH]
[MATH]r_4 = p^5 * \sum_{j=1}^5 \dfrac{q}{p} = 5p^4q = \dbinom{5}{4} * p^4q^1; \text { and}[/MATH]
[MATH]r_5 = \prod_{j=1}^5 p = p^5 = \dbinom{5}{5} * p^5q^0.[/MATH]
It is really easy to implement this in excel. Using the OP's original example, we get for r0 through r5:

6.48%, 34.74%, 39.24%, 16.54%, 2.84%, and 0.16%, which adds up to 100.00.%

It is possible that we can come up with a recursive formula because the OP wants to go up to 10 vessels. I have not thought that through.

Again, thanks to Cubist for making me look at this more closely. I guess you should not do math while looking at election returns and drinking cognac.
 
Yes!!! I managed to make the 5 vessel case work in Excel! It is not a pretty spreadsheet, but does the job. Using Cubist's code would be much more elegant. This will inspire me to learn Python (I last programmed in Fortran and Basic!!!). Definitely a must have if I want to increase the vessel count, even if only for r2. I think that your r2 formula should be expandable for any number of vessels - I'll give it a shot. Thank you again for your help.
 
Yes!!! I managed to make the 5 vessel case work in Excel! It is not a pretty spreadsheet, but does the job. Using Cubist's code would be much more elegant. This will inspire me to learn Python (I last programmed in Fortran and Basic!!!). Definitely a must have if I want to increase the vessel count, even if only for r2. I think that your r2 formula should be expandable for any number of vessels - I'll give it a shot. Thank you again for your help.
Actually the excel spread sheet is pretty simple if you use code like sum(F3:F$7) to build the partial sums.

I have a lot to do today, but I shall try to find time to generalize the r2 formula. No later than tomorrow. I suspect you are correct.
 
Let n be the number of vessels, pi the probability that the ith vessel will be available, qi the probability that the ith vessel will not be available, ri the probability that exactly r vessels will be available. Obviously,

[MATH]1 \le i \le n \implies q_i = 1 - p_1.[/MATH]
[MATH]r_0 = \prod_{j=1}^n q_j.[/MATH]
[MATH]r_1 = r_0 * \sum_{j=1}^n \dfrac{p_j}{q_j}.[/MATH]
[MATH]r_2 = r_0 * \left \{ \sum_{j=1}^{n-1} \dfrac{p_j}{q_j} * \left ( \sum_{k=j+1}^n \dfrac{p_k}{q_k} \right ) \right \}.[/MATH]
However, if n > 5, r_3 is not a simple extrapolation from when n = 5. There may be a recursive formula for n > 5. Not sure.

However, if you just want to know the probability that at least two vessels are available that is a very simple formula for any n, namely

[MATH]1 - (r_0 + r_1).[/MATH]
 
Top