def write_output(Q, P, other, params):

    """
    write the posterior means and variational parameters
    to separate output files.
    """

    handle = open('%s.%d.meanQ'%(params['outputfile'],params['K']),'w')
    handle.write('\n'.join(['  '.join(['%.6f'%i for i in q]) for q in Q])+'\n')
    handle.close()

    handle = open('%s.%d.meanP'%(params['outputfile'],params['K']),'w')
    handle.write('\n'.join(['  '.join([i%'%.6f' for i in p]) for p in P])+'\n')
    handle.close()

    if params['full']:
        handle = open('%s.%d.varQ'%(params['outputfile'],params['K']),'w')
        handle.write('\n'.join(['  '.join(['%.6f'%i for i in q]) for q in other['varQ']])+'\n')
        handle.close()

        handle = open('%s.%d.varP'%(params['outputfile'],params['K']),'w')
        handle.write('\n'.join(['  '.join(['%.6f'%i for i in np.hstack((pb,pg))]) \
            for pb,pg in zip(other['varPb'],other['varPg'])])+'\n')
        handle.close()
dataset/ETHPy150Open rajanil/fastStructure/structure.py/write_output/swapped operands of `%`