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')
0 件のコメント
採用された回答
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
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.
0 件のコメント
その他の回答 (1 件)
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)
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!