How can I bin a set of data probability and plot it as a bar chart ?

11 vues (au cours des 30 derniers jours)
Gabs
Gabs le 16 Sep 2015
Commenté : Gabs le 16 Sep 2015
I have a set of observed data of 3 years of hourly measurements "x" (25920x1 double) with min = 0.00003484 and max = 3.8787 ;
I want to plot a figure that has the following characteristics:
1. x axis = x values, y axis = probability density
2. X should be binned for one month and plotted as a bar chart (look like a bar chart)
3. A normal pdf (based on the mean and std of the observed data) must be plotted
This is in order to compare the existing data and a normal dist or how well the fit in the graph.
I don't even know how to start, how can I do this? Any idea? I am having trouble binning the data and plotting it as a bar chart of the pdf. The normal pdf plotting is not an issue

Réponse acceptée

the cyclist
the cyclist le 16 Sep 2015
If you have the Statistic and Machine Learning Toolbox, you could use the histfit command.

Plus de réponses (1)

Image Analyst
Image Analyst le 16 Sep 2015
Decide how many bins you want and then call histcounts. For example (untested)
x = 4*randn(1, 10000);
numBins = 30;
[counts, edges] = histcounts(x, numBins);
binWidth = edges(2)-edges(1);
binCenters = edges(1:end-1) + binWidth/2;
bar(binCenters, counts, 'BarWidth', 1, 'FaceColor', 'b');
grid on;
To get the PDF, divide counts by the total number of counts. Then do the other stuff - if you still have trouble then write back.
  1 commentaire
Gabs
Gabs le 16 Sep 2015
I have an older version which does not have the histcounts function

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!

Translated by