有没有办法在角点图中画出条件平均数?

2024-04-27 05:06:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用python处理三个数据集,我计划用这些数据集生成一个corner plot,但我希望能够绘制条件平均值,就像分位数选项显示的here,但我不确定如何做到这一点,任何洞察都将被搁置。你知道吗

编辑: 下面是我的部分代码(假设每个文件都有相同的前缀,并且提供了变量的数量)

       truths = np.array([ 0.5, 1.4 ,2.0,  3.3, 2.6, 1.960])
        labels = [ "$f$" ,"$a$" ,"$Ks$", "$Kb$" ,"$N$","$rho$"]

        dimension = int(sys.argv[2])

        #get the shape of walkers
        test = np.genfromtxt( sys.argv[1] + str(0)+".csv" , dtype=float, delimiter=',')

        print "\n\nWalkers : "   , test.shape[0]
        print "Walks   : ", test.shape[1]

        sampler = np.zeros( ( test.shape[0], test.shape[1] , dimension )  )

        # read data
        for i in range(0,dimension):

            sampler[:,:,i] = np.genfromtxt( sys.argv[1] + str(i)+".csv" , dtype=float, delimiter=',')
        #10 percent burnout
        burn_out = int( math.ceil( 0.1 * test.shape[1]) )

        print "burn out: ", burn_out
        print "\n\n"

        samples = sampler[:, burn_out :, :].reshape((-1, dimension))

        fig = corner.corner(samples, labels=labels[0:dimension], truths=truths[0:dimension] ,  show_titles=True, title_kwargs={"fontsize": 12} )

        fig.savefig("triangle.png")

Tags: 数据testlabelsnpsysoutintprint