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

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

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

sympy.stats.MultivariateBeta()方法的帮助下,我们可以使用 Dirichlet/Multivariate Beta Distribution 创建一个连续随机变量。

它是 beta 分布的多元泛化。

Syntax: sympy.stats.MultivariateBeta(syms, alpha)

Parameters: 
 syms: the symbol
 alpha: positive real numbers signifying concentration numbers

Returns: 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)


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)


输出 :

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