Working with grouped data - data access and analysis (standard deviation)
Mostrar comentarios más antiguos
I have a relatively large dataset in which I need to group data based on the cycle of reading, and calculate the median for these cycles. This worked so far. Now I need to compare a value from each member in each cycle with the median for that cycle within some standard deviation range. This should be recorded for some sort of timeseries analysis.
However, I am not able to find a proper solution with the matlab so far. It would be great if someone could help me with this.
so, to recap, - group by cycle - calculate median per group - compare each member valu of the cycle (same members in every cycle) to the group median - save results for each cycle/ member pair in timeseries?
Thanks
Respuesta aceptada
Más respuestas (1)
Lola Davidson
el 4 de Jun. de 2024
For those stumbling on this more recently, you can keep all your data together in a timetable and compute the grouped calculations using grouptransform, introduced in R2018b.
% generate some random timestamped data and collect it in a timetable
cycle = sort(randi(5,30,1));
a = cycle+randn(size(cycle))/5;
t = timetable(hours(1:30)',cycle,value);
% use grouptransform to add a column for the desired calculation. Here we
% subtract off the median of the group from each group member
t = grouptransform(t,"cycle",@(x)x-median(x),"value",ReplaceValues=false)
It might also be helpful to note that grouptransform has a handful of built-in methods for common calculations. For example you can normalize the data in each cycle to have mean 0 and std 1 using z-score:
t = grouptransform(t,"cycle","zscore","value",ReplaceValues=false)
Categorías
Más información sobre Descriptive Statistics and Visualization en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!