Standard deviation of one item

When i try to execute

StandardDeviation[{1}] 

I get an error

 StandardDeviation::shlen: "The argument {1} should have at least two elements" 

But the std of one element is 0, right?

+7
source share
5 answers

The standard deviation is usually defined as the square root of the unbiased variance estimate:

enter image description here

You can easily see that for one sample N=1 and you get 0/0 , which is undefined. Therefore, your standard deviation is undefined for a single sample in Mathematica.

Now, depending on your agreement, you can determine the standard deviation for one sample (either return Null , or some value or 0 ). Here is an example that shows you how to define it for one sample.

 std[x_List] := Which[(Length[x] == 1), 0, True, StandardDeviation[x]] std[{1}] Out[1]= 0 
+13
source

The standard deviation of the constant is zero.

The estimated standard deviation of one sample is undefined.

+7
source

If you need formality:

 p[x_] := DiracDelta[x - mu]; expValue = Integrate[xp[x] , {x, -Infinity, Infinity}] stdDev = Sqrt[Integrate[(x - expValue)^2 p[x] , {x, -Infinity, Infinity}]] (* -> ConditionalExpression[mu, mu \[Element] Reals] -> ConditionalExpression[0, mu \[Element] Reals] *) 

Edit

Or better, using Mathematica ProbabilityDistribution[] :

 dist = ProbabilityDistribution[DiracDelta[x - mu], {x, -Infinity, Infinity}]; {Mean[dist], StandardDeviation[dist]} (* -> { mu, ConditionalExpression[0, mu \[Element] Reals]} *) 
+1
source

If your population size is one of the elements, then the standard deviation of your population will be 0. However, usually standard deviations are used for samples, and not for the entire population, so instead of dividing by the number of elements in the sample, you divide by the number of elements minus one. This is due to an error inherent in performing calculations on a sample, and not on an aggregate basis.

Performing a calculation of the standard deviation over a population of size 1 makes absolutely no sense, and I think there is confusion here. If you know that your population contains only one element, then defining the standard deviation of this element is pointless, so you will usually see the standard deviation of one element written as undefined.

+1
source

The standard deviation, which is a measure for deviating the actual value from the average value of a given set, makes no sense for a list of one element (you can set it to 0 if you want).

0
source

All Articles