未验证 提交 c21a372e 编写于 作者: rictjo's avatar rictjo 提交者: GitHub

function_field

User defined function field. Default behaviour should yield same results as mean_field function
上级 6206ef3d
......@@ -1416,6 +1416,24 @@ class APCA ( object ) :
dimred = PCA()
def function_field ( data:np.array , function=lambda x,a : np.mean(x,a) ,
bSeparate:bool=False , axis_type:str=None ) :
# SAIGA FUNCTION FOR FUNCTIONAL FIELD CALCULATIONS !
lm0,lm1 = np.shape(data)
if axis_type=='0' or str(axis_type) == str(None) :
m0 = function( data , axis=0 )
ms0 = np.ones(lm0).reshape(-1,1) * m0.reshape(1,-1)
if axis_type=='0':
return ( ms0 )
if axis_type=='1' or axis_type is None :
m1 = function( data , axis=1 )
ms1 = m1.reshape(-1,1) * np.ones(lm1).reshape(1,-1)
if axis_type=='1' :
return ( ms1 )
if bSeparate :
return ( m1.reshape(-1,1)*m0.reshape(1,-1) , ( ms1 + ms0 ) * 0.5 )
return( 2*m1.reshape(-1,1)*m0.reshape(1,-1) / ( ms1 + ms0 ) )
def mean_field ( data:np.array , bSeparate:bool=False , axis_type:str=None ) :
lm0,lm1 = np.shape(data)
if axis_type=='0' or str(axis_type) == str(None) :
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册