Help with gmdistribution and feeding model into function

조회 수: 3 (최근 30일)
dsmalenb
dsmalenb 2020년 8월 13일
댓글: dsmalenb 2020년 8월 13일
Hi Team!
I have a question and I hope that someone can perhaps show me where I am missing something. I am trying to implement the Hellinger Distance. The Matlab code can be found here. Try as I might, I cannot get it to work. I wrote the toy program below to try to figure out the issue and I still can't get it working. My code is:
clear all
clc
mu1 = [1 2;-3 -5];
sigma1 = [1 1]; % shared diagonal covariance matrix
mu2 = [1 4;-1 4];
sigma2 = [1 1]; % shared diagonal covariance matrix
gm1 = gmdistribution(mu1,sigma1)
gm2 = gmdistribution(mu2,sigma2)
% Calculate Hellinger Distance
% Error in this single line:
H = uHellingerJointSupport2_ND(gm1,gm2)
Now I should be getting a single number between 0 and 1 but I am getting the following errors:
Unrecognized method, property, or field 'Mu' for class 'gmdistribution'.
Error in classreg.learning.internal.DisallowVectorOps/subsref (line 22)
[varargout{1:nargout}] = builtin('subsref',this,s);
Error in mergeDistributions (line 16)
model.Mu = [ model1.Mu, model2.Mu ] ;
Error in uHellingerJointSupport2_ND>main_uHellinger (line 77)
f0 = mergeDistributions( f1, f2, [0.5 0.5], 0 ) ;
Error in uHellingerJointSupport2_ND (line 51)
H = main_uHellinger(f1, f2, useWeightedHellinger) ;
I have gone through the individual functions and I just don't understand why my toy example will not work. If anyone can provide some insights, I would be very thankful.

답변 (1개)

Cris LaPierre
Cris LaPierre 2020년 8월 13일
I think the issue is you are trying to use the MATLAB function gmdistribution to create the input for the file exchange function uHellingerJointSupport2_ND. However, gmdistribution returns a gmdistribution object, while uHellingerJointSupport2_ND expects the inputs to be structure arrays with the following fields:
  • Mu
  • w
  • Cov
  댓글 수: 1
dsmalenb
dsmalenb 2020년 8월 13일
Oh I see! I will need to try that later today. Thanks for the thought! I will post how that works out.

댓글을 달려면 로그인하십시오.

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by