How to estimate probabilities of an arbitrary range, based on the probability distribution of a given a data set of numbers?
18 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Clarisha Nijman
il 22 Ott 2018
Commentato: Clarisha Nijman
il 23 Ott 2018
Hello,
Given a series of values x, I want to estimate the probabilities of a range of numbers U, in(using) the probability distribution of the given series x. My code works for one value, but I need probabilities of a range, Can somebody give me some feedback please?
Thank you in advance.
This is the code:
%%Generate some data/series
x=randi([-2 50],25,1);
%Values/ranges of interest
U=[-100:100];
%define histogram and probability distribution of x
h = histogram(x);
h.Normalization = 'probability';%Changing count in probabilities
h.Values(U); %finding probabilities of range U
0 Commenti
Risposta accettata
Bruno Luong
il 22 Ott 2018
Modificato: Bruno Luong
il 22 Ott 2018
Use HISTCOUNTS then
N = histcounts(x, [-Inf, U, Inf]);
P = N(2:end) / sum(N)
4 Commenti
Più risposte (2)
Torsten
il 22 Ott 2018
%%Generate some data/series
X=randi([-2 50],25,1);
%Values/ranges of interest
U=[-100:100];
X = sort(X)
[countsX, binsX] = hist(X)
cdfX = cumsum(countsX) / sum(countsX)
extrap_left = (min(U) > max(X));
extrap_right = (max(U) > max(X));
p_U_left = interp1(binsX,cdfX,min(U),'linear',extrap_left)
p_U_right = interp1(binsX,cdfX,max(U),'linear',extrap_right)
p_U = p_U_right - p_U_left
4 Commenti
Torsten
il 22 Ott 2018
Modificato: Torsten
il 22 Ott 2018
If you get discrete values from a random variable, say [ 1 2 4 5 6 ], how should it be possible to tell p({3}) ? (Hint: It's impossible).
In my opinion, the most reasonable estimate would be p=0 since it does not appear in the list.
If you know the distribution the values stem from, you can get a Maximum Likelihood Estimate (MLE) of the parameters describing the distribution. Having calculated these parameters, you can give estimates of probabilities for elements of your choice.
Bruno Luong
il 22 Ott 2018
Modificato: Bruno Luong
il 22 Ott 2018
not sure, is it what you want?
x=randi([-2 50],10000,1);
U=[-100:100];
h = histogram(x, U);
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!