Finding the percentile of a time series

8 次查看(过去 30 天)
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!!

采纳的回答

the cyclist
the cyclist 2018-3-22
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 个评论
the cyclist
the cyclist 2025-1-26
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)
The 50th percentile datetime is 12-Jan-2025 12:00:00
Christian Bothe
Christian Bothe 2025-1-26
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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Calendar 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by