フィルターのクリア

How to calculate real probability of data

5 ビュー (過去 30 日間)
okoth ochola
okoth ochola 2023 年 6 月 13 日
回答済み: Paul 2023 年 6 月 13 日
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