@@ -73,7 +73,7 @@ public GenericMeasureInfo()
7373 public double ? Minimum { get ; set ; }
7474
7575 /// <summary>
76- /// The Standard Deviation of property values
76+ /// The Standard Deviation of property values.
7777 /// </summary>
7878 public double ? StdDeviation { get ; set ; }
7979 }
@@ -135,7 +135,7 @@ public GenericObjectMeasureInfo()
135135 public object Minimum { get ; set ; }
136136
137137 /// <summary>
138- /// The Standard Deviation of property values
138+ /// The Standard Deviation of property values.
139139 /// </summary>
140140 public double ? StdDeviation { get ; set ; }
141141 }
@@ -276,10 +276,9 @@ public MeasureObjectCommand()
276276 #endregion Common parameters in both sets
277277
278278 /// <summary>
279- /// Set to true if Standard Deviation is to be returned
279+ /// Set to true if Standard Deviation is to be returned.
280280 /// </summary>
281- /// <value></value>
282- [ Parameter ( ParameterSetName = GenericParameterSet ) ]
281+ [ Parameter ( ParameterSetName = GenericParameterSet ) ]
283282 public SwitchParameter StdDeviation
284283 {
285284 get
@@ -746,9 +745,10 @@ private void AnalyzeNumber(double numValue, Statistics stat)
746745 }
747746 if ( _measureStdDeviation && stat . count > 1 )
748747 {
749- double countMinusOne = stat . count - 1 ;
750- double avgPrevious = stat . sumPrevious / countMinusOne ;
751- stat . variance *= ( countMinusOne - 1 ) / countMinusOne ;
748+ // Based off of iterative method of calculating variance on
749+ // https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Online_algorithm
750+ double avgPrevious = stat . sumPrevious / ( stat . count - 1 ) ;
751+ stat . variance *= ( stat . count - 2.0 ) / ( stat . count - 1 ) ;
752752 stat . variance += ( numValue - avgPrevious ) * ( numValue - avgPrevious ) / stat . count ;
753753 }
754754 }
0 commit comments