df_standardize_column_real Subroutine

public subroutine df_standardize_column_real(df, col_index)

Standardize a real column (z-score: mean=0, std=1)

Applies z-score standardization: (x - mean) / std

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

Note

If std = 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_standardize_column_real(df, col_index)
        type(data_frame), intent(inout) :: df
        integer, intent(in) :: col_index

        real(rk), dimension(:), allocatable :: col
        real(rk) :: mean_val, std_val
        integer :: i

        col = df_get_col_real(df, col_index)
        mean_val = calculate_mean_real(df, col_index)
        std_val = calculate_std_real(df, col_index)

        if (std_val > 0.0_rk) then
            do i = 1, size(col)
                col(i) = (col(i) - mean_val) / std_val
            end do
            call df_set_col_real(df, col_index, col)
        end if
    end subroutine df_standardize_column_real