How to get upper and lower bounds values from an empirical cumulative distribution?
54 次查看(过去 30 天)
显示 更早的评论
Hi, thanks for looking at my question. I've been googling, looking on here, and reading the Matlab documentation all afternoon and I can't work this out. I'm sure it's very simple, but I'm new to Matlab syntax so I need some help please!
I have a vector, which is a list of parameters from some data fitting. Specifically it's 250 values.
I want to find the 95% confidence bounds for the numbers in this vector. I can plot an ecdf:
I can also get the [x,y] values for this ECDF using:
[cdf_x,cdf_y] = ecdf(data_vector)
cdf = [cdf_x,cdf_y]
Where I am struggling is I cannot work out how to get the 95% upper and lower values from the array "cdf" (or any of the previous variables I've generated along the way). It's all empirical, so I just want to know the two values of cdf_y where cdf_x equals 0.025 and 0.975.
How can I do this?
NB. cdf_x doesn't have values specifically at 0.025 or 0.975 so it needs to either interpolate or give the closest result if possible.
0 个评论
采纳的回答
Star Strider
2020-10-20
编辑:Star Strider
2020-10-20
Using the prctile funciton on ‘cdf_y’ may work to calculate the percentiles (that appear to be what you want). To get the approximate ‘cdf_x’ values that are associated with them, use the interp1 function.
The code would go something like this:
prctv = prctile(cdf_y, [2.5 97.5]);
xval = interp1(cdf_y, cdf_x, prctv);
I cann ot write exact code since I do not have your data.
EDIT — (20 Oct 2020 at 15:42)
Corrected typographical error.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!