Skip to content

The differen between Python and Matlab version #49

@StarrySky-SHT

Description

@StarrySky-SHT

There some different realized method between Python and Matlab version.
For example, for explained variance ratio_:

In python:

def marginal_variances(marginal):
    ''' Computes the relative variance explained of each component
        within a marginalization
    '''
    D, Xr = self.D[marginal], X.reshape((X.shape[0],-1))
    return [np.sum(np.dot(D[:,k], Xr)**2) / total_variance for k in range(D.shape[1])]

Thus, the explained variance ratio_ = ‖w_k^T X‖² / ‖X‖² (a kind of projection energy)

In matlab:

Z = W'*X;
for i=1:size(W,2)
    explVar.cumulativeDPCA(i) = 100 - sum(sum((X - V(:,1:i)*Z(1:i,:)).^2)) / explVar.totalVar * 100;    
    explVar.componentVar(i) = 100 - sum(sum((X - V(:,i)*Z(i,:)).^2)) / explVar.totalVar * 100;    
   
    for j=1:length(Xmargs)
        ZZ = Xmargs{j} - V(:,i)*(W(:,i)'*Xmargs{j});
        explVar.margVar(j,i) = (explVar.totalMarginalizedVar(j) - sum(ZZ(:).^2)) / explVar.totalVar * 100;    
    end
end

the explained variance ratio_ = 1 − ‖X − v_k w_k^T X‖² / ‖X‖² (a kind of reconstruction-based metrics)

In addition, the significance_analysis seems also different in the two version.

Could you clarify whether these differences are intentional? What version should we use? Or I miss something important that lead to me misunderstand the code?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions