How to resolve the algorithm Cumulative standard deviation step by step in the VBScript programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Cumulative standard deviation step by step in the VBScript programming language

Table of Contents

Problem Statement

Write a stateful function, class, generator or co-routine that takes a series of floating point numbers, one at a time, and returns the running standard deviation of the series. The task implementation should use the most natural programming style of those listed for the function in the implementation language; the task must state which is being used. Do not apply Bessel's correction; the returned standard deviation should always be computed as if the sample seen so far is the entire population.

Use this to compute the standard deviation of this demonstration set,

{ 2 , 4 , 4 , 4 , 5 , 5 , 7 , 9 }

{\displaystyle {2,4,4,4,5,5,7,9}}

, which is

2

{\displaystyle 2}

.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Cumulative standard deviation step by step in the VBScript programming language

Source code in the vbscript programming language

data = Array(2,4,4,4,5,5,7,9)

For i = 0 To UBound(data)
	WScript.StdOut.Write "value = " & data(i) &_
		" running sd = " & sd(data,i)
	WScript.StdOut.WriteLine
Next

Function sd(arr,n)
	mean = 0
	variance = 0
	For j = 0 To n
		mean = mean + arr(j)
	Next
	mean = mean/(n+1)
	For k = 0 To n
		variance = variance + ((arr(k)-mean)^2)
	Next
	variance = variance/(n+1)
	sd = FormatNumber(Sqr(variance),6)
End Function

  

You may also check:How to resolve the algorithm JortSort step by step in the Tcl programming language
You may also check:How to resolve the algorithm MD4 step by step in the Kotlin programming language
You may also check:How to resolve the algorithm XML/Input step by step in the LiveCode programming language
You may also check:How to resolve the algorithm Sum digits of an integer step by step in the AutoHotkey programming language
You may also check:How to resolve the algorithm Find if a point is within a triangle step by step in the Delphi programming language