View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

5.0 | 1 rating Rate this file 4 Downloads (last 30 days) File Size: 2.74 KB File ID: #38318 Version: 1.6




24 Sep 2012 (Updated )

Standard deviation of a grouped sample.

| Watch this File

File Information

In some scientific works, once the data have been gathered from a population of interest, it is often difficult to get a sense of what the data indicate when they are presented in an unorganized fashion.

Assembling the raw data into a meaningful form, such as a frequency distribution, makes the data easier to understand and interpret. It is in the context of frequency distributions that the importance of conveying in a succinct way numerical information contained in the data is encountered.

So, grouped data is data that has been organized into groups known as classes. The raw dataset can be organized by constructing a table showing the frequency distribution of the variable (whose values are given in the raw dataset). Such a frequency table is often referred to as grouped data.

Here, we developed a m-code to calculate the standard deviation of a grouped data.

One can input the returns or modified vectors n and xout containing the frequency counts and the bin locations of the hist m-function, in a column form matrix.

Normalizes Y by (N-1), where N is the sample size. This is an unbiased estimator of the standard deviation of the population from which X is drawn. Y = STD(X,1) normalizes by N and produces the square root of the second moment of the sample about its mean. STD(X,0) is the same as STD(X).

Variance calculation uses the formula,
S = SQRT(Sum(F*(MC - M)^2)/D)

F = class frequency
MC = mark class
M = grouped mean
D = N - 1 or N, whether normalizes by n-1 or by n
N = sample size [=sum(F)]

--In orden to run it you must first download the m-file gvar at:

Syntax: function y = gstd(x)
x - data matrix (Size of matrix must be n-by-2; absolut frequency=column 1, class mark=column 2)
n - [normalized by n-1] = 0 (default), [normalized by n] = 1

y - standard deviation of the values in x

Required Products Statistics and Machine Learning Toolbox
MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
04 Sep 2014 Wajahat

Excellent. A very quick and tool to calculate the Std.Dev. of grouped data or histograms.
Its strange that Matlab Statistics Toolbox does not include a function for this. Or at least I could not find one.

26 Sep 2012 Antonio Trujillo-Ortiz

Bug was removed.

Comment only
24 Sep 2012 1.1

It was added an appropriate format to cite this file.

26 Sep 2012 1.4

Text was improved.

26 Sep 2012 1.2

Text was improved.

26 Sep 2012 1.6

Text was improved.

Contact us