Simple Standard Deviation Command
stableDescription
This command is used to calculate a standard deviation for a given data set.
Note: Its a bit slow but works well enough
HaasScript
-- [r4stl1n] Simple Standard Deviation Command
--
-- Very simple standard deviation. Pretty sure its correct
--
-- Note: This is rather slow we should probably bring this to a
-- local command call rather than interpret it from a script
--
--------------------------------
-- You are on your own with this script
--------------------------------
-- ~Bored and programming series~
DefineCommand("GetSTDev","Get the standard deviation for input array")
local dataSetArray = DefineParameter(ListNumberType, "DataSetArray", "The dataset to calculate", true, 0)
local currentSum = ArraySum(dataSetArray)
local meanValue = Div(currentSum, Count(dataSetArray))
local newArray = {}
for i = 1, Count(dataSetArray)
do
local numberToAdd = Sub(dataSetArray[i], meanValue)
numberToAdd = Mul(numberToAdd, numberToAdd)
newArray[i] = numberToAdd
end
local newWorkingTotal = ArraySum(newArray)
local newMeanValue = Div(newWorkingTotal, Count(newArray))
local finalValue = Sqrt(newMeanValue)
DefineOutput(NumberType, finalValue, "StdDev for the input array", "NumberType")
0 Comments
Sign in to leave a comment.
No comments yet. Be the first!