当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python sympy.stats.MultivariateEwens()用法及代码示例


借助于sympy.stats.MultivariateEwens()方法,我们可以创建具有Multivariate Ewens Distribution的离散随机变量。

用法:sympy.stats.MultivariateEwens(syms, n, theta)

参数:
 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

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

输出:

/   -a2                    
|  2                       
|-------  for a1 + 2*a2 = 2
<a1!*a2!                   
|                          
|   0         otherwise    
\                          

范例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    
\                                



相关用法


注:本文由纯净天空筛选整理自ravikishor大神的英文原创作品 sympy.stats.MultivariateEwens() function in Python。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。