How to resolve the algorithm Cumulative standard deviation step by step in the PureBasic programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Cumulative standard deviation step by step in the PureBasic 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 PureBasic programming language
Source code in the purebasic programming language
;Define our Standard deviation function
Declare.d Standard_deviation(x)
; Main program
If OpenConsole()
Define i, x
Restore MyList
For i=1 To 8
Read.i x
PrintN(StrD(Standard_deviation(x)))
Next i
Print(#CRLF$+"Press ENTER to exit"): Input()
EndIf
;Calculation procedure, with memory
Procedure.d Standard_deviation(In)
Static in_summa, antal
Static in_kvadrater.q
in_summa+in
in_kvadrater+in*in
antal+1
ProcedureReturn Pow((in_kvadrater/antal)-Pow(in_summa/antal,2),0.50)
EndProcedure
;data section
DataSection
MyList:
Data.i 2,4,4,4,5,5,7,9
EndDataSection
You may also check:How to resolve the algorithm Memory layout of a data structure step by step in the Perl programming language
You may also check:How to resolve the algorithm Ethiopian multiplication step by step in the EMal programming language
You may also check:How to resolve the algorithm Image convolution step by step in the Raku programming language
You may also check:How to resolve the algorithm FizzBuzz step by step in the ML programming language
You may also check:How to resolve the algorithm Subleq step by step in the Fortran programming language