I have the following graph:
I am told the following information:
(1) vertex A to vertex X is described by an exponential distribution with lambda = 4;
(2) vertex A to vertex Y is described by an exponential distribution with lambda = 2.5;
(3) vertex X to vertex Y identical to vertex Y to vertex X, and it is described by an exponential distribution with lambda = 10;
(4) vertex X to vertex B is described by an exponential distribution with lambda = 3; and, finally,
(5) vertex Y to vertex B is described by an exponential distribution with lambda = 5.
Let's assume that I'm taking the fastest path between vertices every simulation.
I now want to know the average time it takes to get from vertex A to vertex B.
My R code is as follows:
# Generate/simulate 1000 random numbers for each of the internode paths.
AtoX <- rexp(1000, 4)
AtoY <- rexp(1000, 2.5)
XtoY <- rexp(1000, 10)
XtoB <- rexp(1000, 3)
YtoB <- rexp(1000, 5)
# Length of path from A to X to Y and A to Y to X.
AYX = AtoY + XtoY
AXY = AtoX + XtoY
# Total time of paths from A to B.
AXB = AtoX + XtoB
AYB = AtoY + YtoB
AXYB = AtoX + XtoY + YtoB
AYXB = AtoY + XtoY + XtoB
# Taking the fastest path of all paths.
minAXB = min(AXB)
minAYB = min(AYB)
minAXYB = min(AXYB)
minAYXB = min(AYXB)
# Taking an average of the fastest paths.
averageTravelTime =
mean(minAXB + minAYB + minAXYB + minAYXB)
Does this look correct?