001 package aima.probability.reasoning; 002 003 import java.util.ArrayList; 004 import java.util.List; 005 006 import aima.util.Matrix; 007 import aima.util.Table; 008 009 /** 010 * @author Ravi Mohan 011 * 012 */ 013 014 public class SensorModel { 015 private Table<String, String, Double> table; 016 017 private List<String> states; 018 019 public SensorModel(List<String> states, List<String> perceptions) { 020 this.states = states; 021 table = new Table<String, String, Double>(states, perceptions); 022 } 023 024 public void setSensingProbability(String state, String perception, 025 double probability) { 026 table.set(state, perception, probability); 027 028 } 029 030 public Double get(String state, String perception) { 031 032 return table.get(state, perception); 033 } 034 035 public Matrix asMatrix(String perception) { 036 List<Double> values = new ArrayList<Double>(); 037 // for (String state : aBelief.states()) { 038 for (String state : states) { 039 values.add(get(state, perception)); 040 } 041 Matrix OMatrix = Matrix.createDiagonalMatrix(values); 042 return OMatrix; 043 } 044 045 }