Convert to Histogram figure
Afficher commentaires plus anciens
I have the probiblity distrbuion function (see the attached figure) i want to convert this figure to the histogram distbuion
i plot the PDF based on this code
for i=1:length(y_pred)
if y_pred(i) <= failure_threshold
mu =( i + Future_Cycle)*100;
mu=2300
break
end
end
sigma =100
xz = linspace(mu-200 , x1(end-2), 100);
yz = 0.1*gaussian(xz, mu, sigma) + min(y_pred);
plot(xz, yz, 'r-')

Réponses (1)
You might try something like this:
% first, re-creating something like your xz and yz:
pd = makedist('Normal',2300,100);
xz = linspace(2100,2900,100);
yz = 25*pdf(pd,xz)+0.7675;
plot(xz,yz,'r-','LineWidth',2);
grid on
% now, translate each of those yz values into a histogram count for the
% corresponding xz value:
max_count = 1000;
xz_counts = round(max_count*(yz-min(yz))/(max(yz)-min(yz)));
% replicating each xz value a certain number of times depending on yz:
xz_new = arrayfun(@(x,n)repmat(x,1,n),xz,xz_counts,'UniformOutput',false);
xz_new = [xz_new{:}];
% plot a histogram of the new replicated xz values, using the original xz
% values as the bin edges
figure()
histogram(xz_new,xz);
xlim(xz([1 end]));
Catégories
En savoir plus sur Histograms dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

