Error Bars
        create bars and error bars to plot
    Inputs  :
        n_bins   :
            number of bins
        plot_range : (shape) = (number of dimensions, 2)
            matrix which contain the min and max for each dimension as rows
    Outputs :
        x     :
            domain
        p_x   :
            estimated posterior using the chain on the domain
        error :
            estimated error for p_x

def error_bars(self, n_bins, d_min, d_max):
        """
    Error Bars
        create bars and error bars to plot
    Inputs  :
        n_bins   :
            number of bins
        plot_range : (shape) = (number of dimensions, 2)
            matrix which contain the min and max for each dimension as rows
    Outputs :
        x     :
            domain
        p_x   :
            estimated posterior using the chain on the domain
        error :
            estimated error for p_x
        """
        # fetch data
        chain = self._chain
        len_chain = len(chain)
        try:
            n_dims = np.shape(chain)[1]
        except:
            n_dims = 1

        # begin checks
        try: 
            assert n_bins == int(n_bins)
        except: 
            raise TypeError("number of bins has to be an integer")
        d_min = np.reshape(np.array(d_min), (-1,1))
        d_max = np.reshape(np.array(d_max), (-1,1))
        try: 
            assert np.size(d_min) == n_dims
        except: 
            raise TypeError("domain minimum has wrong size")
        try: 
            assert np.size(d_max) == n_dims
        except: 
            raise TypeError("domain maximum has wrong size")
        # end checks

        # initialize outputs
        p_x = np.zeros(n_bins) # esitmate of posterior
        error = np.zeros(n_bins) # error bars
        x = np.zeros((n_dims, n_bins)) # centers of bins

        # set dx
        v = d_max-d_min
        v_2 = np.dot(v.T, v)[0][0]

        # bin count
        for i in xrange(len_chain):
            bin_no = int(np.floor(np.dot(chain[i].T-d_min,v)/v_2*n_bins)[0])
            if n_bins > bin_no > -1:
                p_x[bin_no] += 1.
        # end count
        dx = np.sqrt(v_2)/n_bins
        p_x = p_x/(len_chain*dx)
        # find error
        for i in xrange(n_bins):
            p = p_x[i]
            error[i] = np.sqrt(p*(1./dx-p)/(len_chain))
            x[:,i] = (d_min+v*(0.5+i)/n_bins)[0]
        # end find
        return x, p_x, error