How to calculate mean of standard deviation (mean deviation) in a table
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
With the table below how do I find the players mean_score and standard deviation.
what I tried. now quite sure how to handle the mean deviations.
Average standard deviation = √ (s12 + s22 + … + sk2) / k. ref here
summary = groupsummary(table,{'player'},{'mean'},{'mean_score','mean_rate'})
DATA
week = [1 2 1 2 1 2]';
player = [1 1 2 2 3 3]';
mean_score = [3.4 5.2 4.5 5.5 2.8 3.8]';
std_score = [2.1 2.4 2.8 2.3 2.2 2.3]'; %standard deviation
mean_rate = [5.4 8.2 4.5 15.5 22.8 12.8]';
std_rate = [0.1 0.16 0.14 0.12 0.3 0.16]'; % standard deviation
T = table(week,player,mean_score,std_score,std_rate);
0 Commenti
Risposte (2)
Image Analyst
il 17 Mag 2023
You forgot to attach your data, so we can't try anything with your actual data.
Did you try
meanStd = mean(summary.std_score)
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
4 Commenti
Image Analyst
il 17 Mag 2023
Is there something wrong with my suggested solution?
week = [1 2 1 2 1 2]';
player = [1 1 2 2 3 3]';
mean_score = [3.4 5.2 4.5 5.5 2.8 3.8]';
std_score = [2.1 2.4 2.8 2.3 2.2 2.3]';
std_rate = [0.1 0.16 0.14 0.12 0.3 0.16]';
T = table(week,player,mean_score,std_score,std_rate)
meanStd = mean(T.std_score)
Star Strider
il 17 Mag 2023
The 'mean_rate' variable does not exist in ‘T’.
Giving groupsummary the correct variable names (or at least variable names that exist) works —
week = [1 2 1 2 1 2]';
player = [1 1 2 2 3 3]';
mean_score = [3.4 5.2 4.5 5.5 2.8 3.8]';
std_score = [2.1 2.4 2.8 2.3 2.2 2.3]';
std_rate = [0.1 0.16 0.14 0.12 0.3 0.16]';
T = table(week,player,mean_score,std_score,std_rate)
summary = groupsummary(T,{'player'},{'mean'},{'mean_score','std_score','std_rate'})
.
4 Commenti
Star Strider
il 23 Mag 2023
That doesn’t lend itself to groupsummary, and the means of the standard deviations is not the same as rms, so a different approach is necessary.
Try this —
week = [1 2 1 2 1 2]';
player = [1 1 2 2 3 3]';
mean_score = [3.4 5.2 4.5 5.5 2.8 3.8]';
std_score = [2.1 2.4 2.8 2.3 2.2 2.3]';
std_rate = [0.1 0.16 0.14 0.12 0.3 0.16]';
T = table(week,player,mean_score,std_score,std_rate)
mean3 = accumarray(T{:,2}, (1:size(T,1)).', [], @(x)mean(T{x,3})); % Mean Of Mean Values
mean45c = accumarray(T{:,2}, (1:size(T,1)).', [], @(x){sqrt(sum(T{x,[4 5]}.^2))/numel(x)}); % MEan Of Standard Deviations
mean45 = cell2mat(mean45c);
VN = T.Properties.VariableNames;
Player_Means_Table = table(unique(T{:,2},'stable'),mean3,mean45(:,1),mean45(:,2), 'VariableNames',VN(2:end))
Those results appear to be correct (I checked some manually), if their calculations (as I understand them) are correct.
.
Star Strider
il 23 Mag 2023
@Image Analyst — I don’t believe this is the same as rms.
As I understand it (although the expression posted is a bit ambiguous, and would benefit from appropriately-placed parenthesees) —
square root of the mean of the squares,
while
mean of the square root of the summed variaces
Anyway, that’s how I coded it.
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!