Borrar filtros
Borrar filtros

how can ı normalize the histogram?

6 visualizaciones (últimos 30 días)
studentmatlaber
studentmatlaber el 12 de Oct. de 2021
Respondida: BhaTTa el 19 de Jul. de 2024 a las 3:29
I fit the histogram distribution fitter app as in the plot. But I want to normalize this one as well. How can I get both the fit and normalized histogram?

Respuestas (1)

BhaTTa
BhaTTa el 19 de Jul. de 2024 a las 3:29
Here is an example code snippet that demonstrates how to normalize a histogram and overlay a fitted distribution:
% Example data
data = randn(1000, 1); % Replace this with your actual data
% Create a normalized histogram
figure;
histogram(data, 'Normalization', 'pdf');
hold on;
% Fit a normal distribution to the data
pd = fitdist(data, 'Normal');
% Get the range for the fitted distribution
x_values = linspace(min(data), max(data), 100);
% Evaluate the fitted distribution's PDF
y_values = pdf(pd, x_values);
% Plot the fitted distribution
plot(x_values, y_values, 'r-', 'LineWidth', 2);
% Add labels and legend
xlabel('Data');
ylabel('Density');
title('Normalized Histogram with Fitted Distribution');
legend('Normalized Histogram', 'Fitted Distribution');
hold off;

Categorías

Más información sobre Histograms en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by