Finding the percentile of a time series
9 views (last 30 days)
Show older comments
Dear all,
I hope this finds you well.
I had a question concerning quantiles/percentiles. I want to know the 90th percentile of my time series, because I want to use that value as a threshold later on.
Is it enough to use the quantile() or the prctile() commands on my data set, or do I have to go with a different approach that involves sorting my data, finding the standard deviation, etc. or Find the distribution of my data then look at the tails?
Also my time series has NaNs in them. Not sure if that affects the commands.
This is a dropbox link to my data:
https://www.dropbox.com/s/k838d1ww0wj5s38/Help-Data.mat?dl=0
Thank You!!
0 Comments
Accepted Answer
the cyclist
on 22 Mar 2018
The order of the inputs will not affect the value of the quantile (using either of those functions). You should not need to do any kind of sorting, or "manually" calculate the quantile.
5 Comments
the cyclist
on 26 Jan 2025
I find it odd to calculate the percentile of datetimes. Are you sure that's what you want? (I'm curious why.)
But, if that is really what you want to do, you can convert to the numeric datenum format and back:
% Example datetime vector
datetimeVector = [datetime('2025-01-01'), datetime('2025-01-10'), datetime('2025-01-15'), datetime('2025-01-29')];
% Convert datetime to numerical values
numericalValues = datenum(datetimeVector);
% Calculate the 50th percentile
percentileNumeric = prctile(numericalValues, 50);
% Convert the result back to datetime
percentileDatetime = datetime(percentileNumeric, 'ConvertFrom', 'datenum');
% Display the result
fprintf("The 50th percentile datetime is %s",percentileDatetime)
Christian Bothe
on 26 Jan 2025
I may have expressed myself incorrectly.
For example, I am looking for the time point of a timetable at 90% or 43% or whatever.
You have already answered the right thing. But in the meantime I have also found the solution. AI chat is a great thing for me.
Thank you
More Answers (0)
See Also
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!