Rebuild PDFs from original data

1 次查看(过去 30 天)
Hello,
I have two histograms for two classes data (class1 and class2) and I want to create for each class a Chi2 distribution that represents the original data.
So how and what I should extract from the original data (mean, std, variance, ......) to build my two Chi2 distributions ?
Thanks.
load('data.mat')
histogram(class1)
hold on
histogram(class2)

回答(1 个)

Star Strider
Star Strider 2021-5-1
The is not an option for histfit or the others, however calculating the parameters is straightforward —
LD = load('data.mat');
class1 = LD.class1;
class2 = LD.class2;
figure
subplot(2,1,1)
histogram(class1,1000, 'DisplayStyle','stairs')
xlabel('Bin')
ylabel('Count')
xlim([0 1])
title('Class 1')
[muest1,sdest1] = normfit(class1);
text(0.5,max(ylim), sprintf('\\mu = %.3f\n\\sigma = %.3f',muest1,sdest1), 'Horiz','left', 'Vert','top')
grid
subplot(2,1,2)
histogram(class2,1000, 'DisplayStyle','stairs')
xlabel('Bin')
ylabel('Count')
xlim([0 1])
title('Class 2')
[muest2,sdest2] = normfit(class2);
text(0.5,max(ylim), sprintf('\\mu = %.3f\n\\sigma = %.3f',muest2,sdest2), 'Horiz','left', 'Vert','top')
grid
.
  4 个评论
Jeff Miller
Jeff Miller 2021-5-2
These data don't seem to come from any chi^2 distribution. The mean of a chi^2 equals its degrees of freedom, which is at least 1. These data sets have means far less than 1, so that is simply incompatible with any chi^2.
Star Strider
Star Strider 2021-5-2
@Jeff Miller — I agree. I was also not aware that data were ever -distributed, only that parameters were.

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by