Example #1
0
    def trainAndCompare(self, K, noise):
        self.rs.deltaK = K
        for i in self.rs.sizeOfTarget:
            launchCMAESForAllPoint(self.rs, i, None, noise)

        resultPath = os.getcwd() + "../Data/CMAESK" + str(K) + "/"
        resultName = "geneForHits/finalX/x.last"

        nameTheta = "Best"
        name = "geneForHits"
        nbret = 50
        generateFromCMAESNController(nbret, self.rs, nameTheta, name, noise)

        result1 = np.loadtxt(resultPath + "0.005/" + resultName)
        result2 = np.loadtxt(resultPath + "0.01/" + resultName)
        result3 = np.loadtxt(resultPath + "0.02/" + resultName)
        result4 = np.loadtxt(resultPath + "0.04/" + resultName)

        return -(cp.kl(result1, self.experiment1, 0.0025) +
                 cp.kl(result2, self.experiment2, 0.005) +
                 cp.kl(result3, self.experiment3, 0.01) +
                 cp.kl(result4, self.experiment4, 0.02))
Example #2
0
    def trainAndCompare(self, K, noise):
        self.rs.deltaK = K
        for i in self.rs.sizeOfTarget:
            launchCMAESForAllPoint(self.rs, i, None, noise)

        resultPath = os.getcwd() + "../Data/CMAESK" + str(K) + "/"
        resultName = "geneForHits/finalX/x.last"

        nameTheta = "Best"
        name = "geneForHits"
        nbret = 50
        generateFromCMAESNController(nbret, self.rs, nameTheta, name, noise)

        result1 = np.loadtxt(resultPath + "0.005/" + resultName)
        result2 = np.loadtxt(resultPath + "0.01/" + resultName)
        result3 = np.loadtxt(resultPath + "0.02/" + resultName)
        result4 = np.loadtxt(resultPath + "0.04/" + resultName)

        return -(
            cp.kl(result1, self.experiment1, 0.0025)
            + cp.kl(result2, self.experiment2, 0.005)
            + cp.kl(result3, self.experiment3, 0.01)
            + cp.kl(result4, self.experiment4, 0.02)
        )
Example #3
0
experimentalFolder = "~/ArmModelPython/Data/ExperimentalHits/"

experiment1 = np.loadtxt(experimentalFolder + "hits0.005")[:, 1]
experiment2 = np.loadtxt(experimentalFolder + "hits0.01")[:, 1]
experiment3 = np.loadtxt(experimentalFolder + "hits0.02")[:, 1]
experiment4 = np.loadtxt(experimentalFolder + "hits0.04")[:, 1]

print(experiment1.shape[0])

resultPath = "~/ArmModelPython/Data/CMAESK20/"
resultName = "50/finalX/x.last"

result1 = np.loadtxt(resultPath + "0.005/" + resultName)
result2 = np.loadtxt(resultPath + "0.01/" + resultName)
result3 = np.loadtxt(resultPath + "0.02/" + resultName)
result4 = np.loadtxt(resultPath + "0.04/" + resultName)

print("chi2, taille 0.005 : " + str(cp.chi2(result1, experiment1)))
print("KS, taille 0.005 : " + str(cp.ks(result1, experiment1)))
print("MWWRankSum, taille 0.005 : " + str(cp.MWWRankSum(result1, experiment1)))
print("KL, taille 0.005 : " + str(cp.kl(result1, experiment1)))

print cp.mw(np.random.normal(0, 0.005, 10000),
            np.random.normal(0, 0.005, 10000))
print cp.ks(np.random.normal(0, 0.005, 10000),
            np.random.normal(0, 0.005, 10000))
print(
    cp.kl(np.random.normal(0, 0.005, 10000), np.random.normal(0, 0.005,
                                                              10000)))
Example #4
0
import Utils.Compare as cp
import numpy as np
import matplotlib.pyplot as plt

experimentalFolder="~/ArmModelPython/Data/ExperimentalHits/"

experiment1 = np.loadtxt(experimentalFolder+"hits0.005")[:,1]
experiment2 = np.loadtxt(experimentalFolder+"hits0.01")[:,1]
experiment3 = np.loadtxt(experimentalFolder+"hits0.02")[:,1]
experiment4 = np.loadtxt(experimentalFolder+"hits0.04")[:,1]

print(experiment1.shape[0])

resultPath="~/ArmModelPython/Data/CMAESK20/"
resultName="50/finalX/x.last"

result1= np.loadtxt(resultPath+"0.005/"+resultName)
result2= np.loadtxt(resultPath+"0.01/"+resultName)
result3= np.loadtxt(resultPath+"0.02/"+resultName)
result4= np.loadtxt(resultPath+"0.04/"+resultName)


print ("chi2, taille 0.005 : " + str(cp.chi2(result1, experiment1)))
print ("KS, taille 0.005 : " + str(cp.ks(result1, experiment1)))
print ("MWWRankSum, taille 0.005 : " + str(cp.MWWRankSum(result1, experiment1)))
print ("KL, taille 0.005 : " + str(cp.kl(result1, experiment1)))

print cp.mw(np.random.normal(0,0.005,10000),np.random.normal(0,0.005,10000))
print cp.ks(np.random.normal(0,0.005,10000),np.random.normal(0,0.005,10000))
print (cp.kl(np.random.normal(0,0.005,10000),np.random.normal(0,0.005,10000)))