Picking value from CDF

조회 수: 10 (최근 30일)
Georgios Vamvakopoulos
Georgios Vamvakopoulos 2016년 8월 17일
댓글: Georgios Vamvakopoulos 2016년 8월 17일
Hello Everyone,
I ploted a CDF which I attached in the post. My problem is that I want to pick the 68%, 95% and 99.7% of the observations and find the corresponding value from x axis. How can I have matlab to pick these values and store them?. The problem is that there are too many graphs and it is impossible to do this manually.

채택된 답변

Torsten
Torsten 2016년 8월 17일
편집: Torsten 2016년 8월 17일
v_68 = interp1(probability,velocity,0.68);
v_95 = interp1(probability,velocity,0.95);
v_99_7 = interp1(probability,velocity,0.997);
where probability and velocity are the arrays defining the CDF curve.
Best wishes
Torsten.
  댓글 수: 1
Georgios Vamvakopoulos
Georgios Vamvakopoulos 2016년 8월 17일
Thank you for your reply, you suggestion works perfectly

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

John D'Errico
John D'Errico 2016년 8월 17일
편집: John D'Errico 2016년 8월 17일
It is just a piecewise linear function. You can use a tool like intersections (from the file exchange) to do this trivially. Thus, on of the curves will be the CDF, and the other "curve" will be a horizontal line. Since that line can be defined by two points, it is trivial to create and pass in also.
Alternatively, you can create the CDF as a pchip spline (use pchip to do this), then use slmsolve, as found in my SLM toolbox. Or, you could use slmeval, also in the SLM toolbox .
Since pchip will build a nice smooth interpolant, it may be your preference. Or not. Any of the alternatives I have outlined will work trivially and efficiently in only a very few lines of code.
Edit: I see that Torsten has pointed out you could use interp1 to solve the problem by inverting x and y. This approach will work IF the tails of that CDF are NOT absolutely constant.
However if the first few points on the CDF are exactly zero, or the last few points are exactly 1, then interp1 will fail. It will give an error that talks about needing a monotonic vector for x.
  댓글 수: 1
Georgios Vamvakopoulos
Georgios Vamvakopoulos 2016년 8월 17일
Thank you for your reply, Torsten solution works just fine for my problem :)
Have a nice day

댓글을 달려면 로그인하십시오.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by