fork download
  1. #Modify your code so that it normalizes the output for
  2. #the function sense. This means that the entries in q
  3. #should sum to one.
  4.  
  5.  
  6. p=[0.2, 0.2, 0.2, 0.2, 0.2]
  7. world=['green', 'red', 'red', 'green', 'green']
  8. Z = 'red'
  9. pHit = 0.6
  10. pMiss = 0.2
  11. s=0
  12. def sense(p, Z):
  13. q=[]
  14. for i in range(len(p)):
  15. hit = (Z == world[i])
  16. q.append(p[i] * (hit * pHit + (1-hit) * pMiss))
  17. s+= q[i]
  18.  
  19. return s
  20. print sense(p,Z)
  21.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.nim(6, 1) Error: undeclared identifier: 'p'
stdout
Standard output is empty