HELP! Reading a probability from a CDF plot
4 次查看(过去 30 天)
显示 更早的评论
I have created a CDF plot of some temperature data, and I need to find exceedence probability. Is there a way to input a specific number (i.e. an x-value) and have MATLAB return the exceedence probability?
0 个评论
回答(3 个)
Matt Tearle
2011-3-9
You basically want an inverse CDF calculation (based on measured data, rather than a formula)?
% Make some fake data
x = -4:0.2:4;
y = (1+tanh(x))/2;
% Pick a probability
yval = 0.72;
% Interpolate to find x such that y(x) = yval
f = @(t) interp1(x,y,t,'pchip') - yval;
xval = x(find(y>=yval,1,'first'))
xval = fzero(f,xval)
% See the result
plot(x,y,'o-',xval,yval,'*')
The idea is to find the first data point that exceeds the given probability, then use that as an initial guess to a root-finding algorithm to find the actual x such that y(x) = prob. The tricky thing is that you have to interpolate to get a function to do root-finding on. Hence the use of interp1.
0 个评论
Adele
2011-3-10
1 个评论
Matt Tearle
2011-3-11
My code was intended to show how to do the interpolation (your question implied you already had the empirical CDF).
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Descriptive Statistics and Visualization 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!