# Calculating the mean of a sum of independent variables, with the same distribution, when the number of terms varies?

#### MathNugget

##### New member
Suppose you have a set of max 2 independent variables, [imath]A_1 \: and \: A_2[/imath]~[imath]Exp(\lambda_i)[/imath], and the probability to go from [imath]A_1[/imath] to [imath]A_2[/imath] is [imath]b\in[0, 1][/imath].
Say A is the sum of [imath]A_1 \: and \: A_2[/imath] ([imath]A_2[/imath] can be considered 0 in the situation we don't go from [imath]A_1[/imath] to [imath]A_2[/imath]).
How would I calculate the mean of A? E(A)

It looks to me like it's a discrete function, so E(A) would be [imath]\sum outcome[/imath] x P(outcome) , for all possible outcomes.
So, it would be
E(A)=(1-b)[imath]A_1[/imath]+b([imath]A_1[/imath] + [imath]A_2[/imath]).
How am I supposed to get an actual value out of it?

and the probability to go from A1A_1A1 to A2A_2A2 is b∈[0,1]b\in[0, 1]b∈[0,1].
Does this mean that you pick [imath]A_2[/imath] with probability [imath]b[/imath] or [imath]A_1[/imath] with probability [imath]1-b[/imath] ?

Does this mean that you pick [imath]A_2[/imath] with probability [imath]b[/imath] or [imath]A_1[/imath] with probability [imath]1-b[/imath] ?
I was trying to say [imath]A_1[/imath] happens certainly, but [imath]A_2[/imath] might happen (with probability b). I think it would be simpler to say it's a Bernoulli (coin flip) whether [imath]A_2[/imath] happens, while [imath]A_1[/imath] is a given to occur.
I guess I should have quoted the problem more clearly (for context):
[imath]A_1[/imath] is the time it takes event 1 to happen (it certainly happens).
[imath]A_2[/imath] is the time it takes event 2 to happen (if the coinflip of probability b gives it a go).

So the 2 possible outcomes are: just first event happens (and A = [imath]A_1[/imath]) or both happen (and A is the sum of [imath]A_1[/imath] and [imath]A_2[/imath] )

If I understand the problem statement correctly...

[imath]E(A) = E(A_1) + E(A_2) = A_1+\dfrac{1}{2\lambda}[/imath]

Details below:
[imath]E(A_1) = A_1 \text{ as this happens certainly}[/imath]

Let [imath]X[/imath] the r.v represents the outcome of the coin flip. Assume [imath]X[/imath] is uniformly distributed over [imath][0,1][/imath], the pdf [imath]f(x) = 1; 0 \le x \le 1[/imath]

[imath]\text{By conditional expectation, } E(A_2) = E[E(A_2|X=x)][/imath] and [imath]E(A_2|X=x) = x\cdot \dfrac{1}{\lambda}[/imath]
[imath][/imath][imath][/imath][imath][/imath][imath][/imath][imath][/imath]

Thus,
$E(A_2) = \int_0^1 E(A_2|X=x) \times f(x) \, dx =\int_0^1 x\cdot \dfrac{1}{\lambda}\, dx = \dfrac{1}{2\lambda}$

I was trying to say [imath]A_1[/imath] happens certainly, but [imath]A_2[/imath] might happen (with probability b). I think it would be simpler to say it's a Bernoulli (coin flip) whether [imath]A_2[/imath] happens, while [imath]A_1[/imath] is a given to occur.
I guess I should have quoted the problem more clearly (for context):
[imath]A_1[/imath] is the time it takes event 1 to happen (it certainly happens).
[imath]A_2[/imath] is the time it takes event 2 to happen (if the coinflip of probability b gives it a go).

So the 2 possible outcomes are: just first event happens (and A = [imath]A_1[/imath]) or both happen (and A is the sum of [imath]A_1[/imath] and [imath]A_2[/imath] )
So you pick [imath]A_1[/imath] with probability [imath]1-b[/imath] and [imath]A_1+A_2[/imath] with probability [imath]b[/imath].

Let's simplify slightly: two variables, not necessarily independent, [imath]B_1[/imath] and [imath]B_2[/imath] with CDFs [imath]F_1, F_2[/imath] are picked with probabilities [imath]1-b[/imath] and [imath]b[/imath], where the picking happens independently of [imath]B_1[/imath] and [imath]B_2[/imath]. Let's call the resulting variable [imath]B[/imath]. To compute CDF of B we ask what is the probability that [imath]B \leq a[/imath] ?

We can consider 4 events:
• [imath]v_1[/imath] : [imath]B_1[/imath] is picked with probability [imath]1-b[/imath],
• [imath]v_2[/imath] : [imath]B_2[/imath] is picked with probability [imath]b[/imath],
• [imath]v_3[/imath] : [imath]B_1 \leq a[/imath] with probability [imath]F_1(a)[/imath]
• [imath]v_4[/imath] : [imath]B_2 \leq a[/imath] with probability [imath]F_2(a)[/imath]
We are interested in probability of [imath](v_1 \cap v_3) \cup (v_2 \cap v_4)[/imath]. But since [imath]v_1[/imath] and [imath]v_2[/imath] do not intersect we can claim that:
$P((v_1 \cap v_3) \cup (v_2 \cap v_4)) = P(v_1 \cap v_3) + P(v_2 \cap v_4)$and since [imath]v_1,v_2[/imath] are independent of [imath]v_3,v_4[/imath] :
$P((v_1 \cap v_3) = P(v_1)P(v_3) = (1-b) F_1(a)$$P(v_2 \cap v_4) = P(v_2)P(v_3) = b F_2(a)$which means that the CDF of [imath]B[/imath] is [imath](1-b)F_1 + bF_2[/imath].