In MATLAB (cumulative distribution function), how can I find the corresponding data point (Y) for any chosen cumulative probability?
23 ビュー (過去 30 日間)
古いコメントを表示
In a CDF (using MATLAB,) how can I find the corresponding data value (X) for any chosen cumulative distribution (Y)? Please refer to the pasted code and image. Instead of "eye-balling" the plot, how can I find the data point (X) that corresponds to the cumulative probability value of 0.2 or even 0.466, etc.? Please advise. Thank you.
X = randn(1,500);
u = mean(X);
s = std(X);
pd = makedist('Normal','mu',u,'sigma',s);
x = min(X):.1:max(X);
cdf_normal = cdf(pd,x);
plot(x,cdf_normal,'LineWidth',4)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/148064/image.png)
0 件のコメント
採用された回答
Teja Muppirala
2013 年 5 月 29 日
Alternatively, you can use ICDF directly on the probability distribution object
icdf(pd,[0.2 0.466])
0 件のコメント
その他の回答 (2 件)
Image Analyst
2013 年 5 月 29 日
編集済み: Image Analyst
2013 年 5 月 29 日
If "the_Y_Value" is the y value you're looking at, and xValue is the x location where y first exceeds "the_Y_Value", then:
xIndex = find(cdf_normal >= the_Y_Value, 1, 'first');
xValue = x(xIndex);
0 件のコメント
Brett Hoover
2018 年 7 月 26 日
Kinda surprised that nobody suggested 1-D interpolation:
target_value = interp1(cdf_probs,cdf_values,target_prob)
1 件のコメント
Image Analyst
2018 年 7 月 27 日
Because when Aaron said "how can I find the data point..." I assumed he wanted a data point that was in his existing set of data. Your code would give a point not in the data. It's probably a more accurate estimate but wouldn't be one of his data points -- it would be between two of them. However, maybe that's what he really meant.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!