Module s2_distn_mod

module s2_distn_mod

        ! Uses
    use s2_types_mod, only: s2_sp, s2_dp
    use s2_error_mod

        ! Subroutines and functions
    public function s2_distn_sample_gauss (seed, mean, std) result (sample)
    public function s2_distn_sample_uniform (seed, lower, upper) result (sample)
    private function gasdev2 (idum)
    private function ran2 (idum)
    public function gasdev2_dp (idum)
    private function ran2_dp (idum)

end module s2_distn_mod
Functionality to sample from uniform and Gaussian distributions.

Author: J. D. McEwen (mcewen@mrao.cam.ac.uk)

Version: 0.1 August 2004


Description of Subroutines and Functions

s2_distn_sample_gauss

public function s2_distn_sample_gauss (seed, mean, std) result (sample)
    integer, intent(in) :: seed
    real (kind=s2_sp), optional, intent(in) :: mean
    real (kind=s2_sp), optional, intent(in) :: std
    real (kind=s2_sp) :: sample
end function s2_distn_sample_gauss
Generate sample from Gaussian distribution with mean 'mean' and standard deviation 'std' (based on gasdev2 which generates sample from Gaussian distribution with mean 0 and standard deviation 1).

Variables:

Author: J. D. McEwen

Version: 0.1 August 2004

s2_distn_sample_uniform

public function s2_distn_sample_uniform (seed, lower, upper) result (sample)
    integer, intent(in) :: seed
    real (kind=s2_sp), optional, intent(in) :: lower
    real (kind=s2_sp), optional, intent(in) :: upper
    real (kind=s2_sp) :: sample
    ! Calls: s2_error
end function s2_distn_sample_uniform
Generate sample from uniform distribution in range [lower, upper) (based on ran2 which generates sample from uniform distribution in range [0,1)).

Variables:

Author: J. D. McEwen

Version: 0.1 August 2004

gasdev2

private function gasdev2 (idum)
    integer :: idum
    real :: gasdev2
end function gasdev2
Generate sample from Gaussian distribution of mean 0 and standard deviation 1 given seed.

Notes:

Variables:

Author: J. D. McEwen

Version: 0.1 August 2004

ran2

private function ran2 (idum)
    integer :: idum
    real :: ran2
end function ran2