def calcPosition_Multilateration(d,nSensor,nAnchor,sigma,radiorange,iteN,typeE,typeC):
    print "Multilateraitonによる位置計算を開始"
    print ""
    locSensorNs = []
    RMSDs =[]
    RMSDs_modified=[]
    i=0
    breachN = 0
    while i-breachN < iteN:
        [posX,locX,disX,conX,noisyDisX,trueDisX,estPosX,cLevel] = problems.createProblem_random(d,nSensor,nAnchor,sigma,radiorange,i)
        multi.localizeByMultilateration(nSensor,nAnchor,sigma,radiorange,locX,conX,estPosX,noisyDisX,cLevel,typeE,typeC)
        [nLocSensor,preLocSensor] = helper.analyseLocalizability(nSensor,nAnchor,locX)
        locSensorNs.append(nLocSensor)
        rmsd = helper.calcRMSD(nSensor,locX,posX,estPosX)
        RMSDs.append(rmsd)
        if rmsd <1.5:
            RMSDs_modified.append(rmsd)
        else: breachN +=1
        i+=1
        print rmsd
    perLocSensor = sum(locSensorNs)/nSensor/iteN
    perMinLocSensor = min(locSensorNs)/nSensor
    perMaxLocSensor = max(locSensorNs)/nSensor
    [aveRMSD,minRMSD,maxRMSD] = helper.analyseRMSDs(RMSDs)

    [aveRMSD_modified,minRMSD_modified,maxRMSD_modified]= helper.analyseRMSDs(RMSDs_modified)
    return [perLocSensor,perMinLocSensor,perMaxLocSensor,aveRMSD,minRMSD,maxRMSD,aveRMSD_modified,breachN]
def calcPosition_Trilateration(d,nSensor,nAnchor,sigma,radiorange,iteN,type):
    print "Trilaterationによる位置計算を開始"
    locSensorNs = []
    RMSDs =[]
    for i in range(iteN):
        [posX,locX,disX,conX,noisyDisX,trueDisX,estPosX,cLevel] = problems.createProblem_random(d,nSensor,nAnchor,sigma,radiorange,i+100)
        if type==1:tri.localizeByTrilateration(nSensor,nAnchor,locX,conX,estPosX,noisyDisX,cLevel)
        [nLocSensor,preLocSensor] = helper.analyseLocalizability(nSensor,nAnchor,locX)

        locSensorNs.append(nLocSensor)
        rmsd = helper.calcRMSD(nSensor,locX,posX,estPosX)
        RMSDs.append(rmsd)

        print nLocSensor
        print rmsd
    perLocSensor = sum(locSensorNs)/nSensor/iteN
    perMinLocSensor = min(locSensorNs)/nSensor
    perMaxLocSensor = max(locSensorNs)/nSensor
    [aveRMSD,minRMSD,maxRMSD] = helper.analyseRMSDs(RMSDs)
    RMSDsModified = [elem for elem in RMSDs if elem<1]
    [aveRMSD_modified,a,b]= helper.analyseRMSDs(RMSDsModified)
    return [perLocSensor,perMinLocSensor,perMaxLocSensor,aveRMSD,minRMSD,maxRMSD,aveRMSD_modified]