def steady_state_potential(xdata,HistBins=100):
    """ 
    Calculates the steady state potential.

    Parameters
    ----------
    xdata : ndarray
        Position data for a degree of freedom
    HistBins : int
        Number of bins to use for histogram
        of xdata. Number of position points
        at which the potential is calculated.

    Returns
    -------
    position : ndarray
        positions at which potential has been 
        calculated
    potential : ndarray
        value of potential at the positions above
    
    """  
    import numpy as np
    
    pops=np.histogram(xdata,HistBins)[0]
    bins=np.histogram(xdata,HistBins)[1]
    bins=bins[0:-1]
    bins=bins+np.mean(np.diff(bins))
    
    #normalise pops
    pops=pops/float(np.sum(pops))
    
    return bins,-np.log(pops)