how to normalize two graphs to each other?

I want to plot these two graphs to fit each other perfectly. Is this possible?
pd = makedist('Normal','mu',1.81576e-05,'sigma',0.00863661);
x = -0.25:0.001:0.25;
y = pdf(pd, x);
plot(x,y)

10 commentaires

Image Analyst
Image Analyst le 27 Sep 2021
Not sure what that means, but you can't. The left one is quantized much, much more than the right one. If you overlay them you'll see.
I'm using histfit() to fit the histogram, but it doesn't quite fit. I'm trying to fit manually but I can't. Any ideas on how to do it?
the cyclist
the cyclist le 27 Sep 2021
Can you explain the goal more precisely? In general, it is not possible to fit data "perfectly".
It may help if we understood the purpose better.
I get this graph when I fit with histfit command. It would be great if I could pull the fitting a little higher. For example, if it catches the 2nd peak.
the cyclist
the cyclist le 27 Sep 2021
Modifié(e) : the cyclist le 27 Sep 2021
@Star Strider has posted an answer that does what you seem to want.
But I would be really cautious about this approach, which is why I asked about the purpose.
Calling this manually adjusted histogram a "fit" to the data is probably a bad idea. Fitting data means that you have some metric (e.g. mean squared error) that is minimized. That fitted distribution will then be the one that has the maximum likelihood of being the distribution that generated the original data. Your manipulated curve may look better to your eye -- but it is no longer a mathematical fit.
Also, small changes in how the binning is done can make large changes in the counts, and the apparent data peaks. Manually shifting the "fit" to the peak of a histogram is not very robust.
Finally, I notice that the data that you posted in noise_filt.mat does not look at all like a normal distribution, so why are you fitting with a normal? That is the true reason why you do not fit the peak well.
Star Strider
Star Strider le 27 Sep 2021
@the cyclist — I agree, however @studentmatlaber and I have had this discussion before. This appears to be simply cosmetic.
studentmatlaber
studentmatlaber le 27 Sep 2021
Modifié(e) : studentmatlaber le 27 Sep 2021
Thank you very much for your comments. I thought it looked like a normal distribution, but which distribution do you think it is?
Please do not hold back your thoughts. If not a normal distribution, which distribution? @the cyclist @Star Strider
Star Strider
Star Strider le 28 Sep 2021
@studentmatlaber — It appears to be a normal distribution to me, howver since I have no idea what the data are, others (particularly the lognormal distribution or the Bernoulli distibution) could be appropriate. I doubt that there is any specific way to determine the distribution that best describes any particular set of data, other than perhaps fitting the data to different distributions to see which one works best.
.
I got fit as student's t distribution. Thank you for your help.

Connectez-vous pour commenter.

 Réponse acceptée

Try something like this —
D = randn(1,500);
figure
hfh = histfit(D);
hfh(2).YData = hfh(2).YData * max(hfh(1).YData)/max(hfh(2).YData); % Scale Line To Approximate Histogram Peak
Experiment to get different results.
.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by