def discretize(self):
        """Discretizes the state.

        Discretize the state using the information from the minimum and
        maximum values for each feature and the number of states attributed
        to each feature.
        """
        if not self.discretized:
            return

        nfeatures = type(self).nfeatures
        min_features = type(self).min_features
        max_features = type(self).max_features
        states_per_dim = type(self).states_per_dim

        if min_features is None or min_features.shape[0] != nfeatures:
            raise ValueError("Attribute 'min_features' must be a vectors of length %d." % nfeatures)
        if max_features is None or max_features.shape[0] != nfeatures:
            raise ValueError("Attribute 'max_features' must be a vectors of length %d." % nfeatures)
        if states_per_dim is None or states_per_dim.shape[0] != nfeatures:
            raise ValueError("Attribute 'states_per_dim' must be a vectors of length %d." % nfeatures)

        ds = []
        for i, feat in enumerate(self):
            factor = math.ceil(
                (max_features[i] - min_features[i]) / states_per_dim[i])
            if feat > 0:
                bin_num = int((feat + factor / 2) / factor)
            else:
                bin_num = int((feat - factor / 2) / factor)

            ds.append(bin_num * factor)

        self._features = np.asarray(ds)