Cumulative standard deviation: Difference between revisions

m
m (→‎RPL 1993: typo)
m (→‎{{header|Wren}}: Minor tidy)
 
(3 intermediate revisions by 2 users not shown)
Line 904:
No attempt to handle different types -- standard deviation is intrinsically a real number.
<syntaxhighlight lang="cpp">
#include <assert.hcassert>
#include <cmath>
#include <vector>
Line 1,348:
1.3997084244475297
2.0</syntaxhighlight>
 
=={{header|EasyLang}}==
{{trans|Pascal}}
<syntaxhighlight lang="easylang">
global sum sum2 n .
proc sd x . r .
sum += x
sum2 += x * x
n += 1
r = sqrt (sum2 / n - sum * sum / n / n)
.
v[] = [ 2 4 4 4 5 5 7 9 ]
for v in v[]
sd v r
print v & " " & r
.
</syntaxhighlight>
 
=={{header|Elixir}}==
Line 4,425 ⟶ 4,442:
{{libheader|Wren-fmt}}
{{libheader|Wren-math}}
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Fmt
import "./math" for Nums
 
var cumStdDev = Fiber.new { |a|
Line 4,440 ⟶ 4,457:
var sd = cumStdDev.call(a)
if (cumStdDev.isDone) return
SystemFmt.print("Std Dev : %(Fmt$10.f(108f\n", sd, 8))\n")
}</syntaxhighlight>
 
9,476

edits