How to set bins correctly when graphing a pdf

7 visualizaciones (últimos 30 días)
Matt Trenton
Matt Trenton el 12 de Nov. de 2018
Editada: the cyclist el 13 de Nov. de 2018
I made an histogram with the following code:
histogram(k,'Normalization','pdf')
But when I set an specific number of bins, for example:
histogram(k,15,'Normalization','pdf')
The probabilities stop matching.
I know the exact numbers change given it groups more or less data into one bin, but the whole thing doesn't even add up to one as it should given we're talking about probabilities.
Why is it and how can I fix it????

Respuestas (1)

the cyclist
the cyclist el 13 de Nov. de 2018
Editada: the cyclist el 13 de Nov. de 2018
The height of the pdf does not give the probability. The height of the pdf times the width of the interval gives the probability. You've changed the width of the interval (i.e. the bin width).
Use the name-value pair (...,'Normalization','probability') if you want the heights to be the probabilities.

Categorías

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

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by