![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/603545/image.png)
Rebuild PDFs from original data
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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)
0 comentarios
Respuestas (1)
Star Strider
el 1 de Mayo de 2021
The
is not an option for histfit or the others, however calculating the parameters is straightforward —
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/603545/image.png)
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 comentarios
Jeff Miller
el 2 de Mayo de 2021
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
el 2 de Mayo de 2021
@Jeff Miller — I agree. I was also not aware that data were ever
-distributed, only that parameters were.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/604315/image.png)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!