Probability of max/min of independent random variables #24755
-
I tried looking for issues mentioning this, but i can't find anything. I don't think this is implemented, but i could be wrong. from sympy.stats import Die, P
from sympy import Max
X = Die("", 3)
Y = Die("", 6)
P(max(X,Y)>1)
P(Max(X,Y)>1) Both of the last 2 lines fail. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Using The correct way is In [6]: from sympy.stats import Die, P
...: from sympy import Max
...: X = Die("", 3)
...: Y = Die("", 6)
In [7]: Max(X, Y) > 1
Out[7]: Max(, ) > 1
In [8]: P(Max(X, Y) > 1)
---------------------------------------------------------------------------
ValueError: Overlapping Random Variables Why does it think that the variables are overlapping? That's because you gave them both the same name (the empty string) which also explains the weird printing. If you give them different names then you'll get an answer: In [9]: from sympy.stats import Die, P
...: from sympy import Max
...: X = Die("X", 3)
...: Y = Die("Y", 6)
In [10]: Max(X, Y) > 1
Out[10]: Max(X, Y) > 1
In [11]: P(Max(X, Y) > 1)
Out[11]:
17
──
18
In [12]: P(Max(X, Y) > 2)
Out[12]: 7/9
In [13]: P(Max(X, Y) > 3)
Out[13]: 1/2
In [14]: P(Max(X, Y) > 4)
Out[14]: 1/3
In [15]: P(Max(X, Y) > 5)
Out[15]: 1/6
In [16]: P(Max(X, Y) > 6)
Out[16]: 0 |
Beta Was this translation helpful? Give feedback.
Using
max(X, Y)
will fail becausemax
is not a symbolic function (and cannot be overloaded by a dunder).The correct way is
Max(X, Y)
and in that case the error is:Why does it think that the variables are overlapping? That's because you gave them both the same name (the empty string) which also explains the weird printing.
If you give them different names then you'll get an answer: