Get the log likelihood of a combined set of clusters, fitting the offsets
    
    arguments:
    inputs -- the 'X's in a list, one item per cluster
    data -- the 'Y's in a list, one item per cluster
    clust -- list of clusters to use
    
    returns a tuple:
    log likelihood and the offset

def get_log_likelihood_offset(inputs,data,clust):
    """Get the log likelihood of a combined set of clusters, fitting the offsets
    
    arguments:
    inputs -- the 'X's in a list, one item per cluster
    data -- the 'Y's in a list, one item per cluster
    clust -- list of clusters to use
    
    returns a tuple:
    log likelihood and the offset
    """    
        
    #if we've only got one cluster, the model has an error, so we want to just
    #use normal GPRegression.
    if len(clust)==1: 
        return get_log_likelihood(inputs,data,clust)
                
    S = data[0].shape[0] #number of time series
        
    X = np.zeros([0,2]) #notice the extra column, this is for the cluster index
    Y = np.zeros([0,S])
    
    #for each person in the cluster, add their inputs and data to the new
    #dataset. Note we add an index identifying which person is which data point.
    #This is for the offset model to use, to allow it to know which data points
    #to shift.
    for i,p in enumerate(clust):
        idx = i*np.ones([inputs[p].shape[0],1])
        X = np.vstack([X,np.hstack([inputs[p],idx])])
        Y = np.vstack([Y,data[p].T])
        
    m = GPy.models.GPOffsetRegression(X,Y)
    #TODO: How to select a sensible prior?
    m.offset.set_prior(GPy.priors.Gaussian(0,20)) 
    #TODO: Set a sensible start value for the length scale,
    #make it long to help the offset fit.
    
    m.optimize()
    
    ll = m.log_likelihood()
    offset = m.offset.values[0]
    return ll,offset