Skip to content

Chapter 2: Error in calculation of likelihood for train problem #487

@oildale

Description

@oildale

Hi,

I think the method of calculating likelihood for train problem is incorrect.
For example, if the sensor shows position 5, we can deduce from this that the train is definitely not in position 8, because it is too far from the sensor's readings.
The current method treats positions 6 and 8 as equally likely when reading from sensor is 5.

I think the correct function should look like this:

def lh_train(track, m, sensor_accuracy):
  result = []
  T = len(track)
  for i in range(T):
    if i in [(m - 1) % T, (m + 1) % T]:
      result.append((1 - sensor_accuracy) / 2)
    elif i == m:
      result.append(sensor_accuracy)
    else:
      result.append(0)
  return np.array(result)

By the way, I would like to point out that the modulo operation is missing in Train.sense() method. Currently, when we add sensor error, the resulting position may go outside the allowed position range.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions