Find Probability of numbers using histogram

Given a large m*n matrix is there any way to calculate the weights of elements and compute their probabilities?

 Réponse acceptée

Ameer Hamza
Ameer Hamza le 18 Mai 2018
Modifié(e) : Ameer Hamza le 18 Mai 2018
Use histcounts to estimate the distribution of your matrix element
[density bins] = histcounts(yourMatrix);
Then to estimate probability from the histogram, find the bin which includes your number, and get the density of that bin as shown here
targetBin = find(bins > testNumber, 1); % this will give the density of 'testNumber'
probability = density(targetBin - 1);

Plus de réponses (1)

Try
histogramObject = histogram(yourData, 'Normalization', 'probability');
then look at all the informative things returned in the histogramObject.

Community Treasure Hunt

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

Start Hunting!

Translated by