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.

采纳的回答

Star Strider
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.
  4 个评论
Hamish Cavaye
Hamish Cavaye 2020-10-20
Thanks a lot for your help. I will give this a try and if I need to come back to you I'll attach some files so you've got something specific to work with!

请先登录,再进行评论。

更多回答(0 个)

产品


版本

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by