%Histogram Program
clc;
load TEC2.txt; %Loading the file
x=[];
x=TEC2(:,4);
x_min=min(x);
x_max=max(x);
binWidth = 0.7;
binCtrs = x_min:binWidth:x_max;
hist(x,binCtrs);
xlabel('TEC'); ylabel('Frequency'); ylim([0 15]);
h = get(gca,'child');
set(h,'FaceColor',[.98 .98 .98],'EdgeColor',[.94 .94 .94]);
counts = hist(x,binCtrs);
hold on
plot(binCtrs,counts,'o');
hold off
paramEsts = wblfit(x);
n = length(x);
prob = counts / (n * binWidth);
bar(binCtrs,prob,'hist');
h = get(gca,'child');
set(h,'FaceColor',[.9 .9 .9]);
xlabel('TEC'); ylabel('Probability Density'); ylim([0 0.2]);
xgrid = linspace(0,20,100);
pdfEst = wblpdf(xgrid,paramEsts(1),paramEsts(2));
line(xgrid,pdfEst)