Working with grouped data - data access and analysis (standard deviation)
이전 댓글 표시
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
채택된 답변
추가 답변 (1개)
Lola Davidson
2024년 6월 4일
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)
카테고리
도움말 센터 및 File Exchange에서 Descriptive Statistics and Visualization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!