Python中的 sympy.stats.MultivariateEwens()函数
借助sympy.stats.MultivariateEwens()方法,我们可以创建具有多元 Ewens 分布的离散随机变量。
Syntax: sympy.stats.MultivariateEwens(syms, n, theta)
Parameters:
syms: the symbol
n: size of the sample or the integer whose partitions are considered, a positive integer
theta: mutation rate, must be positive real number
Returns: a discrete random variable with Multivariate Ewens Distribution.
示例 #1:
Python3
# import sympy, MultivariateEwens, density, Symbol
from sympy.stats.joint_rv_types import MultivariateEwens
from sympy.stats import density
from sympy import Symbol, pprint
a = Symbol('a', positive = True)
b = Symbol('b', positive = True)
# using sympy.stats.MultivariateEwens() method
E = MultivariateEwens('E', 2, 1)
mveDist = density(E)(a, b)
pprint(mveDist)
Python3
# import sympy, MultivariateEwens, density, Symbol
from sympy.stats.joint_rv_types import MultivariateEwens
from sympy.stats import density
from sympy import Symbol, pprint
a = Symbol('a', positive = True)
b = Symbol('b', positive = True)
# using sympy.stats.MultivariateEwens() method
E = MultivariateEwens('E', 2, 1 / 2)
mveDist = density(E)(a, b)
pprint(mveDist)
输出 :
/ -a2
| 2
|------- for a1 + 2*a2 = 2
示例 #2:
Python3
# import sympy, MultivariateEwens, density, Symbol
from sympy.stats.joint_rv_types import MultivariateEwens
from sympy.stats import density
from sympy import Symbol, pprint
a = Symbol('a', positive = True)
b = Symbol('b', positive = True)
# using sympy.stats.MultivariateEwens() method
E = MultivariateEwens('E', 2, 1 / 2)
mveDist = density(E)(a, b)
pprint(mveDist)
输出 :
/ -a1 -2*a2
|8*2 *2
|------------- for a1 + 2*a2 = 2
< 3*a1!*a2!
|
| 0 otherwise
\