📜  Python中的 sympy.stats.NormalGamma()函数

📅  最后修改于: 2022-05-13 01:54:54.656000             🧑  作者: Mango

Python中的 sympy.stats.NormalGamma()函数

借助sympy.stats.NormalGamma()方法,我们可以创建具有多元正态伽马分布的二元联合随机变量。

Syntax:  sympy.stats.NormalGamma(syms, mu, lamda, alpha, beta)
 
Parameters:
 syms: the symbol, for identifying the random variable
 mu: a real number, the mean of the normal distribution
 lambda: a positive integer
 alpha: a positive integer
 beta: a positive integer

Returns:  a bivariate joint random variable with multivariate Normal gamma distribution.

示例 #1:

Python3
# import sympy, NormalGamma, density, symbols
from sympy.stats import density, NormalGamma
from sympy import symbols, pprint
  
y, z = symbols('y z')
  
# using sympy.stats.NormalGamma() method
X = NormalGamma('X', 0, 1, 2, 3)
norGammaDist = density(X)(y, z)
  
pprint(norGammaDist)


Python3
# import sympy, NormalGamma, density, symbols
from sympy.stats import density, NormalGamma
from sympy import symbols, pprint
  
y, z = symbols('y z')
  
# using sympy.stats.NormalGamma() method
X = NormalGamma('X', 1 / 2, 3, 4, 6)
norGammaDist = density(X)(y, z)
  
pprint(norGammaDist)


输出 :

2   
                    -y *z 
                    ------
    ___  3/2  -3*z    2   
9*\/ 2 *z   *e    *e      
--------------------------
             ____         
         2*\/ pi      

示例 #2:

Python3

# import sympy, NormalGamma, density, symbols
from sympy.stats import density, NormalGamma
from sympy import symbols, pprint
  
y, z = symbols('y z')
  
# using sympy.stats.NormalGamma() method
X = NormalGamma('X', 1 / 2, 3, 4, 6)
norGammaDist = density(X)(y, z)
  
pprint(norGammaDist)

输出 :

2 
                      -3*z*(y - 1/2)  
                      ----------------
      ___  7/2  -6*z         2        
108*\/ 6 *z   *e    *e                
--------------------------------------
                  ____                
                \/ pi