Cumulative standard deviation: Difference between revisions
Content added Content deleted
(Added COBOL example.) |
m (Added small COBOL example. Corrected PL/I and R lang tags.) |
||
Line 472: | Line 472: | ||
Using an intrinsic function: |
Using an intrinsic function: |
||
<lang cobol>FUNCTION STANDARD-DEVIATION(2, 4, 4, 4, 5, 5, 7, 9)</lang> |
<lang cobol>FUNCTION STANDARD-DEVIATION(2, 4, 4, 4, 5, 5, 7, 9)</lang> |
||
The implementation of this based of the standard's implementation: |
|||
<lang cobol>FUNCTION SQRT(FUNCTION VARIANCE(2, 4, 4, 4, 5, 5, 7, 9))</lang> |
|||
=={{header|CoffeeScript}}== |
=={{header|CoffeeScript}}== |
||
Line 1,771: | Line 1,774: | ||
=={{header|PL/I}}== |
=={{header|PL/I}}== |
||
<lang |
<lang pli> |
||
declare A(200) float; |
declare A(200) float; |
||
declare ap fixed binary; |
declare ap fixed binary; |
||
Line 1,991: | Line 1,994: | ||
=={{header|R}}== |
=={{header|R}}== |
||
===Built-in Std Dev fn=== |
===Built-in Std Dev fn=== |
||
<lang |
<lang rsplus>#The built-in standard deviation function applies the Bessel correction. To reverse this, we can apply an uncorrection. |
||
#If na.rm is true, missing data points (NA values) are removed. |
#If na.rm is true, missing data points (NA values) are removed. |
||
reverseBesselCorrection <- function(x, na.rm=FALSE) |
reverseBesselCorrection <- function(x, na.rm=FALSE) |
||
Line 2,003: | Line 2,006: | ||
reverseBesselCorrection(testdata)*sd(testdata) #2</lang> |
reverseBesselCorrection(testdata)*sd(testdata) #2</lang> |
||
===From scratch=== |
===From scratch=== |
||
<lang |
<lang rsplus>#Again, if na.rm is true, missing data points (NA values) are removed. |
||
uncorrectedsd <- function(x, na.rm=FALSE) |
uncorrectedsd <- function(x, na.rm=FALSE) |
||
{ |
{ |