How can I define a distribution and get the expectation in Mathematica for $a=a_H$ with probability $\lambda$ and $a=a_L$ with probability $1−\lambda$, where $\lambda\in(0,1)$?
2 Answers
There are many ways. Here's one:
dist = TransformedDistribution[x aH + (1 - x) aL, x \[Distributed] BernoulliDistribution[λ]]
Mean[dist]
(* aL+aH λ-aL λ *)
As JimB notes, there are many ways. Here's another:
dist = EmpiricalDistribution[{\[Lambda], 1 - \[Lambda]} -> {aH, aL}];
Mean[dist]
(* aL (1 - \[Lambda]) + aH \[Lambda] *)