Cumulative standard deviation: Difference between revisions
→R: Added environment-based solution.
m (→show running sums: aligned a comment.) |
ReeceGoding (talk | contribs) (→R: Added environment-based solution.) |
||
Line 3,324:
[1] 1.399708
[1] 2</pre>
===Environment solution===
R gives us some control over what environment expressions are evaluated in. This lets us shorten the previous solution and get identical output.
<lang r>localCumSD<-local({
data<-numeric(0)
function(oneNumber)
{
data<<-c(data,oneNumber)
biasedSd(data)#Again, lifted from the ""Running" SD" solution.
}
})
localCumSD(2);localCumSD(4);localCumSD(4);localCumSD(4);localCumSD(5);localCumSD(5);localCumSD(7);localCumSD(9)</lang>
=={{header|Racket}}==
|