RosettaCodeData/Task/Cumulative-standard-deviation/Run-BASIC/cumulative-standard-deviati...

17 lines
587 B
Plaintext

dim sdSave$(100) 'can call up to 100 versions
'holds (space-separated) number of data , sum of values and sum of squares
sd$ = "2,4,4,4,5,5,7,9"
for num = 1 to 8
stdData = val(word$(sd$,num,","))
sumVal = sumVal + stdData
sumSqs = sumSqs + stdData^2
' standard deviation = square root of (the average of the squares less the square of the average)
standDev =((sumSqs / num) - (sumVal /num) ^ 2) ^ 0.5
sdSave$(num) = str$(num);" ";str$(sumVal);" ";str$(sumSqs)
print num;" value in = ";stdData; " Stand Dev = "; using("###.######", standDev)
next num