當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


Python sympy.stats.NormalGamma()用法及代碼示例


借助於sympy.stats.NormalGamma()方法,我們可以創建具有多元正態伽馬分布的雙變量聯合隨機變量。

用法: sympy.stats.NormalGamma(syms, mu, lamda, alpha, beta)
 
參數:
 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

返回: 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)

輸出:

                      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       

相關用法


注:本文由純淨天空篩選整理自ravikishor大神的英文原創作品 sympy.stats.NormalGamma() function in Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。