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


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


借助於sympy.stats.MultivariateBeta()方法,我們可以創建具有Dirichlet /Multivariate Beta Distribution的連續隨機變量。

它是beta分布的多元概括。

用法:sympy.stats.MultivariateBeta(syms, alpha)

參數:
 syms:the symbol
 alpha:positive real numbers signifying concentration numbers

返回:a continuous random variable with multivariate beta distribution.

範例1:

Python3

# import sympy, MultivariateBeta, density, Symbol 
from sympy.stats.joint_rv_types import MultivariateBeta 
from sympy.stats import density 
from sympy import Symbol, pprint 
  
a = Symbol('a', positive = True) 
b = Symbol('b', positive = True) 
x = Symbol('x') 
y = Symbol('y') 
  
# using sympy.stats.MultivariateBeta() method 
M = MultivariateBeta('M', [a, b]) 
mvbDist = density(M)(x, y) 
  
pprint(mvbDist)

輸出:



 a1 - 1  a2 - 1               
x      *y      *Gamma(a1 + a2)
------------------------------
     Gamma(a1)*Gamma(a2)     

範例2:

Python3

# import sympy, MultivariateBeta, density, Symbol 
from sympy.stats.joint_rv_types import MultivariateBeta 
from sympy.stats import density 
from sympy import Symbol, pprint 
  
x = Symbol('x') 
y = Symbol('y') 
  
# using sympy.stats.MultivariateBeta() method 
M = MultivariateBeta('M', [2, 1 / 2]) 
mvbDist = density(M)(x, y) 
  
pprint(mvbDist)

輸出:

  3*x  
-------
    ___
4*\/ y 



相關用法


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