1
$\begingroup$

I want to calculate the probability of a discrete random variable. First I defined the function:

pw = Piecewise[{{1/8, x == 1}, {2/8, x == 2}, {5/8, x == 3}}, 0];

Next I used the following:

Probability[x <= 2.1, x \[Distributed] pw]

But this doesn't return an answer, am I doing something wrong?

$\endgroup$
3
$\begingroup$

pw is not a probability distribution. Use

pw = EmpiricalDistribution[{1/8, 2/8, 5/8} -> {1, 2, 3}]

to get

Probability[x <= 2.1, x \[Distributed] pw]

3/8

$\endgroup$
3
$\begingroup$
pw = Piecewise[{{1/8, x == 1}, {2/8, x == 2}, {5/8, x == 3}}, 0];
pd = ProbabilityDistribution[pw, {x, 0, Infinity, 1}];

Probability[x <= 2.1, x \[Distributed] pd]

0.375

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.