Skip to content

Commit 03e99f4

Browse files
committed
Updated docstring and stdm function for variation
1 parent 3b36bfa commit 03e99f4

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/scalarstats.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,13 +404,16 @@ span(x) = ((a, b) = extrema(x); a:b)
404404

405405
# Variation coefficient: std / mean
406406
"""
407-
variation(x, m=mean(x))
407+
variation(x, m=mean(x); corrected=true)
408408
409409
Return the coefficient of variation of collection `x`, optionally specifying
410-
a precomputed mean `m`. The coefficient of variation is the ratio of the
411-
standard deviation to the mean.
410+
a precomputed mean `m`, and the optional correction parameter `corrected`.
411+
The coefficient of variation is the ratio of the
412+
standard deviation to the mean. If `corrected` is `false`,
413+
then `std` is calculated with denominator `n`. Else, the `std` is
414+
calculated with denominator `n-1`.
412415
"""
413-
variation(x, m) = stdm(x, m) / m
416+
variation(x, m; corrected::Bool=true) = stdm(x, m; corrected=corrected) / m
414417
variation(x; corrected::Bool=true) = ((m, s) = mean_and_std(x; corrected=corrected); s/m)
415418

416419
# Standard error of the mean: std / sqrt(len)

0 commit comments

Comments
 (0)