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


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。