I have some observations from an unknown source. This set of observations is x, for example :
x = [97 , 102.3, 95.05 , 89.1 , 117 , ...]; % this is just an example. data set could contain any thing.
provided x is large enough, I should be able to say something about the probability distribution function, right?
So how can I do this in MATLAB so I can get p(x = 101)
or p(x = 5)
? the first one will probably be very high.
Any kind of assumption (normal distribution etc.) is ok, I just want a simple answer for probabilities. And maybe I don't have to explicitly know the PDF, I just need a way to implement p(x = x_star)
, where x_star is not necessarily a member of x. How can I do this?
Thanks for any help !
My Attempts
The simplest attempt is length(find(x==x_star))/length(x)
, however this returns zero if for example there is no 101
in the observations. However looking at the distribution it should be a high probability.
Edit :
My function according to Kamtal's answer :
function p = get_probability_from_sample_set(S, X)
% finds the probability that a sample from S is equal to X
[mu,sigma] = normfit(S);
z = 1:200;
xfit = normpdf(z,mu,sigma);
p = xfit(find(z == X));
end
p
returns []
. Where am I doing wrong?