Calculate 2 standard deviations

I am trying to calculate +/- two standard deviations from the mean of a bunch of values. I am not sure if I am using the standard deviation function properly. Would I just multiply by two to get 2 standard deviations?
dmean = mean(values(:,1)); upperstd = dmean+2*std(values(:,1)); lowerstd = dmean-2*std(values(:,1));

 Accepted Answer

Hi Chris, for a matrix of data
x = randn(10,4);
mean(x)+2*std(x)
mean(x)-2*std(x)
gives the sample means of the columns plus/minus 2 times the standard deviation. The question is whether you really want the sample standard deviation here, or the standard error of the mean.
Wayne

2 Comments

Hello Wayne King. In this case, how would you calculate the standard error of the mean?
Jay, the standard error is calculated by taking the standard deviation and dividing it by the square root of N-th samples used to calculate the standard deviation.

Sign in to comment.

More Answers (1)

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Asked:

on 28 Aug 2011

Commented:

on 20 Jan 2020

Community Treasure Hunt

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

Start Hunting!