MATLAB: Find Probability of numbers using histogram

distributionprobability

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

Best 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);
Related Question