How to Normalize a Histogram without using fitdist and pdf or any other fitting functions?
3 views (last 30 days)
Show older comments
I am trying to create a histogram for a set of data that is normalized, i.e the sum of the bins or area under the curve is = 1. However, fitdist or histfit apply a fit and does not simply normalize the curve. Attached are two images. The first is the histogram I need to normalize, and the second immage is the histogram when I use fitdist. I need to insure that the histogram has a total area of 1 without using a fitting function that will manipulate the actual data. How do I nomalize the data without changing/fitting its acual values?
x_values = 0:0.01:5;
xx_values = 0:0.01:5;
data1 = load('343E_SCX_0p001-deviations.csv'); %343 Grain
len=length(data1);
limit=len/2+1;
StnDev1=reshape(data1(10,3:limit),len/2-1,1);
StsDev1=reshape(data1(10,limit+1:end),len/2-1,1);
pd = fitdist(StnDev1,'Normal');
y = pdf(pd,x_values);
%histogram(StnDev1);
plot(x_values,y,'b','LineWidth',2)
hold on
0 Comments
Accepted Answer
the cyclist
on 6 Sep 2021
Use the 'Normalization' Name-Value pair to the histogram function:
x_values = 0:0.01:5;
xx_values = 0:0.01:5;
data1 = load('343E_SCX_0p001-deviations.csv'); %343 Grain
len=length(data1);
limit=len/2+1;
StnDev1=reshape(data1(10,3:limit),len/2-1,1);
histogram(StnDev1,'Normalization','probability')
More Answers (0)
See Also
Categories
Find more on Probability Distributions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!