analyze_data Subroutine

public subroutine analyze_data(this, mean, error, eie)

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: this(:)
real(kind=dp), intent(out) :: mean
real(kind=dp), intent(out) :: error
real(kind=dp), intent(out) :: eie

Contents

Source Code


Source Code

    subroutine analyze_data(this, mean, error, eie)
        ! Finds the mean, error and error in error for Flyvbjerg and Petersen
        ! blocking analysis
        ! General routine, does not require global data

        real(dp), intent(in) :: this(:)
        real(dp), intent(out) :: mean, error, eie
        real(dp) :: mean2 ! squared value mean
        integer :: length
        integer :: i
        real(dp) :: s, s2 ! sum x_i and sum x_i^2

        s = 0.0_dp
        s2 = 0.0_dp
        mean = 0.0_dp
        mean2 = 0.0_dp
        error = 0.0_dp
        eie = 0.0_dp
        length = size(this, 1)
        do i = 1, length
            s = s + this(i)
            s2 = s2 + this(i)**2
        end do
        mean = s / length
        mean2 = s2 / length

        error = sqrt(merge(mean2 - mean**2, 0._dp, mean2 - mean**2 > 0) / real(length - 1._dp, dp))

        eie = error / sqrt(2.0_dp * (length - 1))

    end subroutine analyze_data