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?

 Accepted Answer

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);

More Answers (1)

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

Asked:

on 18 May 2018

Answered:

on 18 May 2018

Community Treasure Hunt

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

Start Hunting!