df_normalize_column_real Subroutine

public subroutine df_normalize_column_real(df, col_index)

Normalize a real column to [0, 1] range

Applies min-max normalization: (x - min) / (max - min)

@param[in,out] df The data frame instance @param[in] col_index Index of the column to normalize

Note

If all values are the same (range = 0), the column is not modified

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(inout) :: df
integer, intent(in) :: col_index

Source Code

    subroutine df_normalize_column_real(df, col_index)
        type(data_frame), intent(inout) :: df
        integer, intent(in) :: col_index

        real(rk), dimension(:), allocatable :: col
        real(rk) :: min_val, max_val, range
        integer :: i

        col = df_get_col_real(df, col_index)
        min_val = calculate_min_real(df, col_index)
        max_val = calculate_max_real(df, col_index)
        range = max_val - min_val

        if (range > 0.0_rk) then
            do i = 1, size(col)
                col(i) = (col(i) - min_val) / range
            end do
            call df_set_col_real(df, col_index, col)
        end if
    end subroutine df_normalize_column_real