HomeLanguagessympy.stats.variance() function in Python

sympy.stats.variance() function in Python

In mathematics, the variance is the way to check the difference between the actual value and any random input, i.e variance can be calculated as a squared difference of these two values. With the help of sympy.stats.variance() method, we can calculate the value of variance by using this method.

Syntax : sympy.stats.variance(value)

Return : Return the value of variance.

Example #1 :
In this example we can see that by using sympy.stats.variance() method, we are able to calculate the value of variance using this method.




# Import Sympy and variance
from sympy.stats import P, variance, Die
  
X, Y = Die('X', 5), Die('Y', 3)
  
# Using stats.variance() method
gfg = variance(X + Y)
  
print(gfg)


Output :

8/3

Example #2 :




# Import Sympy and variance
from sympy.stats import P, variance, Die
  
X, Y = Die('X', 2), Die('Y', 4)
  
# Using stats.variance() method
gfg = variance(X * Y)
  
print(gfg)


Output :

75/16
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32688 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
7057 POSTS0 COMMENTS
Nicole Veronica
12198 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12293 POSTS0 COMMENTS
Shaida Kate Naidoo
7182 POSTS0 COMMENTS
Ted Musemwa
7447 POSTS0 COMMENTS
Thapelo Manthata
7160 POSTS0 COMMENTS
Umr Jansen
7150 POSTS0 COMMENTS