rndgenPL Derived Type

type, public, extends(rndgen) :: rndgenPL

Random number generator object for power-law distribution, adapted from Silvio C. Ferreira code. The power-law distribution is given by P(k) = k^(-gamma), where k is an integer between kmin and kmax.


Inherits

type~~rndgenpl~~InheritsGraph type~rndgenpl rndgenPL type~rndgen rndgen type~rndgenpl->type~rndgen type~rndseed rndSeed type~rndgen->type~rndseed seed

Components

Type Visibility Attributes Name Initial
integer, public :: o_iseed
type(rndSeed), public :: seed
real(kind=dp), private :: AA
real(kind=dp), private :: expo
real(kind=dp), private :: x0
real(kind=dp), private :: xc
real(kind=dp), public :: gamma
integer(kind=i16), public :: kmin
integer(kind=i16), public :: kmax
real(kind=dp), private, allocatable :: prob(:)

Type-Bound Procedures

procedure, public :: rnd => rnd_rndgen

  • private function rnd_rndgen(this) result(rnd_number)

    Generates a random number in the range [0, 1)

    Arguments

    Type IntentOptional Attributes Name
    class(rndgen) :: this

    Return Value real(kind=dp)

procedure, public :: int => int_rndgen

  • private function int_rndgen(this, i1, i2) result(rnd_number)

    Generates a random integer number in the range [i1, i2]

    Arguments

    Type IntentOptional Attributes Name
    class(rndgen) :: this
    integer(kind=i16), intent(in) :: i1
    integer(kind=i16), intent(in) :: i2

    Return Value integer(kind=i16)

procedure, public :: real => real_rndgen

  • private function real_rndgen(this, r1, r2) result(rnd_number)

    Generates a random real number in the range [r1, r2)

    Arguments

    Type IntentOptional Attributes Name
    class(rndgen) :: this
    real(kind=dp), intent(in) :: r1
    real(kind=dp), intent(in) :: r2

    Return Value real(kind=dp)

procedure, public :: init => init_rndgen

  • private subroutine init_rndgen(this, iseed)

    Initializes the random number generator

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(rndgen) :: this
    integer(kind=i8) :: iseed

procedure, public :: reset => reset_rndgen

  • private subroutine reset_rndgen(this)

    Resets the random number generator

    Arguments

    Type IntentOptional Attributes Name
    class(rndgen) :: this

procedure, public :: save_seed => save_seed_rndgen

  • private subroutine save_seed_rndgen(this, u_mseed, und)

    Save the current seeds to a seeds object and, optionally, to a file unit

    Arguments

    Type IntentOptional Attributes Name
    class(rndgen) :: this
    type(rndSeed), intent(out) :: u_mseed
    integer, intent(in), optional :: und

procedure, public :: read_seed => read_seed_rndgen

  • private subroutine read_seed_rndgen(this, u_mseed, und)

    Read the seeds from a seeds object or, optionally, from a file unit

    Arguments

    Type IntentOptional Attributes Name
    class(rndgen) :: this
    type(rndSeed), intent(in) :: u_mseed
    integer, intent(in), optional :: und

procedure, public :: rndPL => rndPL_rndgenPL

  • private function rndPL_rndgenPL(this) result(rnd_number)

    Generates a random number following the power-law distribution

    Arguments

    Type IntentOptional Attributes Name
    class(rndgenPL) :: this

    Return Value integer(kind=i16)

procedure, public :: initPL => initPL_rndgenPL

  • private subroutine initPL_rndgenPL(this, kmin, kmax, gama, iseed)

    Initializes the power-law random number generator

    Arguments

    Type IntentOptional Attributes Name
    class(rndgenPL) :: this
    integer(kind=i16), intent(in) :: kmin
    integer(kind=i16), intent(in) :: kmax
    real(kind=dp), intent(in) :: gama
    integer, intent(in), optional :: iseed