コード例 #1
0
ファイル: temp.py プロジェクト: emya/4publiishment
def pos_neg(mat):
    pos = []
    neg = []
    for i in range(len(mat)):
        for j in range(i+1, len(mat)):
            if (i==0 and j==1) or (i==3 and j==4):
               pos.append(mat[i][j])
            else: neg.append(mat[i][j])
    print "pos", pos
    print "neg", neg

datafile = "datasimulationout-proposedmcmcp_exclusive_len50sig15vari1.5noise8.0.out"

m = []

f = open(datafile, 'r')

for line in f:
    list = line.replace('\n', '').split(' ')
    m.append([int(x) for x in list])

f.close()

poi_pmat_p, poi_pmat_s = poi.poisson_p(m)

print "pppppppppppppppppppppppppppppp"
pos_neg(poi_pmat_p)
print "ssssssssssssssssssssssssssssss"
pos_neg(poi_pmat_s)

コード例 #2
0
ファイル: temp.py プロジェクト: emya/ISBRA
#!/usr/bin/env python

import transfer_concretedata as tc
import poiss_binomial as poi

datafile = "datasimulationout-proposedmcmcp_exclusive_len50sig15vari1.5noise8.0.out"

m = []

f = open(datafile, 'r')

for line in f:
    list = line.replace('\n', '').split(' ')
    m.append([int(x) for x in list])

f.close()

poi_pmat_p, poi_pmat_s = poi.poisson_p(m)
コード例 #3
0
def prplot(fisher, proposed, existing, poisson_p, poisson_s, rn, leng, signal, variance, noise, num, roop_n):
    #pid = os.getpid()
    print "prplot starts!"
    sys.stdout.flush()

    fpos_fisher = "pos_"+fisher+"_"+str(rn)+".out"
    fneg_fisher = "neg_"+fisher+"_"+str(rn)+".out"

    pos_fisher = []
    neg_fisher = []

    fpos_poi_p = "pos_"+poisson_p+"_"+str(rn)+".out"
    fneg_poi_p = "neg_"+poisson_p+"_"+str(rn)+".out"

    pos_poi_p = []
    neg_poi_p = []

    fpos_poi_s = "pos_"+poisson_s+"_"+str(rn)+".out"
    fneg_poi_s = "neg_"+poisson_s+"_"+str(rn)+".out"

    pos_poi_s = []
    neg_poi_s = []

    for i in range(5):
        print "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii=%d", i
        sys.stdout.flush()

        m = ins.normal_dist(leng,leng,signal, 0.0, variance, noise, 1, "b")
        datafile = "data"+proposed+".out"
        bm = tc.read_and_writedata_sim_withoutfile(m, 0.5, datafile)
        ft = fisher_test2_exclusive.fisher_test(m)

        poi_pmat_p, poi_pmat_s = poi.poisson_p(m)
        #poi_pmat_p = [[0 for i in range(50)] for j in range(50)]
        #poi_pmat_s = [[0 for i in range(50)] for j in range(50)]

        inproposed1 = proposed+"_num"+str(num*5)
        print "file1", inproposed1
        sys.stdout.flush()

        cmd="sh child_poissonandproposed_exclusive.sh "+str(leng)+" "+str(num)+" "+datafile+" "+inproposed1+""
        os.system(cmd)
        print "inproposed1"

        inproposed2= proposed+"_num"+str(num*5*10)
        print "file2", inproposed2
        sys.stdout.flush()

        cmd="sh child_poissonandproposed_exclusive.sh "+str(leng)+" "+str(num*10)+" "+datafile+" "+inproposed2+""
        os.system(cmd)
        print "inproposed2"

        inexisting1 = existing+"_num"+str(num*5)
        print "inexisting1", inexisting1
        cmd="sh child_poissonandexisting_exclusive.sh "+str(leng)+" "+str(num)+" "+datafile+" "+inexisting1+""
        os.system(cmd)

        inexisting2 = existing+"_num"+str(num*5*10)
        print "inexisting2", inexisting2
        cmd="sh child_poissonandexisting_exclusive.sh "+str(leng)+" "+str(num*10)+" "+datafile+" "+inexisting2+""
        os.system(cmd)

        """
        tmp = 1
        while tmp >0:
            time.sleep(10)
            tmp = int(commands.getoutput("qstat| grep "+"ch_"+str(pid)+" |wc").split()[0])
        """

        for k in range(leng):
            for l in range(k+1, leng):
                if(k == 0 and l == 1) or (k == 3 and l == 4):
                    pos_fisher.append(str(ft[k][l])+" ")
                    pos_poi_p.append(str(poi_pmat_p[k][l])+" ")
                    pos_poi_s.append(str(poi_pmat_s[k][l])+" ")
                else:
                    neg_fisher.append(str(ft[k][l])+" ")
                    neg_poi_p.append(str(poi_pmat_p[k][l])+" ")
                    neg_poi_s.append(str(poi_pmat_s[k][l])+" ")

    ffp = open(fpos_fisher, "w")
    ffn = open(fneg_fisher, "w")
    ffp.writelines(pos_fisher)
    ffn.writelines(neg_fisher)
    ffp.close()
    ffn.close()

    ffp = open(fpos_poi_p, "w")
    ffn = open(fneg_poi_p, "w")
    ffp.writelines(pos_poi_p)
    ffn.writelines(neg_poi_p)
    ffp.close()
    ffn.close()

    ffp = open(fpos_poi_s, "w")
    ffn = open(fneg_poi_s, "w")
    ffp.writelines(pos_poi_s)
    ffn.writelines(neg_poi_s)
    ffp.close()
    ffn.close()
    return 0
コード例 #4
0
def prplot(fisher, proposed, existing, poisson_p, poisson_s, rn, leng, signal, variance, noise, num, roop_n):
    #pid = os.getpid()
    print "prplot starts!"
    sys.stdout.flush()

    fpos_fisher = "pos_"+fisher+"_"+str(rn)+".out"
    fneg_fisher = "neg_"+fisher+"_"+str(rn)+".out"

    pos_fisher = []
    neg_fisher = []

    fpos_poi_p = "pos_"+poisson_p+"_"+str(rn)+".out"
    fneg_poi_p = "neg_"+poisson_p+"_"+str(rn)+".out"

    pos_poi_p = []
    neg_poi_p = []

    fpos_poi_s = "pos_"+poisson_s+"_"+str(rn)+".out"
    fneg_poi_s = "neg_"+poisson_s+"_"+str(rn)+".out"

    pos_poi_s = []
    neg_poi_s = []

    for i in range(5):
        print "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii=%d", i
        sys.stdout.flush()

        m = ins.normal_dist(leng,leng,signal, 0.0, variance, noise, 1, "b")
        datafile = "data"+proposed+".out"
        bm = tc.read_and_writedata_sim_withoutfile(m, 0.5, datafile)
        ft = fisher_test2_together.fisher_test(m)

        poi_pmat_p, poi_pmat_s = poi.poisson_p(m)
        #poi_pmat_p = [[0 for i in range(50)] for j in range(50)]
        #poi_pmat_s = [[0 for i in range(50)] for j in range(50)]

        inproposed1 = proposed+"_num"+str(num*5)
        print "file1", inproposed1
        sys.stdout.flush()

        cmd="sh child_poissonandproposed_together.sh "+str(leng)+" "+str(num)+" "+datafile+" "+inproposed1+""
        os.system(cmd)
        print "inproposed1"

        inproposed2= proposed+"_num"+str(num*5*10)
        print "file2", inproposed2
        sys.stdout.flush()

        cmd="sh child_poissonandproposed_together.sh "+str(leng)+" "+str(num*10)+" "+datafile+" "+inproposed2+""
        os.system(cmd)
        print "inproposed2"

        inexisting1 = existing+"_num"+str(num*5)
        print "inexisting1", inexisting1
        cmd="sh child_poissonandexisting_together.sh "+str(leng)+" "+str(num)+" "+datafile+" "+inexisting1+""
        os.system(cmd)

        inexisting2 = existing+"_num"+str(num*5*10)
        print "inexisting2", inexisting2
        cmd="sh child_poissonandexisting_together.sh "+str(leng)+" "+str(num*10)+" "+datafile+" "+inexisting2+""
        os.system(cmd)

        """
        tmp = 1
        while tmp >0:
            time.sleep(10)
            tmp = int(commands.getoutput("qstat| grep "+"ch_"+str(pid)+" |wc").split()[0])
        """

        for k in range(leng):
            for l in range(k+1, leng):
                if(k == 0 and l == 1) or (k == 3 and l == 4):
                    pos_fisher.append(str(ft[k][l])+" ")
                    pos_poi_p.append(str(poi_pmat_p[k][l])+" ")
                    pos_poi_s.append(str(poi_pmat_s[k][l])+" ")
                else:
                    neg_fisher.append(str(ft[k][l])+" ")
                    neg_poi_p.append(str(poi_pmat_p[k][l])+" ")
                    neg_poi_s.append(str(poi_pmat_s[k][l])+" ")

    ffp = open(fpos_fisher, "w")
    ffn = open(fneg_fisher, "w")
    ffp.writelines(pos_fisher)
    ffn.writelines(neg_fisher)
    ffp.close()
    ffn.close()

    ffp = open(fpos_poi_p, "w")
    ffn = open(fneg_poi_p, "w")
    ffp.writelines(pos_poi_p)
    ffn.writelines(neg_poi_p)
    ffp.close()
    ffn.close()

    ffp = open(fpos_poi_s, "w")
    ffn = open(fneg_poi_s, "w")
    ffp.writelines(pos_poi_s)
    ffn.writelines(neg_poi_s)
    ffp.close()
    ffn.close()
    return 0