def normalize_data(data, maxv, minv):
    """
        Normalizes the data given the maximum and minimum values of each variable.

        Parameters
        ----------
        data: numpy n x m
            Numpy array comprising n realisations (instances) of m variables.
        maxv, minv: numpy m
            The maximum and minimum values of each variable. One and zero, resp.
            if the variable is categorical.

        Returns
        -------
        data: numpy n x m
            The normalized data.
    """
    data = data.copy()
    for v in range(data.shape[1]):
        if maxv[v] != minv[v]:
            data[:, v] = (data[:, v] - minv[v])/(maxv[v] - minv[v])
    return data