Finding the percentile of a time series

9 visualizaciones (últimos 30 días)
John Doe
John Doe el 22 de Mzo. de 2018
Comentada: Christian Bothe el 26 de En. de 2025
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!!

Respuesta aceptada

the cyclist
the cyclist el 22 de Mzo. de 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 comentarios
the cyclist
the cyclist el 26 de En. de 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)
The 50th percentile datetime is 12-Jan-2025 12:00:00
Christian Bothe
Christian Bothe el 26 de En. de 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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Descriptive Statistics en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by