ali-design / visual-balance

4 stars 1 forks source link

reproduce the thesis #1

Open aunhappy opened 1 year ago

aunhappy commented 1 year ago

Hello, I am trying to reproduce your thesis. But the result I get is not the same as yours. I tried to write the plotGMM function myself, this is the result after running the code. But it seems to be different from the picture provided in the paper. can you help me? plotGMM.m

function plotGMM(mixture)

% Extract data from the 'ans' structure
numClusters = mixture.K;
clusterData = mixture.cluster;
% Assuming your data is stored in a matrix called 'data' with dimensions numPnts x D
% scatter(data(:, 1), data(:, 2), 10, 'filled'); % Adjust the marker size (10) as needed
% hold on;
for k = 1:numClusters
    % Extract cluster parameters
    mu = clusterData(k).mu;
    sigma = clusterData(k).R;

    % Create grid for plotting the Gaussian contour
    x = linspace(mu(1) - 3*sqrt(sigma(1, 1)), mu(1) + 3*sqrt(sigma(1, 1)), 100);
    y = linspace(mu(2) - 3*sqrt(sigma(2, 2)), mu(2) + 3*sqrt(sigma(2, 2)), 100);
    [X, Y] = meshgrid(x, y);
    XY = [X(:) Y(:)];

    % Evaluate the Gaussian pdf
    z = mvnpdf(XY, mu, sigma);
    Z = reshape(z, size(X));

    % Plot the Gaussian contour
    contour(X, Y, Z, 'LineWidth', 1);
end

hold off;

end

I tried this

load('dataset_1K.mat'); 
process_GMM_Layout(dataset);
plotGMM(ans);

and got the image

aunhappy commented 1 year ago

1