anchor.diff:  
     end function stats_mean_abs_err
   
  -  ! Calculate mean squared error from residuals
     real(dp) function stats_mean_sq_err(resid_arr, mask) result(val)
  +    ! Calculate mean squared error from residuals
  +    !
  +    ! resid_arr :: residual array
  +    ! mask :: logical masking array
       real(dp), intent(in) :: resid_arr(:)
       logical, intent(in), optional :: mask(:)
  -
   
       integer :: n
   
  
positive.code: 
    end function stats_mean
  
    ! Calculate median
    real(dp) function stats_median(data_arr, mask) result(val)
  
      real(dp), intent(in) :: data_arr(:)
      logical, intent(in), optional :: mask(:)
  
  
negative.code:   public :: stats_stdev
  
  contains
  
    subroutine stats_residuals(data_arr, theor_arr, resid_arr)
      ! Calculate residuals
      !
      ! data_arr :: array of experimental data values
      ! theor_arr :: array of theoretical values, parallel to data_arr
      ! resid_arr :: array to populate with residuals
      real(dp), intent(in) :: data_arr(:), theor_arr(:)
      real(dp), intent(inout) :: resid_arr(:)
  
  