std Function

public pure function std(array)

Compute the STD of a 1D array

Arguments

Type IntentOptional AttributesName
real(kind=xp), intent(in), dimension(:):: array

1D array

Return Value real(kind=xp)

standard deviation


Called by

proc~~std~~CalledByGraph proc~std std proc~set_stdmap set_stdmap proc~set_stdmap->proc~std proc~std_2d std_2D proc~std_2d->proc~std proc~std_spectrum std_spectrum proc~std_spectrum->proc~std_2d proc~main_rohsa main_rohsa proc~main_rohsa->proc~set_stdmap program~rohsa ROHSA program~rohsa->proc~main_rohsa

Contents

Source Code

std

Source Code

  pure function std(array)
    !! Compute the STD of a 1D array
    implicit none

    real(xp), intent(in), dimension(:) :: array !! 1D array
    integer :: i
    integer :: n
    real(xp) :: std !! standard deviation 
    real(xp) :: mean
    real(xp) :: var

    mean = 0._xp; var = 0._xp
    std = 0._xp

    n = size(array)
    mean = sum(array) / n

    do i=1, n
       var = var + (array(i) - mean)**2._xp
    end do
    
    var = var / (n - 1)
    std = sqrt(var)
    
    return
  end function std