Created
February 26, 2012 03:39
-
-
Save swuecho/1912801 to your computer and use it in GitHub Desktop.
local
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
colors = [['red', 'green', 'green', 'red' , 'red'], | |
['red', 'red', 'green', 'red', 'red'], | |
['red', 'red', 'green', 'green', 'red'], | |
['red', 'red', 'red', 'red', 'red']] | |
measurements = ['green', 'green', 'green' ,'green', 'green'] | |
motions = [[0,0],[0,1],[1,0],[1,0],[0,1]] | |
sensor_right = 0.7 | |
p_move = 0.8 | |
def show(p): | |
for i in range(len(p)): | |
print p[i] | |
#DO NOT USE IMPORT | |
#ENTER CODE BELOW HERE | |
#ANY CODE ABOVE WILL CAUSE | |
#HOMEWORK TO BE GRADED | |
#INCORRECT | |
p = [] | |
sum=0 | |
for k in range(len(colors)): | |
sum=sum+len(colors[k]) | |
pvalue=1./sum | |
for i in range(len(colors)): | |
q=[] | |
for j in range(len(colors[i])): | |
q.append(pvalue) | |
p.append(q) | |
def sense(p, Z): | |
q = [ ] | |
for i in range(len(p)): | |
n=[] | |
for j in range(len(p[i]): | |
hit = (Z == colors[i]) | |
n.append(p[i][j] * (hit * sensor_right + (1-hit) * pMiss)) | |
return q | |
#Your probability array must be printed | |
#with the following code. | |
show(p) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment