# Finding the probability of a given x-value on a histogram

10 vues (au cours des 30 derniers jours)
Nithila MK le 2 Août 2020
Commenté : Nithila MK le 4 Août 2020
I have a data set that I use to plot a histogram with the following code:
edges = linspace(0, 1, 21);
figure(1); h = histogram(dataSet,'BinEdges', edges, 'Normalization', 'probability');
title(['Eccentricity Distribution']); xlabel('Eccentricity'); ylabel('Probability'); ylim([0 1]);
I then find the median of the data set using:
med = median(dataSet);
I now want to find the probability of this median value from the histogram. At the very least I would need the edges of the bin in which the median value is.
I tried using h.Values and h.Data but these two sets don't share a common indexing method that would allow me to find the index of the median value from h.Values and then use that to find the probability in h.Data.
##### 0 commentairesAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

If your dataset has discrete values, you don't need to get the histogram, rather just count how many times the median appear and divide by the total. If your dataset is continuos, than it doesn't make sense to say "how likely is the median", but rather "how likely is an interval around the median" or even to estimate the probability density function of it. Histogram methods are very unreliable for this, so I would advise to use something like ksdensity on your data.
##### 1 commentaireAfficher AucuneMasquer Aucune
Nithila MK le 4 Août 2020
Thanks for your response! I understand what you are saying. Something like ksdensity might make more sense.

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Data Distribution Plots dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!