Open In App

Sympy – stats.P() in Python

Last Updated : 08 Jun, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

With the help of sympy.stats.P() method, we can find the probability of an occasion or a hypothetical situation by using sympy.stats.P() method.

Syntax : sympy.stats.P(function)
Return : Return the probability of a hypothesis.

Example #1 :
In this example we can see that by using sympy.stats.P() method, we are able to find the probability of an hypothetical situation by using this method.




# Import sympy, P, Dice
from sympy.stats import P, Die
  
situation = Die('X', 2)
  
# Using stats.P() method
gfg = P(situation < 5)
  
print(gfg)


Output :

1

Example #2 :




# Import sympy, P, Dice
from sympy.stats import P, Die
  
situation = Die('X', 6)
  
# Using stats.P() method
gfg = P(situation > 3)
  
print(gfg)


Output :

1/2


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads