- Mu
- w
- Cov
Help with gmdistribution and feeding model into function
3 views (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
Cris LaPierre
on 13 Aug 2020
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:
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!