Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,21 @@
|
|||
StdDeviator = {}
|
||||
StdDeviator.count = 0
|
||||
StdDeviator.sum = 0
|
||||
StdDeviator.sumOfSquares = 0
|
||||
|
||||
StdDeviator.add = function(x)
|
||||
self.count = self.count + 1
|
||||
self.sum = self.sum + x
|
||||
self.sumOfSquares = self.sumOfSquares + x*x
|
||||
end function
|
||||
|
||||
StdDeviator.stddev = function()
|
||||
m = self.sum / self.count
|
||||
return sqrt(self.sumOfSquares / self.count - m*m)
|
||||
end function
|
||||
|
||||
sd = new StdDeviator
|
||||
for x in [2, 4, 4, 4, 5, 5, 7, 9]
|
||||
sd.add x
|
||||
end for
|
||||
print sd.stddev
|
||||
Loading…
Add table
Add a link
Reference in a new issue