weighted_histogram_t Derived Type

type, public :: weighted_histogram_t

Weighted histogram type


Components

Type Visibility Attributes Name Initial
real(kind=dp), public, allocatable :: bins(:)

Bin weights

integer(kind=i4), public :: min_index

Lower bound of bins

integer(kind=i4), public :: max_index

Upper bound of bins

real(kind=dp), public :: total_weight

Sum of all weights


Type-Bound Procedures

procedure, public :: init => weighted_histogram_init

  • private subroutine weighted_histogram_init(this, min_index, max_index)

    Initialize the histogram with a given range of bins.

    Arguments

    Type IntentOptional Attributes Name
    class(weighted_histogram_t), intent(inout) :: this

    Histogram object

    integer, intent(in) :: min_index

    Lower bound index

    integer, intent(in) :: max_index

    Upper bound index

procedure, public :: reset => weighted_histogram_reset

  • private subroutine weighted_histogram_reset(this)

    Reset all bin weights and total weight to zero.

    Arguments

    Type IntentOptional Attributes Name
    class(weighted_histogram_t), intent(inout) :: this

    Histogram object

procedure, public :: add_value => weighted_histogram_add_value

  • private subroutine weighted_histogram_add_value(this, index, weight)

    Add a weighted value to a given bin index.

    Arguments

    Type IntentOptional Attributes Name
    class(weighted_histogram_t), intent(inout) :: this

    Histogram object

    integer(kind=i4), intent(in) :: index

    Bin index

    real(kind=dp), intent(in) :: weight

    Weight to add

procedure, public :: get_mean => weighted_histogram_get_mean

  • private function weighted_histogram_get_mean(this, normalization_factor) result(res)

    Compute the mean value of the histogram.

    Arguments

    Type IntentOptional Attributes Name
    class(weighted_histogram_t), intent(in) :: this

    Histogram object

    real(kind=dp), intent(in), optional :: normalization_factor

    Normalization factor for index scaling

    Return Value real(kind=dp)

procedure, public :: get_variance => weighted_histogram_get_variance

  • private function weighted_histogram_get_variance(this, normalization_factor) result(res)

    Compute the variance of the histogram.

    Arguments

    Type IntentOptional Attributes Name
    class(weighted_histogram_t), intent(in) :: this

    Histogram object

    real(kind=dp), intent(in), optional :: normalization_factor

    Normalization factor for index scaling

    Return Value real(kind=dp)

procedure, public :: get_moment => weighted_histogram_get_moment

  • private function weighted_histogram_get_moment(this, k, normalization_factor) result(res)

    Compute the k-th statistical moment of the histogram. The moment is normalized by the total weight.

    Arguments

    Type IntentOptional Attributes Name
    class(weighted_histogram_t), intent(in) :: this

    Histogram object

    integer(kind=i4), intent(in) :: k

    Moment order (k ≥ 0)

    real(kind=dp), intent(in), optional :: normalization_factor

    Normalization factor for index scaling

    Return Value real(kind=dp)