Calculating Percentile from a pdf
Show older comments
Hi,
I have a data with two columns: Column 1 is the variable, and Column 2 is the probability density. I am pasting a sample of the data, but overall cumsum(COlumn2) = 100, as it should be.

Question is, how do I get the 5th percentile of Column 1 (given the probabilities associated with each number). I have tried a number of things but coming at the dead-end. APologies in advance in case its too naive.
Accepted Answer
More Answers (1)
John D'Errico
on 5 Jun 2019
Edited: John D'Errico
on 5 Jun 2019
0 votes
Pretty simple actually, though it is far easier as I can give you an example, than if you posted your actual data rather than a blasted picture of numbers. A picture of numbers is not worth a thousand words. Sorry, but I refuse to type in numbers from a picture.
But do this:
- Set the point at -9.42 to be zero.
- Use cumsum.
- Normalize the sum to 1.
- Interpolate (actually reverse interpolation.) at 0.05. You can do that using interp1, where x will be the cumulative probability, and y is the column 1 variable. Linear interpolation seems right.
You could also use the 'pchip' or 'makima' options in interp1 to interpolate. Do NOT use 'spline'.
1 Comment
Rohit Goel
on 6 Jun 2019
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!