def _backward_sampling_ON2(self, M, idx):
        """O(N^2) version of backward sampling.

        not meant to be called directly, see backward_sampling
        """
        for m in range(M):
            for t in reversed(range(self.T - 1)):
                lwm = (self.wgt[t].lw + self.model.logpt(t + 1, self.X[t],
                                                     self.X[t + 1][idx[t + 1, m]]))
                idx[t, m] = rs.multinomial_once(rs.exp_and_normalise(lwm))
O(N^2) version of backward sampling.

        not meant to be called directly, see backward_sampling