How to calculate real probability of data

6 次查看(过去 30 天)
Hello, I have a slight question which maybe really simple but am getting stack somehow. Suppose we have a measured data say A=5*rand(1000,1). Suppose am to find the probability distribution of the data, I assume I would easily do this via histogram plot as the one inserted below. Which woul give probabilty distribution of the data in an histogram plot. My question is, is there a way I can get the probability values in a matrix of the same dimenions as A. I mean the vallues that were used to plot the histogram, is there a way I can extract this information?
histogram(A,'Normalization','probability')

采纳的回答

Paul
Paul 2023-6-13
"is there a way I can get the probability values in a matrix of the same dimenions as A."
The number of bins in the histogram will always, or very nearly always, be less than number of elements in A. So I don't think this will be possible.
"I mean the vallues that were used to plot the histogram, is there a way I can extract this information?"
histogram returns an object from which the properties of the the histogram can be obtained via dot indexing:
rng(100);
A = 5*rand(1000,1);
h = histogram(A,'Normalization','probability');
h.Values % values of the bin heights
ans = 1×10
0.0980 0.1010 0.1060 0.0940 0.1000 0.1160 0.0920 0.0980 0.0930 0.1020
If the elements of A are supposed to be samples from a continuous distribution, then it may be better to use the pdf normalization of histogram. I guess it depends on how the histogram is going to be used.

更多回答(1 个)

Torsten
Torsten 2023-6-13
编辑:Torsten 2023-6-13
Usually, one assumes that the underlying distribution for the realizations in A is continuous. This implies that each element in A has probability 0. You could extract probabilities for an element to be in a certain interval, e.g. In the following example, if you take as interval [x(i),x(i+1)], then the probability that the random variable gets a value within this interval is approximately f(i+1)-f(i).
A = 5*rand(1000,1);
[f,x] = ecdf(A);
plot(x,f)

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by