f_sts_var Function

public impure function f_sts_var(x, ddof) result(var)

Impure wrapper function for f_sts_var_core.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x(:)

x vector (assumed size array)

real(kind=wp), intent(in), optional :: ddof

delta degrees of freedom

Return Value real(kind=wp)

variance


Calls

proc~~f_sts_var~~CallsGraph proc~f_sts_var f_sts_var proc~f_sts_var_core f_sts_var_core proc~f_sts_var->proc~f_sts_var_core proc~s_err_print s_err_print proc~f_sts_var->proc~s_err_print proc~f_sts_mean_core f_sts_mean_core proc~f_sts_var_core->proc~f_sts_mean_core proc~f_utl_r2c f_utl_r2c proc~s_err_print->proc~f_utl_r2c

Called by

proc~~f_sts_var~~CalledByGraph proc~f_sts_var f_sts_var interface~fsml_var fsml_var interface~fsml_var->proc~f_sts_var

Source Code

impure function f_sts_var(x, ddof) result(var)

! ==== Description
!! Impure wrapper function for `f_sts_var_core`.

! ==== Declarations
  real(wp), intent(in)           :: x(:)   !! x vector (assumed size array)
  real(wp), intent(in), optional :: ddof   !! delta degrees of freedom
  real(wp)                       :: ddof_w !! final value for ddof
  real(wp)                       :: xbar   !! mean of x
  real(wp)                       :: var    !! variance

! ==== Instructions

! ---- handle input

  ! assume ddof = 0 (population, not sample statistics)
  ddof_w = 0.0_wp
  if (present(ddof)) ddof_w = ddof

  ! check if value is valid
  if (ddof_w .ne. 1.0_wp .and. ddof_w .ne. 0.0_wp) then
     ! write error message and assign sentinel value if invalid
     call s_err_print(fsml_error(2))
     var = c_sentinel_r
     return
  endif

  ! check if size is valid
  if (size(x) .le. 1) then
     ! write error message and assign sentinel value if invalid
     call s_err_print(fsml_error(4))
     var = c_sentinel_r
     return
  endif

! ---- compute variance

  ! call pure function
  var  = f_sts_var_core(x, ddof_w)

end function f_sts_var