Skip to content

Mahal in matlab vs mahal in python #4

@balajisriram

Description

@balajisriram

I'm not sure this is the right place for this question. But here goes
I'm trying to code the maskedClusterQuality function in python and I'm having trouble replicating the mahal function outputs. Here is a sample of what I did.

PYTHON
`
import numpy
import scipy.io
x = numpy.random.normal(0,1,[100,12])
y = numpy.random.normal(17,1,[1000,12])

cov_x_inv = numpy.linalg.inv(numpy.cov(x,rowvar=False))
cdist = scipy.spatial.distance.cdist
md = cdist(y,x,'mahalanobis',cov_x_inv)
md_py = numpy.mean(md,axis=1)

scipy.io.savemat('D:\sample_feature.mat',dict(x=x,y=y,md=md,md_py=md_py))
`

MATLAB
load('D:\sample_features.mat') md_mat = mahal(y,x) plot(md_py,sqrt(md_mat),'ko')

Heres what I get...
mav_vs_python

Whats going on here?

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