Computes (sample) variance.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x(:) |
x vector (assumed size array) |
||
real(kind=wp), | intent(in) | :: | ddof |
delta degrees of freedom |
variance
pure function f_sts_var_core(x, ddof) result(var) ! ==== Description !! Computes (sample) variance. ! ==== Declarations real(wp), intent(in) :: x(:) !! x vector (assumed size array) real(wp), intent(in) :: ddof !! delta degrees of freedom real(wp) :: xbar !! mean of x real(wp) :: var !! variance ! ==== Instructions xbar = f_sts_mean_core(x) var = dot_product( (x - xbar), (x - xbar) ) / & & (real(size(x), kind=wp) - ddof) end function f_sts_var_core